diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-30 18:09:38 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-30 18:09:38 +0000 |
commit | 028bb5dda7abc9ec76f21ae8e691825b4673f733 (patch) | |
tree | a41741811452f928c6f650451c69fc18e46b62a4 /spec/frontend/registry | |
parent | 7f305b576b51c3503970ef224cf4b31e247a322d (diff) | |
download | gitlab-ce-028bb5dda7abc9ec76f21ae8e691825b4673f733.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/registry')
3 files changed, 54 insertions, 15 deletions
diff --git a/spec/frontend/registry/settings/store/getters_spec.js b/spec/frontend/registry/settings/store/getters_spec.js index 944057ebc9f..b781d09466c 100644 --- a/spec/frontend/registry/settings/store/getters_spec.js +++ b/spec/frontend/registry/settings/store/getters_spec.js @@ -4,9 +4,12 @@ import { formOptions } from '../../shared/mock_data'; describe('Getters registry settings store', () => { const settings = { + enabled: true, cadence: 'foo', keep_n: 'bar', older_than: 'baz', + name_regex: 'name-foo', + name_regex_keep: 'name-keep-bar', }; describe.each` @@ -29,6 +32,17 @@ describe('Getters registry settings store', () => { }); }); + describe('getSettings', () => { + it('returns the content of settings', () => { + const computedGetters = { + getCadence: settings.cadence, + getOlderThan: settings.older_than, + getKeepN: settings.keep_n, + }; + expect(getters.getSettings({ settings }, computedGetters)).toEqual(settings); + }); + }); + describe('getIsEdited', () => { it('returns false when original is equal to settings', () => { const same = { foo: 'bar' }; diff --git a/spec/frontend/registry/shared/components/__snapshots__/expiration_policy_fields_spec.js.snap b/spec/frontend/registry/shared/components/__snapshots__/expiration_policy_fields_spec.js.snap index 6e7bc0491ce..a9034b81d2f 100644 --- a/spec/frontend/registry/shared/components/__snapshots__/expiration_policy_fields_spec.js.snap +++ b/spec/frontend/registry/shared/components/__snapshots__/expiration_policy_fields_spec.js.snap @@ -117,11 +117,11 @@ exports[`Expiration Policy Form renders 1`] = ` <gl-form-group-stub id="expiration-policy-name-matching-group" invalid-feedback="The value of this input should be less than 255 characters" - label="Docker tags with names matching this regex pattern will expire:" label-align="right" label-cols="3" label-for="expiration-policy-name-matching" > + <gl-form-textarea-stub disabled="true" id="expiration-policy-name-matching" @@ -130,5 +130,21 @@ exports[`Expiration Policy Form renders 1`] = ` value="" /> </gl-form-group-stub> + <gl-form-group-stub + id="expiration-policy-keep-name-group" + invalid-feedback="The value of this input should be less than 255 characters" + label-align="right" + label-cols="3" + label-for="expiration-policy-keep-name" + > + + <gl-form-textarea-stub + disabled="true" + id="expiration-policy-keep-name" + placeholder="" + trim="" + value="" + /> + </gl-form-group-stub> </div> `; diff --git a/spec/frontend/registry/shared/components/expiration_policy_fields_spec.js b/spec/frontend/registry/shared/components/expiration_policy_fields_spec.js index 3782bfeaac4..4825351a6d3 100644 --- a/spec/frontend/registry/shared/components/expiration_policy_fields_spec.js +++ b/spec/frontend/registry/shared/components/expiration_policy_fields_spec.js @@ -40,12 +40,13 @@ describe('Expiration Policy Form', () => { }); describe.each` - elementName | modelName | value | disabledByToggle - ${'toggle'} | ${'enabled'} | ${true} | ${'not disabled'} - ${'interval'} | ${'older_than'} | ${'foo'} | ${'disabled'} - ${'schedule'} | ${'cadence'} | ${'foo'} | ${'disabled'} - ${'latest'} | ${'keep_n'} | ${'foo'} | ${'disabled'} - ${'name-matching'} | ${'name_regex'} | ${'foo'} | ${'disabled'} + elementName | modelName | value | disabledByToggle + ${'toggle'} | ${'enabled'} | ${true} | ${'not disabled'} + ${'interval'} | ${'older_than'} | ${'foo'} | ${'disabled'} + ${'schedule'} | ${'cadence'} | ${'foo'} | ${'disabled'} + ${'latest'} | ${'keep_n'} | ${'foo'} | ${'disabled'} + ${'name-matching'} | ${'name_regex'} | ${'foo'} | ${'disabled'} + ${'keep-name'} | ${'name_regex_keep'} | ${'bar'} | ${'disabled'} `( `${FORM_ELEMENTS_ID_PREFIX}-$elementName form element`, ({ elementName, modelName, value, disabledByToggle }) => { @@ -118,21 +119,26 @@ describe('Expiration Policy Form', () => { ${'schedule'} ${'latest'} ${'name-matching'} + ${'keep-name'} `(`${FORM_ELEMENTS_ID_PREFIX}-$elementName is disabled`, ({ elementName }) => { expect(findFormElements(elementName).attributes('disabled')).toBe('true'); }); }); - describe('form validation', () => { + describe.each` + modelName | elementName | stateVariable + ${'name_regex'} | ${'name-matching'} | ${'nameRegexState'} + ${'name_regex_keep'} | ${'keep-name'} | ${'nameKeepRegexState'} + `('regex textarea validation', ({ modelName, elementName, stateVariable }) => { describe(`when name regex is longer than ${NAME_REGEX_LENGTH}`, () => { const invalidString = new Array(NAME_REGEX_LENGTH + 2).join(','); beforeEach(() => { - mountComponent({ value: { name_regex: invalidString } }); + mountComponent({ value: { [modelName]: invalidString } }); }); - it('nameRegexState is false', () => { - expect(wrapper.vm.nameRegexState).toBe(false); + it(`${stateVariable} is false`, () => { + expect(wrapper.vm.textAreaState[stateVariable]).toBe(false); }); it('emit the @invalidated event', () => { @@ -141,17 +147,20 @@ describe('Expiration Policy Form', () => { }); it('if the user did not type validation is null', () => { - mountComponent({ value: { name_regex: '' } }); + mountComponent({ value: { [modelName]: '' } }); return wrapper.vm.$nextTick().then(() => { - expect(wrapper.vm.nameRegexState).toBe(null); + expect(wrapper.vm.textAreaState[stateVariable]).toBe(null); expect(wrapper.emitted('validated')).toBeTruthy(); }); }); it(`if the user typed and is less than ${NAME_REGEX_LENGTH} state is true`, () => { - mountComponent({ value: { name_regex: 'foo' } }); + mountComponent({ value: { [modelName]: 'foo' } }); return wrapper.vm.$nextTick().then(() => { - expect(wrapper.vm.nameRegexState).toBe(true); + const formGroup = findFormGroup(elementName); + const formElement = findFormElements(elementName, formGroup); + expect(formGroup.attributes('state')).toBeTruthy(); + expect(formElement.attributes('state')).toBeTruthy(); }); }); }); |