diff options
Diffstat (limited to 'spec/frontend/releases/components')
-rw-r--r-- | spec/frontend/releases/components/app_edit_new_spec.js | 12 | ||||
-rw-r--r-- | spec/frontend/releases/components/tag_field_new_spec.js | 28 |
2 files changed, 38 insertions, 2 deletions
diff --git a/spec/frontend/releases/components/app_edit_new_spec.js b/spec/frontend/releases/components/app_edit_new_spec.js index 0a0a683b56d..80be27c92ff 100644 --- a/spec/frontend/releases/components/app_edit_new_spec.js +++ b/spec/frontend/releases/components/app_edit_new_spec.js @@ -4,6 +4,7 @@ import MockAdapter from 'axios-mock-adapter'; import { merge } from 'lodash'; import Vuex from 'vuex'; import { nextTick } from 'vue'; +import { GlFormCheckbox } from '@gitlab/ui'; import originalRelease from 'test_fixtures/api/releases/release.json'; import setWindowLocation from 'helpers/set_window_location_helper'; import { TEST_HOST } from 'helpers/test_constants'; @@ -11,6 +12,7 @@ import * as commonUtils from '~/lib/utils/common_utils'; import ReleaseEditNewApp from '~/releases/components/app_edit_new.vue'; import AssetLinksForm from '~/releases/components/asset_links_form.vue'; import { BACK_URL_PARAM } from '~/releases/constants'; +import MarkdownField from '~/vue_shared/components/markdown/field.vue'; const originalMilestones = originalRelease.milestones; const releasesPagePath = 'path/to/releases/page'; @@ -47,6 +49,7 @@ describe('Release edit/new component', () => { links: [], }, }), + formattedReleaseNotes: () => 'these notes are formatted', }; const store = new Vuex.Store( @@ -129,6 +132,11 @@ describe('Release edit/new component', () => { expect(wrapper.find('#release-notes').element.value).toBe(release.description); }); + it('sets the preview text to be the formatted release notes', () => { + const notes = getters.formattedReleaseNotes(); + expect(wrapper.findComponent(MarkdownField).props('textareaValue')).toBe(notes); + }); + it('renders the "Save changes" button as type="submit"', () => { expect(findSubmitButton().attributes('type')).toBe('submit'); }); @@ -195,6 +203,10 @@ describe('Release edit/new component', () => { it('renders the submit button with the text "Create release"', () => { expect(findSubmitButton().text()).toBe('Create release'); }); + + it('renders a checkbox to include release notes', () => { + expect(wrapper.find(GlFormCheckbox).exists()).toBe(true); + }); }); describe('when editing an existing release', () => { diff --git a/spec/frontend/releases/components/tag_field_new_spec.js b/spec/frontend/releases/components/tag_field_new_spec.js index c13b513f87e..9f500c318ea 100644 --- a/spec/frontend/releases/components/tag_field_new_spec.js +++ b/spec/frontend/releases/components/tag_field_new_spec.js @@ -1,5 +1,7 @@ import { GlDropdownItem } from '@gitlab/ui'; import { mount, shallowMount } from '@vue/test-utils'; +import axios from 'axios'; +import MockAdapter from 'axios-mock-adapter'; import Vue, { nextTick } from 'vue'; import { __ } from '~/locale'; import TagFieldNew from '~/releases/components/tag_field_new.vue'; @@ -14,6 +16,7 @@ const NONEXISTENT_TAG_NAME = 'nonexistent-tag'; describe('releases/components/tag_field_new', () => { let store; let wrapper; + let mock; let RefSelectorStub; const createComponent = ( @@ -65,11 +68,14 @@ describe('releases/components/tag_field_new', () => { links: [], }, }; + + mock = new MockAdapter(axios); + gon.api_version = 'v4'; }); afterEach(() => { wrapper.destroy(); - wrapper = null; + mock.restore(); }); const findTagNameFormGroup = () => wrapper.find('[data-testid="tag-name-field"]'); @@ -114,9 +120,14 @@ describe('releases/components/tag_field_new', () => { expect(store.state.editNew.release.tagName).toBe(updatedTagName); }); - it('shows the "Create from" field', () => { + it('hides the "Create from" field', () => { expect(findCreateFromFormGroup().exists()).toBe(false); }); + + it('fetches the release notes for the tag', () => { + const expectedUrl = `/api/v4/projects/1234/repository/tags/${updatedTagName}`; + expect(mock.history.get).toContainEqual(expect.objectContaining({ url: expectedUrl })); + }); }); }); @@ -177,6 +188,18 @@ describe('releases/components/tag_field_new', () => { await expectValidationMessageToBe('hidden'); }); + + it('displays a validation error if the tag has an associated release', async () => { + findTagNameDropdown().vm.$emit('input', 'vTest'); + findTagNameDropdown().vm.$emit('hide'); + + store.state.editNew.existingRelease = {}; + + await expectValidationMessageToBe('shown'); + expect(findTagNameFormGroup().text()).toContain( + __('Selected tag is already in use. Choose another option.'), + ); + }); }); describe('when the user has interacted with the component and the value is empty', () => { @@ -185,6 +208,7 @@ describe('releases/components/tag_field_new', () => { findTagNameDropdown().vm.$emit('hide'); await expectValidationMessageToBe('shown'); + expect(findTagNameFormGroup().text()).toContain(__('Tag name is required.')); }); }); }); |