diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
commit | 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch) | |
tree | 6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /spec/frontend/releases/components | |
parent | a7253423e3403b8c08f8a161e5937e1488f5f407 (diff) |
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'spec/frontend/releases/components')
6 files changed, 45 insertions, 75 deletions
diff --git a/spec/frontend/releases/components/app_edit_new_spec.js b/spec/frontend/releases/components/app_edit_new_spec.js index 649d8eef6ec..bd61e4537f9 100644 --- a/spec/frontend/releases/components/app_edit_new_spec.js +++ b/spec/frontend/releases/components/app_edit_new_spec.js @@ -5,11 +5,13 @@ import Vuex from 'vuex'; import { nextTick } from 'vue'; import { GlDatepicker, GlFormCheckbox } from '@gitlab/ui'; import originalOneReleaseForEditingQueryResponse from 'test_fixtures/graphql/releases/graphql/queries/one_release_for_editing.query.graphql.json'; +import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; import { convertOneReleaseGraphQLResponse } from '~/releases/util'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import setWindowLocation from 'helpers/set_window_location_helper'; import { TEST_HOST } from 'helpers/test_constants'; import ReleaseEditNewApp from '~/releases/components/app_edit_new.vue'; +import { putCreateReleaseNotification } from '~/releases/release_notification_service'; import AssetLinksForm from '~/releases/components/asset_links_form.vue'; import ConfirmDeleteModal from '~/releases/components/confirm_delete_modal.vue'; import { BACK_URL_PARAM } from '~/releases/constants'; @@ -19,6 +21,8 @@ const originalRelease = originalOneReleaseForEditingQueryResponse.data.project.r const originalMilestones = originalRelease.milestones; const releasesPagePath = 'path/to/releases/page'; const upcomingReleaseDocsPath = 'path/to/upcoming/release/docs'; +const projectPath = 'project/path'; +jest.mock('~/releases/release_notification_service'); describe('Release edit/new component', () => { let wrapper; @@ -32,6 +36,7 @@ describe('Release edit/new component', () => { state = { release, isExistingRelease: true, + projectPath, markdownDocsPath: 'path/to/markdown/docs', releasesPagePath, projectId: '8', @@ -91,7 +96,7 @@ describe('Release edit/new component', () => { mock = new MockAdapter(axios); gon.api_version = 'v4'; - mock.onGet('/api/v4/projects/8/milestones').reply(200, originalMilestones); + mock.onGet('/api/v4/projects/8/milestones').reply(HTTP_STATUS_OK, originalMilestones); release = convertOneReleaseGraphQLResponse(originalOneReleaseForEditingQueryResponse).data; }); @@ -125,7 +130,7 @@ describe('Release edit/new component', () => { it('renders the description text at the top of the page', () => { expect(wrapper.find('.js-subtitle-text').text()).toBe( - 'Releases are based on Git tags. We recommend tags that use semantic versioning, for example v1.0.0, v2.1.0-pre.', + 'Releases are based on Git tags. We recommend tags that use semantic versioning, for example 1.0.0, 2.1.0-pre.', ); }); @@ -163,6 +168,13 @@ describe('Release edit/new component', () => { expect(actions.saveRelease).toHaveBeenCalledTimes(1); }); + + it('sets release created notification when the form is submitted', () => { + findForm().trigger('submit'); + const releaseName = originalOneReleaseForEditingQueryResponse.data.project.release.name; + expect(putCreateReleaseNotification).toHaveBeenCalledTimes(1); + expect(putCreateReleaseNotification).toHaveBeenCalledWith(projectPath, releaseName); + }); }); describe(`when the URL does not contain a "${BACK_URL_PARAM}" parameter`, () => { diff --git a/spec/frontend/releases/components/app_index_spec.js b/spec/frontend/releases/components/app_index_spec.js index 48589a54ec4..ef3bd5ca873 100644 --- a/spec/frontend/releases/components/app_index_spec.js +++ b/spec/frontend/releases/components/app_index_spec.js @@ -92,10 +92,6 @@ describe('app_index.vue', () => { queryMock = jest.fn(); }); - afterEach(() => { - wrapper.destroy(); - }); - // Finders const findLoadingIndicator = () => wrapper.findComponent(ReleaseSkeletonLoader); const findEmptyState = () => wrapper.findComponent(ReleasesEmptyState); @@ -179,12 +175,14 @@ describe('app_index.vue', () => { expect(findPagination().exists()).toBe(pagination); }); - it('does render the "New release" button', () => { - expect(findNewReleaseButton().exists()).toBe(true); + it('does render the "New release" button only for non-empty state', () => { + const shouldRenderNewReleaseButton = !emptyState; + expect(findNewReleaseButton().exists()).toBe(shouldRenderNewReleaseButton); }); - it('does render the sort controls', () => { - expect(findSort().exists()).toBe(true); + it('does render the sort controls only for non-empty state', () => { + const shouldRenderControls = !emptyState; + expect(findSort().exists()).toBe(shouldRenderControls); }); }, ); diff --git a/spec/frontend/releases/components/app_show_spec.js b/spec/frontend/releases/components/app_show_spec.js index c5cb8589ee8..efe72e8000a 100644 --- a/spec/frontend/releases/components/app_show_spec.js +++ b/spec/frontend/releases/components/app_show_spec.js @@ -5,12 +5,14 @@ import oneReleaseQueryResponse from 'test_fixtures/graphql/releases/graphql/quer import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { createAlert } from '~/flash'; +import { popCreateReleaseNotification } from '~/releases/release_notification_service'; import ReleaseShowApp from '~/releases/components/app_show.vue'; import ReleaseBlock from '~/releases/components/release_block.vue'; import ReleaseSkeletonLoader from '~/releases/components/release_skeleton_loader.vue'; import oneReleaseQuery from '~/releases/graphql/queries/one_release.query.graphql'; jest.mock('~/flash'); +jest.mock('~/releases/release_notification_service'); Vue.use(VueApollo); @@ -88,6 +90,11 @@ describe('Release show component', () => { createComponent({ apolloProvider }); }); + it('shows info notification on mount', () => { + expect(popCreateReleaseNotification).toHaveBeenCalledTimes(1); + expect(popCreateReleaseNotification).toHaveBeenCalledWith(MOCK_FULL_PATH); + }); + it('builds a GraphQL with the expected variables', () => { expect(queryHandler).toHaveBeenCalledTimes(1); expect(queryHandler).toHaveBeenCalledWith({ diff --git a/spec/frontend/releases/components/evidence_block_spec.js b/spec/frontend/releases/components/evidence_block_spec.js index 6f935215dd7..69443cb7a11 100644 --- a/spec/frontend/releases/components/evidence_block_spec.js +++ b/spec/frontend/releases/components/evidence_block_spec.js @@ -40,13 +40,11 @@ describe('Evidence Block', () => { }); it('renders the correct hover text for the download', () => { - expect(wrapper.findComponent(GlLink).attributes('title')).toBe('Download evidence JSON'); + expect(wrapper.findComponent(GlLink).attributes('title')).toBe('Open evidence JSON in new tab'); }); - it('renders the correct file link for download', () => { - expect(wrapper.findComponent(GlLink).attributes().download).toMatch( - /v1\.1-evidences-[0-9]+\.json/, - ); + it('renders a link that opens in a new tab', () => { + expect(wrapper.findComponent(GlLink).attributes().target).toBe('_blank'); }); describe('sha text', () => { diff --git a/spec/frontend/releases/components/release_block_assets_spec.js b/spec/frontend/releases/components/release_block_assets_spec.js index 4f94e4dfd55..6d53bf5a49e 100644 --- a/spec/frontend/releases/components/release_block_assets_spec.js +++ b/spec/frontend/releases/components/release_block_assets_spec.js @@ -123,42 +123,14 @@ describe('Release block assets', () => { }); }); - describe('external vs internal links', () => { + describe('links', () => { const containsExternalSourceIndicator = () => wrapper.find('[data-testid="external-link-indicator"]').exists(); - describe('when a link is external', () => { - beforeEach(() => { - defaultProps.assets.sources = []; - defaultProps.assets.links = [ - { - ...defaultProps.assets.links[0], - external: true, - }, - ]; - createComponent(defaultProps); - }); - - it('renders the link with an "external source" indicator', () => { - expect(containsExternalSourceIndicator()).toBe(true); - }); - }); + beforeEach(() => createComponent(defaultProps)); - describe('when a link is internal', () => { - beforeEach(() => { - defaultProps.assets.sources = []; - defaultProps.assets.links = [ - { - ...defaultProps.assets.links[0], - external: false, - }, - ]; - createComponent(defaultProps); - }); - - it('renders the link without the "external source" indicator', () => { - expect(containsExternalSourceIndicator()).toBe(false); - }); + it('renders with an external source indicator (except for sections with no title)', () => { + expect(containsExternalSourceIndicator()).toBe(true); }); }); }); diff --git a/spec/frontend/releases/components/releases_empty_state_spec.js b/spec/frontend/releases/components/releases_empty_state_spec.js index 495e6d863f7..f0db7d16bd7 100644 --- a/spec/frontend/releases/components/releases_empty_state_spec.js +++ b/spec/frontend/releases/components/releases_empty_state_spec.js @@ -4,6 +4,7 @@ import ReleasesEmptyState from '~/releases/components/releases_empty_state.vue'; describe('releases_empty_state.vue', () => { const documentationPath = 'path/to/releases/documentation'; + const newReleasePath = 'path/to/releases/new-release'; const illustrationPath = 'path/to/releases/empty/state/illustration'; let wrapper; @@ -12,6 +13,7 @@ describe('releases_empty_state.vue', () => { wrapper = shallowMountExtended(ReleasesEmptyState, { provide: { documentationPath, + newReleasePath, illustrationPath, }, }); @@ -21,36 +23,17 @@ describe('releases_empty_state.vue', () => { createComponent(); }); - afterEach(() => { - wrapper.destroy(); - }); - it('renders a GlEmptyState and provides it with the correct props', () => { const emptyStateProps = wrapper.findComponent(GlEmptyState).props(); - expect(emptyStateProps).toEqual( - expect.objectContaining({ - title: ReleasesEmptyState.i18n.emptyStateTitle, - svgPath: illustrationPath, - }), - ); - }); - - it('renders the empty state text', () => { - expect(wrapper.findByText(ReleasesEmptyState.i18n.emptyStateText).exists()).toBe(true); - }); - - it('renders a link to the documentation', () => { - const documentationLink = wrapper.findByText(ReleasesEmptyState.i18n.moreInformation); - - expect(documentationLink.exists()).toBe(true); - - expect(documentationLink.attributes()).toEqual( - expect.objectContaining({ - 'aria-label': ReleasesEmptyState.i18n.releasesDocumentation, - href: documentationPath, - target: '_blank', - }), - ); + expect(emptyStateProps).toMatchObject({ + title: ReleasesEmptyState.i18n.emptyStateTitle, + svgPath: illustrationPath, + description: ReleasesEmptyState.i18n.emptyStateText, + primaryButtonLink: newReleasePath, + primaryButtonText: ReleasesEmptyState.i18n.newRelease, + secondaryButtonLink: documentationPath, + secondaryButtonText: ReleasesEmptyState.i18n.releasesDocumentation, + }); }); }); |