diff options
Diffstat (limited to 'spec/frontend/issue_show/components')
-rw-r--r-- | spec/frontend/issue_show/components/app_spec.js | 38 | ||||
-rw-r--r-- | spec/frontend/issue_show/components/description_spec.js | 22 | ||||
-rw-r--r-- | spec/frontend/issue_show/components/fields/type_spec.js | 26 |
3 files changed, 84 insertions, 2 deletions
diff --git a/spec/frontend/issue_show/components/app_spec.js b/spec/frontend/issue_show/components/app_spec.js index bd05cb1ac5a..e32215b4aa6 100644 --- a/spec/frontend/issue_show/components/app_spec.js +++ b/spec/frontend/issue_show/components/app_spec.js @@ -8,7 +8,7 @@ import IssuableApp from '~/issue_show/components/app.vue'; import DescriptionComponent from '~/issue_show/components/description.vue'; import IncidentTabs from '~/issue_show/components/incidents/incident_tabs.vue'; import PinnedLinks from '~/issue_show/components/pinned_links.vue'; -import { IssuableStatus, IssuableStatusText } from '~/issue_show/constants'; +import { IssuableStatus, IssuableStatusText, POLLING_DELAY } from '~/issue_show/constants'; import eventHub from '~/issue_show/event_hub'; import axios from '~/lib/utils/axios_utils'; import { visitUrl } from '~/lib/utils/url_utility'; @@ -643,4 +643,40 @@ describe('Issuable output', () => { }); }); }); + + describe('taskListUpdateStarted', () => { + it('stops polling', () => { + jest.spyOn(wrapper.vm.poll, 'stop'); + + wrapper.vm.taskListUpdateStarted(); + + expect(wrapper.vm.poll.stop).toHaveBeenCalled(); + }); + }); + + describe('taskListUpdateSucceeded', () => { + it('enables polling', () => { + jest.spyOn(wrapper.vm.poll, 'enable'); + jest.spyOn(wrapper.vm.poll, 'makeDelayedRequest'); + + wrapper.vm.taskListUpdateSucceeded(); + + expect(wrapper.vm.poll.enable).toHaveBeenCalled(); + expect(wrapper.vm.poll.makeDelayedRequest).toHaveBeenCalledWith(POLLING_DELAY); + }); + }); + + describe('taskListUpdateFailed', () => { + it('enables polling and calls updateStoreState', () => { + jest.spyOn(wrapper.vm.poll, 'enable'); + jest.spyOn(wrapper.vm.poll, 'makeDelayedRequest'); + jest.spyOn(wrapper.vm, 'updateStoreState'); + + wrapper.vm.taskListUpdateFailed(); + + expect(wrapper.vm.poll.enable).toHaveBeenCalled(); + expect(wrapper.vm.poll.makeDelayedRequest).toHaveBeenCalledWith(POLLING_DELAY); + expect(wrapper.vm.updateStoreState).toHaveBeenCalled(); + }); + }); }); diff --git a/spec/frontend/issue_show/components/description_spec.js b/spec/frontend/issue_show/components/description_spec.js index cdf06ecc31f..bdcc82cab81 100644 --- a/spec/frontend/issue_show/components/description_spec.js +++ b/spec/frontend/issue_show/components/description_spec.js @@ -114,6 +114,8 @@ describe('Description component', () => { dataType: 'issuableType', fieldName: 'description', selector: '.detail-page-description', + onUpdate: expect.any(Function), + onSuccess: expect.any(Function), onError: expect.any(Function), lockVersion: 0, }); @@ -150,6 +152,26 @@ describe('Description component', () => { }); }); + describe('taskListUpdateStarted', () => { + it('emits event to parent', () => { + const spy = jest.spyOn(vm, '$emit'); + + vm.taskListUpdateStarted(); + + expect(spy).toHaveBeenCalledWith('taskListUpdateStarted'); + }); + }); + + describe('taskListUpdateSuccess', () => { + it('emits event to parent', () => { + const spy = jest.spyOn(vm, '$emit'); + + vm.taskListUpdateSuccess(); + + expect(spy).toHaveBeenCalledWith('taskListUpdateSucceeded'); + }); + }); + describe('taskListUpdateError', () => { it('should create flash notification and emit an event to parent', () => { const msg = diff --git a/spec/frontend/issue_show/components/fields/type_spec.js b/spec/frontend/issue_show/components/fields/type_spec.js index fac745716d7..95ae6f37877 100644 --- a/spec/frontend/issue_show/components/fields/type_spec.js +++ b/spec/frontend/issue_show/components/fields/type_spec.js @@ -39,7 +39,7 @@ describe('Issue type field component', () => { const findTypeFromDropDownItemIconAt = (at) => findTypeFromDropDownItems().at(at).findComponent(GlIcon); - const createComponent = ({ data } = {}) => { + const createComponent = ({ data } = {}, provide) => { fakeApollo = createMockApollo([], mockResolvers); wrapper = shallowMount(IssueTypeField, { @@ -51,6 +51,10 @@ describe('Issue type field component', () => { ...data, }; }, + provide: { + canCreateIncident: true, + ...provide, + }, }); }; @@ -92,5 +96,25 @@ describe('Issue type field component', () => { await wrapper.vm.$nextTick(); expect(findTypeFromDropDown().attributes('value')).toBe(IssuableTypes.incident); }); + + describe('when user is a guest', () => { + it('hides the incident type from the dropdown', async () => { + createComponent({}, { canCreateIncident: false, issueType: 'issue' }); + await waitForPromises(); + + expect(findTypeFromDropDownItemAt(0).isVisible()).toBe(true); + expect(findTypeFromDropDownItemAt(1).isVisible()).toBe(false); + expect(findTypeFromDropDown().attributes('value')).toBe(IssuableTypes.issue); + }); + + it('and incident is selected, includes incident in the dropdown', async () => { + createComponent({}, { canCreateIncident: false, issueType: 'incident' }); + await waitForPromises(); + + expect(findTypeFromDropDownItemAt(0).isVisible()).toBe(true); + expect(findTypeFromDropDownItemAt(1).isVisible()).toBe(true); + expect(findTypeFromDropDown().attributes('value')).toBe(IssuableTypes.incident); + }); + }); }); }); |