diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/frontend/integrations/edit/components/trigger_fields_spec.js | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/frontend/integrations/edit/components/trigger_fields_spec.js')
-rw-r--r-- | spec/frontend/integrations/edit/components/trigger_fields_spec.js | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/spec/frontend/integrations/edit/components/trigger_fields_spec.js b/spec/frontend/integrations/edit/components/trigger_fields_spec.js index 337876c6d16..41bccb8ada0 100644 --- a/spec/frontend/integrations/edit/components/trigger_fields_spec.js +++ b/spec/frontend/integrations/edit/components/trigger_fields_spec.js @@ -9,9 +9,12 @@ describe('TriggerFields', () => { type: 'slack', }; - const createComponent = props => { + const createComponent = (props, isInheriting = false) => { wrapper = mount(TriggerFields, { propsData: { ...defaultProps, ...props }, + computed: { + isInheriting: () => isInheriting, + }, }); }; @@ -22,10 +25,11 @@ describe('TriggerFields', () => { } }); + const findAllGlFormGroups = () => wrapper.find('#trigger-fields').findAll(GlFormGroup); const findAllGlFormCheckboxes = () => wrapper.findAll(GlFormCheckbox); const findAllGlFormInputs = () => wrapper.findAll(GlFormInput); - describe('template', () => { + describe.each([true, false])('template, isInheriting = `%p`', isInheriting => { it('renders a label with text "Trigger"', () => { createComponent(); @@ -51,9 +55,12 @@ describe('TriggerFields', () => { ]; beforeEach(() => { - createComponent({ - events, - }); + createComponent( + { + events, + }, + isInheriting, + ); }); it('does not render GlFormInput for each event', () => { @@ -69,8 +76,10 @@ describe('TriggerFields', () => { }); }); - it('renders GlFormCheckbox for each event', () => { - const checkboxes = findAllGlFormCheckboxes(); + it(`renders GlFormCheckbox and corresponding hidden input for each event, which ${ + isInheriting ? 'is' : 'is not' + } disabled`, () => { + const checkboxes = findAllGlFormGroups(); const expectedResults = [ { labelText: 'Push', inputName: 'service[push_event]' }, { labelText: 'Merge Request', inputName: 'service[merge_requests_event]' }, @@ -78,14 +87,22 @@ describe('TriggerFields', () => { expect(checkboxes).toHaveLength(2); checkboxes.wrappers.forEach((checkbox, index) => { + const checkBox = checkbox.find(GlFormCheckbox); + expect(checkbox.find('label').text()).toBe(expectedResults[index].labelText); - expect(checkbox.find('input').attributes('name')).toBe(expectedResults[index].inputName); - expect(checkbox.vm.$attrs.checked).toBe(events[index].value); + expect(checkbox.find('[type=hidden]').attributes('name')).toBe( + expectedResults[index].inputName, + ); + expect(checkbox.find('[type=hidden]').attributes('value')).toBe( + events[index].value.toString(), + ); + expect(checkBox.vm.$attrs.disabled).toBe(isInheriting); + expect(checkBox.vm.$attrs.checked).toBe(events[index].value); }); }); }); - describe('events with field property', () => { + describe('events with field property, isInheriting = `%p`', () => { const events = [ { field: { @@ -102,16 +119,21 @@ describe('TriggerFields', () => { ]; beforeEach(() => { - createComponent({ - events, - }); + createComponent( + { + events, + }, + isInheriting, + ); }); it('renders GlFormCheckbox for each event', () => { expect(findAllGlFormCheckboxes()).toHaveLength(2); }); - it('renders GlFormInput for each event', () => { + it(`renders GlFormInput for each event, which ${ + isInheriting ? 'is' : 'is not' + } readonly`, () => { const fields = findAllGlFormInputs(); const expectedResults = [ { @@ -128,6 +150,7 @@ describe('TriggerFields', () => { fields.wrappers.forEach((field, index) => { expect(field.attributes()).toMatchObject(expectedResults[index]); + expect(field.vm.$attrs.readonly).toBe(isInheriting); expect(field.vm.$attrs.value).toBe(events[index].field.value); }); }); |