Commit 23551042 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch '327835-display-validation-for-radio-visibility' into 'master'

Add validation feedback for visibility level

See merge request gitlab-org/gitlab!62300
parents 2951fb8c 7fbf5728
...@@ -113,7 +113,6 @@ export default { ...@@ -113,7 +113,6 @@ export default {
}), }),
visibility: initFormField({ visibility: initFormField({
value: this.projectVisibility, value: this.projectVisibility,
skipValidation: true,
}), }),
}, },
}; };
...@@ -326,7 +325,11 @@ export default { ...@@ -326,7 +325,11 @@ export default {
/> />
</gl-form-group> </gl-form-group>
<gl-form-group> <gl-form-group
v-validation:[form.showValidation]
:invalid-feedback="s__('ForkProject|Please select a visibility level')"
:state="form.fields.visibility.state"
>
<label> <label>
{{ s__('ForkProject|Visibility level') }} {{ s__('ForkProject|Visibility level') }}
<gl-link :href="visibilityHelpPath" target="_blank"> <gl-link :href="visibilityHelpPath" target="_blank">
......
...@@ -14341,6 +14341,9 @@ msgstr "" ...@@ -14341,6 +14341,9 @@ msgstr ""
msgid "ForkProject|Please select a namespace" msgid "ForkProject|Please select a namespace"
msgstr "" msgstr ""
msgid "ForkProject|Please select a visibility level"
msgstr ""
msgid "ForkProject|Private" msgid "ForkProject|Private"
msgstr "" msgstr ""
......
...@@ -261,7 +261,7 @@ describe('ForkForm component', () => { ...@@ -261,7 +261,7 @@ describe('ForkForm component', () => {
}); });
describe('onSubmit', () => { describe('onSubmit', () => {
beforeEach(() => { const setupComponent = (fields = {}) => {
jest.spyOn(urlUtility, 'redirectTo').mockImplementation(); jest.spyOn(urlUtility, 'redirectTo').mockImplementation();
mockGetRequest(); mockGetRequest();
...@@ -271,9 +271,14 @@ describe('ForkForm component', () => { ...@@ -271,9 +271,14 @@ describe('ForkForm component', () => {
namespaces: MOCK_NAMESPACES_RESPONSE, namespaces: MOCK_NAMESPACES_RESPONSE,
form: { form: {
state: true, state: true,
...fields,
}, },
}, },
); );
};
beforeEach(() => {
setupComponent();
}); });
const selectedMockNamespaceIndex = 1; const selectedMockNamespaceIndex = 1;
...@@ -305,6 +310,23 @@ describe('ForkForm component', () => { ...@@ -305,6 +310,23 @@ describe('ForkForm component', () => {
expect(urlUtility.redirectTo).not.toHaveBeenCalled(); expect(urlUtility.redirectTo).not.toHaveBeenCalled();
}); });
it('does not make POST request if no visbility is checked', async () => {
jest.spyOn(axios, 'post');
setupComponent({
fields: {
visibility: {
value: null,
},
},
});
await submitForm();
expect(wrapper.find('[name="visibility"]:checked').exists()).toBe(false);
expect(axios.post).not.toHaveBeenCalled();
});
}); });
describe('with valid form', () => { describe('with valid form', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment