diff options
Diffstat (limited to 'spec/frontend/issue_show/components/fields')
-rw-r--r-- | spec/frontend/issue_show/components/fields/type_spec.js | 26 |
1 files changed, 25 insertions, 1 deletions
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); + }); + }); }); }); |