diff options
Diffstat (limited to 'spec/frontend/organizations/shared/components')
-rw-r--r-- | spec/frontend/organizations/shared/components/new_edit_form_spec.js | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/spec/frontend/organizations/shared/components/new_edit_form_spec.js b/spec/frontend/organizations/shared/components/new_edit_form_spec.js index 4897a81fc1c..5be26ef7cc3 100644 --- a/spec/frontend/organizations/shared/components/new_edit_form_spec.js +++ b/spec/frontend/organizations/shared/components/new_edit_form_spec.js @@ -1,9 +1,10 @@ -import { GlButton } from '@gitlab/ui'; import { nextTick } from 'vue'; import NewEditForm from '~/organizations/shared/components/new_edit_form.vue'; import OrganizationUrlField from '~/organizations/shared/components/organization_url_field.vue'; import AvatarUploadDropzone from '~/vue_shared/components/upload_dropzone/avatar_upload_dropzone.vue'; +import MarkdownField from '~/vue_shared/components/markdown/field.vue'; +import { helpPagePath } from '~/helpers/help_page_helper'; import { FORM_FIELD_NAME, FORM_FIELD_ID, @@ -18,6 +19,7 @@ describe('NewEditForm', () => { const defaultProvide = { organizationsPath: '/-/organizations', rootUrl: 'http://127.0.0.1:3000/', + previewMarkdownPath: '/-/organizations/preview_markdown', }; const defaultPropsData = { @@ -38,6 +40,7 @@ describe('NewEditForm', () => { const findNameField = () => wrapper.findByLabelText('Organization name'); const findIdField = () => wrapper.findByLabelText('Organization ID'); const findUrlField = () => wrapper.findComponent(OrganizationUrlField); + const findDescriptionField = () => wrapper.findByLabelText('Organization description (optional)'); const findAvatarField = () => wrapper.findComponent(AvatarUploadDropzone); const setUrlFieldValue = async (value) => { @@ -70,6 +73,30 @@ describe('NewEditForm', () => { }); }); + it('renders `Organization description` field as markdown editor', () => { + createComponent(); + + expect(findDescriptionField().exists()).toBe(true); + expect(wrapper.findComponent(MarkdownField).props()).toMatchObject({ + markdownPreviewPath: defaultProvide.previewMarkdownPath, + markdownDocsPath: helpPagePath('user/organization/index', { + anchor: 'organization-description-supported-markdown', + }), + textareaValue: '', + restrictedToolBarItems: [ + 'code', + 'quote', + 'bullet-list', + 'numbered-list', + 'task-list', + 'collapsible-section', + 'table', + 'attach-file', + 'full-screen', + ], + }); + }); + describe('when `Organization avatar` field is changed', () => { const file = new File(['foo'], 'foo.jpg', { type: 'text/plain', @@ -154,12 +181,13 @@ describe('NewEditForm', () => { await findNameField().setValue('Foo bar'); await setUrlFieldValue('foo-bar'); + await findDescriptionField().setValue('Foo bar description'); await submitForm(); }); it('emits `submit` event with form values', () => { expect(wrapper.emitted('submit')).toEqual([ - [{ name: 'Foo bar', path: 'foo-bar', avatar: null }], + [{ name: 'Foo bar', path: 'foo-bar', description: 'Foo bar description', avatar: null }], ]); }); }); @@ -221,7 +249,7 @@ describe('NewEditForm', () => { }); it('shows button with loading icon', () => { - expect(wrapper.findComponent(GlButton).props('loading')).toBe(true); + expect(wrapper.findByTestId('submit-button').props('loading')).toBe(true); }); }); |