diff options
Diffstat (limited to 'spec/frontend/issues_list/components/issues_list_app_spec.js')
-rw-r--r-- | spec/frontend/issues_list/components/issues_list_app_spec.js | 134 |
1 files changed, 128 insertions, 6 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 5d83bf0142f..d78a436c618 100644 --- a/spec/frontend/issues_list/components/issues_list_app_spec.js +++ b/spec/frontend/issues_list/components/issues_list_app_spec.js @@ -18,6 +18,15 @@ import { PAGE_SIZE_MANUAL, PARAM_DUE_DATE, RELATIVE_POSITION_DESC, + TOKEN_TYPE_ASSIGNEE, + TOKEN_TYPE_AUTHOR, + TOKEN_TYPE_CONFIDENTIAL, + TOKEN_TYPE_EPIC, + TOKEN_TYPE_ITERATION, + TOKEN_TYPE_LABEL, + TOKEN_TYPE_MILESTONE, + TOKEN_TYPE_MY_REACTION, + TOKEN_TYPE_WEIGHT, urlSortParams, } from '~/issues_list/constants'; import eventHub from '~/issues_list/eventhub'; @@ -39,8 +48,8 @@ describe('IssuesListApp component', () => { endpoint: 'api/endpoint', exportCsvPath: 'export/csv/path', hasBlockedIssuesFeature: true, - hasIssues: true, hasIssueWeightsFeature: true, + hasProjectIssues: true, isSignedIn: false, issuesPath: 'path/to/issues', jiraIntegrationPath: 'jira/integration/path', @@ -320,7 +329,7 @@ describe('IssuesListApp component', () => { beforeEach(async () => { global.jsdom.reconfigure({ url: `${TEST_HOST}?search=no+results` }); - wrapper = mountComponent({ provide: { hasIssues: true }, mountFn: mount }); + wrapper = mountComponent({ provide: { hasProjectIssues: true }, mountFn: mount }); await waitForPromises(); }); @@ -336,7 +345,7 @@ describe('IssuesListApp component', () => { describe('when "Open" tab has no issues', () => { beforeEach(async () => { - wrapper = mountComponent({ provide: { hasIssues: true }, mountFn: mount }); + wrapper = mountComponent({ provide: { hasProjectIssues: true }, mountFn: mount }); await waitForPromises(); }); @@ -356,7 +365,7 @@ describe('IssuesListApp component', () => { url: setUrlParams({ state: IssuableStates.Closed }, TEST_HOST), }); - wrapper = mountComponent({ provide: { hasIssues: true }, mountFn: mount }); + wrapper = mountComponent({ provide: { hasProjectIssues: true }, mountFn: mount }); await waitForPromises(); }); @@ -374,7 +383,7 @@ describe('IssuesListApp component', () => { describe('when user is logged in', () => { beforeEach(() => { wrapper = mountComponent({ - provide: { hasIssues: false, isSignedIn: true }, + provide: { hasProjectIssues: false, isSignedIn: true }, mountFn: mount, }); }); @@ -413,7 +422,7 @@ describe('IssuesListApp component', () => { describe('when user is logged out', () => { beforeEach(() => { wrapper = mountComponent({ - provide: { hasIssues: false, isSignedIn: false }, + provide: { hasProjectIssues: false, isSignedIn: false }, }); }); @@ -430,6 +439,119 @@ describe('IssuesListApp component', () => { }); }); + describe('tokens', () => { + const mockCurrentUser = { + id: 1, + name: 'Administrator', + username: 'root', + avatar_url: 'avatar/url', + }; + + describe('when user is signed out', () => { + beforeEach(() => { + wrapper = mountComponent({ + provide: { + isSignedIn: false, + }, + }); + }); + + it('does not render My-Reaction or Confidential tokens', () => { + expect(findIssuableList().props('searchTokens')).not.toMatchObject([ + { type: TOKEN_TYPE_AUTHOR, preloadedAuthors: [mockCurrentUser] }, + { type: TOKEN_TYPE_ASSIGNEE, preloadedAuthors: [mockCurrentUser] }, + { type: TOKEN_TYPE_MY_REACTION }, + { type: TOKEN_TYPE_CONFIDENTIAL }, + ]); + }); + }); + + describe('when iterations are not available', () => { + beforeEach(() => { + wrapper = mountComponent({ + provide: { + projectIterationsPath: '', + }, + }); + }); + + it('does not render Iteration token', () => { + expect(findIssuableList().props('searchTokens')).not.toMatchObject([ + { type: TOKEN_TYPE_ITERATION }, + ]); + }); + }); + + describe('when epics are not available', () => { + beforeEach(() => { + wrapper = mountComponent({ + provide: { + groupEpicsPath: '', + }, + }); + }); + + it('does not render Epic token', () => { + expect(findIssuableList().props('searchTokens')).not.toMatchObject([ + { type: TOKEN_TYPE_EPIC }, + ]); + }); + }); + + describe('when weights are not available', () => { + beforeEach(() => { + wrapper = mountComponent({ + provide: { + groupEpicsPath: '', + }, + }); + }); + + it('does not render Weight token', () => { + expect(findIssuableList().props('searchTokens')).not.toMatchObject([ + { type: TOKEN_TYPE_WEIGHT }, + ]); + }); + }); + + describe('when all tokens are available', () => { + const originalGon = window.gon; + + beforeEach(() => { + window.gon = { + ...originalGon, + current_user_id: mockCurrentUser.id, + current_user_fullname: mockCurrentUser.name, + current_username: mockCurrentUser.username, + current_user_avatar_url: mockCurrentUser.avatar_url, + }; + + wrapper = mountComponent({ + provide: { + isSignedIn: true, + projectIterationsPath: 'project/iterations/path', + groupEpicsPath: 'group/epics/path', + hasIssueWeightsFeature: true, + }, + }); + }); + + it('renders all tokens', () => { + expect(findIssuableList().props('searchTokens')).toMatchObject([ + { type: TOKEN_TYPE_AUTHOR, preloadedAuthors: [mockCurrentUser] }, + { type: TOKEN_TYPE_ASSIGNEE, preloadedAuthors: [mockCurrentUser] }, + { type: TOKEN_TYPE_MILESTONE }, + { type: TOKEN_TYPE_LABEL }, + { type: TOKEN_TYPE_MY_REACTION }, + { type: TOKEN_TYPE_CONFIDENTIAL }, + { type: TOKEN_TYPE_ITERATION }, + { type: TOKEN_TYPE_EPIC }, + { type: TOKEN_TYPE_WEIGHT }, + ]); + }); + }); + }); + describe('events', () => { describe('when "click-tab" event is emitted by IssuableList', () => { beforeEach(() => { |