diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-28 21:10:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-28 21:10:12 +0300 |
commit | 52e32e255f7d868c4ec952a201bb8813b5e03703 (patch) | |
tree | 4b1678207027093c6f0cf0ad0dfa07979fad2092 /spec/frontend/issues_list | |
parent | 42d13aebd3c47671337d871e8b349385dade5252 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/issues_list')
-rw-r--r-- | spec/frontend/issues_list/components/issues_list_app_spec.js | 89 |
1 files changed, 42 insertions, 47 deletions
diff --git a/spec/frontend/issues_list/components/issues_list_app_spec.js b/spec/frontend/issues_list/components/issues_list_app_spec.js index 7d559de507a..b63940e0240 100644 --- a/spec/frontend/issues_list/components/issues_list_app_spec.js +++ b/spec/frontend/issues_list/components/issues_list_app_spec.js @@ -6,6 +6,7 @@ import waitForPromises from 'helpers/wait_for_promises'; import { apiParams, filteredTokens, locationSearch, urlParams } from 'jest/issues_list/mock_data'; import createFlash from '~/flash'; import CsvImportExportButtons from '~/issuable/components/csv_import_export_buttons.vue'; +import IssuableByEmail from '~/issuable/components/issuable_by_email.vue'; import IssuableList from '~/issuable_list/components/issuable_list_root.vue'; import { IssuableListTabs, IssuableStates } from '~/issuable_list/constants'; import IssuesListApp from '~/issues_list/components/issues_list_app.vue'; @@ -24,7 +25,6 @@ import { setUrlParams } from '~/lib/utils/url_utility'; jest.mock('~/flash'); describe('IssuesListApp component', () => { - const originalWindowLocation = window.location; let axiosMock; let wrapper; @@ -65,6 +65,7 @@ describe('IssuesListApp component', () => { }; const findCsvImportExportButtons = () => wrapper.findComponent(CsvImportExportButtons); + const findIssuableByEmail = () => wrapper.findComponent(IssuableByEmail); const findGlButton = () => wrapper.findComponent(GlButton); const findGlButtons = () => wrapper.findAllComponents(GlButton); const findGlButtonAt = (index) => findGlButtons().at(index); @@ -88,7 +89,7 @@ describe('IssuesListApp component', () => { }); afterEach(() => { - window.location = originalWindowLocation; + global.jsdom.reconfigure({ url: TEST_HOST }); axiosMock.reset(); wrapper.destroy(); }); @@ -122,34 +123,31 @@ describe('IssuesListApp component', () => { describe('header action buttons', () => { it('renders rss button', () => { - wrapper = mountComponent(); + wrapper = mountComponent({ mountFn: mount }); + expect(findGlButtonAt(0).props('icon')).toBe('rss'); expect(findGlButtonAt(0).attributes()).toMatchObject({ href: defaultProvide.rssPath, - icon: 'rss', 'aria-label': IssuesListApp.i18n.rssLabel, }); }); it('renders calendar button', () => { - wrapper = mountComponent(); + wrapper = mountComponent({ mountFn: mount }); + expect(findGlButtonAt(1).props('icon')).toBe('calendar'); expect(findGlButtonAt(1).attributes()).toMatchObject({ href: defaultProvide.calendarPath, - icon: 'calendar', 'aria-label': IssuesListApp.i18n.calendarLabel, }); }); it('renders csv import/export component', async () => { - const search = '?page=1&search=refactor'; + const search = '?page=1&search=refactor&state=opened&order_by=created_at&sort=desc'; - Object.defineProperty(window, 'location', { - writable: true, - value: { search }, - }); + global.jsdom.reconfigure({ url: `${TEST_HOST}${search}` }); - wrapper = mountComponent(); + wrapper = mountComponent({ mountFn: mount }); await waitForPromises(); @@ -161,7 +159,7 @@ describe('IssuesListApp component', () => { describe('bulk edit button', () => { it('renders when user has permissions', () => { - wrapper = mountComponent({ provide: { canBulkUpdate: true } }); + wrapper = mountComponent({ provide: { canBulkUpdate: true }, mountFn: mount }); expect(findGlButtonAt(2).text()).toBe('Edit issues'); }); @@ -173,7 +171,7 @@ describe('IssuesListApp component', () => { }); it('emits "issuables:enableBulkEdit" event to legacy bulk edit class', () => { - wrapper = mountComponent({ provide: { canBulkUpdate: true } }); + wrapper = mountComponent({ provide: { canBulkUpdate: true }, mountFn: mount }); jest.spyOn(eventHub, '$emit'); @@ -185,7 +183,7 @@ describe('IssuesListApp component', () => { describe('new issue button', () => { it('renders when user has permissions', () => { - wrapper = mountComponent({ provide: { showNewIssueLink: true } }); + wrapper = mountComponent({ provide: { showNewIssueLink: true }, mountFn: mount }); expect(findGlButtonAt(2).text()).toBe('New issue'); expect(findGlButtonAt(2).attributes('href')).toBe(defaultProvide.newIssuePath); @@ -204,10 +202,7 @@ describe('IssuesListApp component', () => { it('is set from the url params', () => { const page = 5; - Object.defineProperty(window, 'location', { - writable: true, - value: { href: setUrlParams({ page }, TEST_HOST) }, - }); + global.jsdom.reconfigure({ url: setUrlParams({ page }, TEST_HOST) }); wrapper = mountComponent(); @@ -217,10 +212,7 @@ describe('IssuesListApp component', () => { describe('search', () => { it('is set from the url params', () => { - Object.defineProperty(window, 'location', { - writable: true, - value: { search: locationSearch }, - }); + global.jsdom.reconfigure({ url: `${TEST_HOST}${locationSearch}` }); wrapper = mountComponent(); @@ -230,10 +222,7 @@ describe('IssuesListApp component', () => { describe('sort', () => { it.each(Object.keys(sortParams))('is set as %s from the url params', (sortKey) => { - Object.defineProperty(window, 'location', { - writable: true, - value: { href: setUrlParams(sortParams[sortKey], TEST_HOST) }, - }); + global.jsdom.reconfigure({ url: setUrlParams(sortParams[sortKey], TEST_HOST) }); wrapper = mountComponent(); @@ -248,10 +237,7 @@ describe('IssuesListApp component', () => { it('is set from the url params', () => { const initialState = IssuableStates.All; - Object.defineProperty(window, 'location', { - writable: true, - value: { href: setUrlParams({ state: initialState }, TEST_HOST) }, - }); + global.jsdom.reconfigure({ url: setUrlParams({ state: initialState }, TEST_HOST) }); wrapper = mountComponent(); @@ -261,10 +247,7 @@ describe('IssuesListApp component', () => { describe('filter tokens', () => { it('is set from the url params', () => { - Object.defineProperty(window, 'location', { - writable: true, - value: { search: locationSearch }, - }); + global.jsdom.reconfigure({ url: `${TEST_HOST}${locationSearch}` }); wrapper = mountComponent(); @@ -290,16 +273,25 @@ describe('IssuesListApp component', () => { ); }); + describe('IssuableByEmail component', () => { + describe.each([true, false])(`when issue creation by email is enabled=%s`, (enabled) => { + it(`${enabled ? 'renders' : 'does not render'}`, () => { + wrapper = mountComponent({ provide: { initialEmail: enabled } }); + + expect(findIssuableByEmail().exists()).toBe(enabled); + }); + }); + }); + describe('empty states', () => { describe('when there are issues', () => { describe('when search returns no results', () => { - beforeEach(() => { - Object.defineProperty(window, 'location', { - writable: true, - value: { search: '?search=no+results' }, - }); + beforeEach(async () => { + global.jsdom.reconfigure({ url: `${TEST_HOST}?search=no+results` }); + + wrapper = mountComponent({ provide: { hasIssues: true }, mountFn: mount }); - wrapper = mountComponent({ provide: { hasIssues: true } }); + await waitForPromises(); }); it('shows empty state', () => { @@ -312,8 +304,10 @@ describe('IssuesListApp component', () => { }); describe('when "Open" tab has no issues', () => { - beforeEach(() => { - wrapper = mountComponent({ provide: { hasIssues: true } }); + beforeEach(async () => { + wrapper = mountComponent({ provide: { hasIssues: true }, mountFn: mount }); + + await waitForPromises(); }); it('shows empty state', () => { @@ -327,12 +321,13 @@ describe('IssuesListApp component', () => { describe('when "Closed" tab has no issues', () => { beforeEach(async () => { - Object.defineProperty(window, 'location', { - writable: true, - value: { href: setUrlParams({ state: IssuableStates.Closed }, TEST_HOST) }, + global.jsdom.reconfigure({ + url: setUrlParams({ state: IssuableStates.Closed }, TEST_HOST), }); - wrapper = mountComponent({ provide: { hasIssues: true } }); + wrapper = mountComponent({ provide: { hasIssues: true }, mountFn: mount }); + + await waitForPromises(); }); it('shows empty state', () => { |