diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-27 15:10:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-27 15:10:16 +0300 |
commit | af3904f9d0c9abab61f96f63d0c889f54e31fabd (patch) | |
tree | 3e37e9766bf290c0e65aa7c9628f0ec247427f26 /spec/frontend/releases | |
parent | 1b9f574b89cb80cdd5af8cba3ad3e7995a4af47d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/releases')
4 files changed, 67 insertions, 1 deletions
diff --git a/spec/frontend/releases/components/tag_field_new_spec.js b/spec/frontend/releases/components/tag_field_new_spec.js index b8047cae8c2..fcba0da3462 100644 --- a/spec/frontend/releases/components/tag_field_new_spec.js +++ b/spec/frontend/releases/components/tag_field_new_spec.js @@ -1,14 +1,17 @@ -import { GlDropdownItem } from '@gitlab/ui'; +import { GlDropdownItem, GlFormGroup, GlSprintf } 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 { trimText } from 'helpers/text_helper'; +import { mountExtended } from 'helpers/vue_test_utils_helper'; import { __ } from '~/locale'; import TagFieldNew from '~/releases/components/tag_field_new.vue'; import createStore from '~/releases/stores'; import createEditNewModule from '~/releases/stores/modules/edit_new'; const TEST_TAG_NAME = 'test-tag-name'; +const TEST_TAG_MESSAGE = 'Test tag message'; const TEST_PROJECT_ID = '1234'; const TEST_CREATE_FROM = 'test-create-from'; const NONEXISTENT_TAG_NAME = 'nonexistent-tag'; @@ -47,6 +50,8 @@ describe('releases/components/tag_field_new', () => { store, stubs: { RefSelector: RefSelectorStub, + GlFormGroup, + GlSprintf, }, }); }; @@ -61,9 +66,11 @@ describe('releases/components/tag_field_new', () => { }); store.state.editNew.createFrom = TEST_CREATE_FROM; + store.state.editNew.showCreateFrom = true; store.state.editNew.release = { tagName: TEST_TAG_NAME, + tagMessage: '', assets: { links: [], }, @@ -86,6 +93,9 @@ describe('releases/components/tag_field_new', () => { const findCreateNewTagOption = () => wrapper.findComponent(GlDropdownItem); + const findAnnotatedTagMessageFormGroup = () => + wrapper.find('[data-testid="annotated-tag-message-field"]'); + describe('"Tag name" field', () => { describe('rendering and behavior', () => { beforeEach(() => createComponent()); @@ -124,6 +134,10 @@ describe('releases/components/tag_field_new', () => { expect(findCreateFromFormGroup().exists()).toBe(false); }); + it('hides the "Tag message" field', () => { + expect(findAnnotatedTagMessageFormGroup().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 })); @@ -230,4 +244,34 @@ describe('releases/components/tag_field_new', () => { }); }); }); + + describe('"Annotated Tag" field', () => { + beforeEach(() => { + createComponent(mountExtended); + }); + + it('renders a label', () => { + expect(wrapper.findByRole('textbox', { name: 'Set tag message' }).exists()).toBe(true); + }); + + it('renders a description', () => { + expect(trimText(findAnnotatedTagMessageFormGroup().text())).toContain( + 'Add a message to the tag. Leaving this blank creates a lightweight tag.', + ); + }); + + it('updates the store', async () => { + await findAnnotatedTagMessageFormGroup().find('textarea').setValue(TEST_TAG_MESSAGE); + + expect(store.state.editNew.release.tagMessage).toBe(TEST_TAG_MESSAGE); + }); + + it('shows a link', () => { + const link = wrapper.findByRole('link', { + name: 'lightweight tag', + }); + + expect(link.attributes('href')).toBe('https://git-scm.com/book/en/v2/Git-Basics-Tagging/'); + }); + }); }); diff --git a/spec/frontend/releases/stores/modules/detail/actions_spec.js b/spec/frontend/releases/stores/modules/detail/actions_spec.js index 48fba3adb24..67a07e82532 100644 --- a/spec/frontend/releases/stores/modules/detail/actions_spec.js +++ b/spec/frontend/releases/stores/modules/detail/actions_spec.js @@ -169,6 +169,15 @@ describe('Release edit/new actions', () => { }); }); + describe('updateReleaseTagMessage', () => { + it(`commits ${types.UPDATE_RELEASE_TAG_MESSAGE} with the updated tag name`, () => { + const newMessage = 'updated-tag-message'; + return testAction(actions.updateReleaseTagMessage, newMessage, state, [ + { type: types.UPDATE_RELEASE_TAG_MESSAGE, payload: newMessage }, + ]); + }); + }); + describe('updateReleasedAt', () => { it(`commits ${types.UPDATE_RELEASED_AT} with the updated date`, () => { const newDate = new Date(); diff --git a/spec/frontend/releases/stores/modules/detail/getters_spec.js b/spec/frontend/releases/stores/modules/detail/getters_spec.js index 2982dc5c46c..2e0f9eca285 100644 --- a/spec/frontend/releases/stores/modules/detail/getters_spec.js +++ b/spec/frontend/releases/stores/modules/detail/getters_spec.js @@ -332,6 +332,7 @@ describe('Release edit/new getters', () => { it('returns all the data needed for the releaseCreate GraphQL query', () => { const state = { createFrom: 'main', + release: { tagMessage: 'hello' }, }; const otherGetters = { @@ -352,6 +353,7 @@ describe('Release edit/new getters', () => { const expectedVariables = { input: { name: 'release.name', + tagMessage: 'hello', ref: 'main', assets: { links: [ diff --git a/spec/frontend/releases/stores/modules/detail/mutations_spec.js b/spec/frontend/releases/stores/modules/detail/mutations_spec.js index 8bbf550b77d..944769d22cc 100644 --- a/spec/frontend/releases/stores/modules/detail/mutations_spec.js +++ b/spec/frontend/releases/stores/modules/detail/mutations_spec.js @@ -26,6 +26,7 @@ describe('Release edit/new mutations', () => { expect(state.release).toEqual({ tagName: 'v1.3', + tagMessage: '', name: '', description: '', milestones: [], @@ -90,6 +91,16 @@ describe('Release edit/new mutations', () => { }); }); + describe(`${types.UPDATE_RELEASE_TAG_MESSAGE}`, () => { + it("updates the release's tag message", () => { + state.release = release; + const newMessage = 'updated-tag-message'; + mutations[types.UPDATE_RELEASE_TAG_MESSAGE](state, newMessage); + + expect(state.release.tagMessage).toBe(newMessage); + }); + }); + describe(`${types.UPDATE_RELEASED_AT}`, () => { it("updates the release's released at date", () => { state.release = release; |