diff options
Diffstat (limited to 'spec/frontend/registry/shared')
-rw-r--r-- | spec/frontend/registry/shared/components/__snapshots__/expiration_policy_fields_spec.js.snap | 18 | ||||
-rw-r--r-- | spec/frontend/registry/shared/components/expiration_policy_fields_spec.js | 37 |
2 files changed, 40 insertions, 15 deletions
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(); }); }); }); |