diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/frontend/whats_new | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/frontend/whats_new')
-rw-r--r-- | spec/frontend/whats_new/components/app_spec.js | 11 | ||||
-rw-r--r-- | spec/frontend/whats_new/components/feature_spec.js | 46 | ||||
-rw-r--r-- | spec/frontend/whats_new/store/actions_spec.js | 21 |
3 files changed, 75 insertions, 3 deletions
diff --git a/spec/frontend/whats_new/components/app_spec.js b/spec/frontend/whats_new/components/app_spec.js index 45c4682208b..12034346aba 100644 --- a/spec/frontend/whats_new/components/app_spec.js +++ b/spec/frontend/whats_new/components/app_spec.js @@ -82,6 +82,7 @@ describe('App', () => { }); const getDrawer = () => wrapper.find(GlDrawer); + const getBackdrop = () => wrapper.find('.whats-new-modal-backdrop'); it('contains a drawer', () => { expect(getDrawer().exists()).toBe(true); @@ -100,6 +101,11 @@ describe('App', () => { expect(actions.closeDrawer).toHaveBeenCalled(); }); + it('dispatches closeDrawer when clicking the backdrop', () => { + getBackdrop().trigger('click'); + expect(actions.closeDrawer).toHaveBeenCalled(); + }); + it.each([true, false])('passes open property', async (openState) => { wrapper.vm.$store.state.open = openState; @@ -149,7 +155,10 @@ describe('App', () => { wrapper.vm.$store.state.pageInfo = { nextPage: 840 }; emitBottomReached(); - expect(actions.fetchItems).toHaveBeenCalledWith(expect.anything(), { page: 840 }); + expect(actions.fetchItems).toHaveBeenCalledWith(expect.anything(), { + page: 840, + versionDigest: 'version-digest', + }); }); it('when nextPage does not exist it does not call fetchItems', () => { diff --git a/spec/frontend/whats_new/components/feature_spec.js b/spec/frontend/whats_new/components/feature_spec.js new file mode 100644 index 00000000000..9e9cb59c0d6 --- /dev/null +++ b/spec/frontend/whats_new/components/feature_spec.js @@ -0,0 +1,46 @@ +import { shallowMount } from '@vue/test-utils'; +import Feature from '~/whats_new/components/feature.vue'; + +describe("What's new single feature", () => { + /** @type {import("@vue/test-utils").Wrapper} */ + let wrapper; + + const exampleFeature = { + title: 'Compliance pipeline configurations', + body: + '<p>We are thrilled to announce that it is now possible to define enforceable pipelines that will run for any project assigned a corresponding compliance framework.</p>', + stage: 'Manage', + 'self-managed': true, + 'gitlab-com': true, + packages: ['Ultimate'], + url: 'https://docs.gitlab.com/ee/user/project/settings/#compliance-pipeline-configuration', + image_url: 'https://img.youtube.com/vi/upLJ_equomw/hqdefault.jpg', + published_at: '2021-04-22T00:00:00.000Z', + release: '13.11', + }; + + const findReleaseDate = () => wrapper.find('[data-testid="release-date"]'); + + const createWrapper = ({ feature } = {}) => { + wrapper = shallowMount(Feature, { + propsData: { feature }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + it('renders the date', () => { + createWrapper({ feature: exampleFeature }); + expect(findReleaseDate().text()).toBe('April 22, 2021'); + }); + + describe('when the published_at is null', () => { + it("doesn't render the date", () => { + createWrapper({ feature: { ...exampleFeature, published_at: null } }); + expect(findReleaseDate().exists()).toBe(false); + }); + }); +}); diff --git a/spec/frontend/whats_new/store/actions_spec.js b/spec/frontend/whats_new/store/actions_spec.js index 39ad526cf14..c9614c7330b 100644 --- a/spec/frontend/whats_new/store/actions_spec.js +++ b/spec/frontend/whats_new/store/actions_spec.js @@ -44,16 +44,33 @@ describe('whats new actions', () => { axiosMock.restore(); }); + it("doesn't require arguments", () => { + axiosMock.reset(); + + axiosMock + .onGet('/-/whats_new', { params: { page: undefined, v: undefined } }) + .replyOnce(200, [{ title: 'GitLab Stories' }]); + + testAction( + actions.fetchItems, + {}, + {}, + expect.arrayContaining([ + { type: types.ADD_FEATURES, payload: [{ title: 'GitLab Stories' }] }, + ]), + ); + }); + it('passes arguments', () => { axiosMock.reset(); axiosMock - .onGet('/-/whats_new', { params: { page: 8 } }) + .onGet('/-/whats_new', { params: { page: 8, v: 42 } }) .replyOnce(200, [{ title: 'GitLab Stories' }]); testAction( actions.fetchItems, - { page: 8 }, + { page: 8, versionDigest: 42 }, {}, expect.arrayContaining([ { type: types.ADD_FEATURES, payload: [{ title: 'GitLab Stories' }] }, |