Commit 7fbf5728 authored by Samantha Ming's avatar Samantha Ming

Add validation feedback for visibility level

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/327835
parent eeb453fe
......@@ -113,7 +113,6 @@ export default {
}),
visibility: initFormField({
value: this.projectVisibility,
skipValidation: true,
}),
},
};
......@@ -322,7 +321,11 @@ export default {
/>
</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>
{{ s__('ForkProject|Visibility level') }}
<gl-link :href="visibilityHelpPath" target="_blank">
......
......@@ -14294,6 +14294,9 @@ msgstr ""
msgid "ForkProject|Please select a namespace"
msgstr ""
msgid "ForkProject|Please select a visibility level"
msgstr ""
msgid "ForkProject|Private"
msgstr ""
......
......@@ -235,7 +235,7 @@ describe('ForkForm component', () => {
});
describe('onSubmit', () => {
beforeEach(() => {
const setupComponent = (fields = {}) => {
jest.spyOn(urlUtility, 'redirectTo').mockImplementation();
mockGetRequest();
......@@ -245,9 +245,14 @@ describe('ForkForm component', () => {
namespaces: MOCK_NAMESPACES_RESPONSE,
form: {
state: true,
...fields,
},
},
);
};
beforeEach(() => {
setupComponent();
});
const selectedMockNamespaceIndex = 1;
......@@ -279,6 +284,23 @@ describe('ForkForm component', () => {
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', () => {
......
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