Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-05 15:08:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-05 15:08:19 +0300
commit12b995e0e7aace4b7695c4424aed71b053c2c2a6 (patch)
tree0f2c9a902693aa5b7c9265c3ed24e842eedb6a96 /spec/frontend/releases
parent1e02d1c756e1b5e79453fcc805c9737bb6520fca (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/releases')
-rw-r--r--spec/frontend/releases/__snapshots__/util_spec.js.snap4
-rw-r--r--spec/frontend/releases/components/release_block_footer_spec.js231
2 files changed, 117 insertions, 118 deletions
diff --git a/spec/frontend/releases/__snapshots__/util_spec.js.snap b/spec/frontend/releases/__snapshots__/util_spec.js.snap
index d88d79d2cde..4084d734b83 100644
--- a/spec/frontend/releases/__snapshots__/util_spec.js.snap
+++ b/spec/frontend/releases/__snapshots__/util_spec.js.snap
@@ -53,6 +53,7 @@ Object {
"title": "Merge branch 'branch-merged' into 'master'",
},
"commitPath": "http://localhost/releases-namespace/releases-project/-/commit/b83d6e391c22777fca1ed3012fce84f633d7fed0",
+ "createdAt": 2019-01-03T00:00:00.000Z,
"descriptionHtml": "<p data-sourcepos=\\"1:1-1:23\\" dir=\\"auto\\">An okay release <gl-emoji title=\\"shrug\\" data-name=\\"shrug\\" data-unicode-version=\\"9.0\\">🤷</gl-emoji></p>",
"evidences": Array [],
"historicalRelease": false,
@@ -150,6 +151,7 @@ Object {
"title": "Merge branch 'branch-merged' into 'master'",
},
"commitPath": "http://localhost/releases-namespace/releases-project/-/commit/b83d6e391c22777fca1ed3012fce84f633d7fed0",
+ "createdAt": 2018-12-03T00:00:00.000Z,
"descriptionHtml": "<p data-sourcepos=\\"1:1-1:33\\" dir=\\"auto\\">Best. Release. <strong>Ever.</strong> <gl-emoji title=\\"rocket\\" data-name=\\"rocket\\" data-unicode-version=\\"6.0\\">🚀</gl-emoji></p>",
"evidences": Array [
Object {
@@ -253,6 +255,7 @@ Object {
"sources": Array [],
},
"author": undefined,
+ "createdAt": 2018-12-03T00:00:00.000Z,
"description": "Best. Release. **Ever.** :rocket:",
"evidences": Array [],
"milestones": Array [
@@ -372,6 +375,7 @@ Object {
"title": "Merge branch 'branch-merged' into 'master'",
},
"commitPath": "http://localhost/releases-namespace/releases-project/-/commit/b83d6e391c22777fca1ed3012fce84f633d7fed0",
+ "createdAt": 2018-12-03T00:00:00.000Z,
"descriptionHtml": "<p data-sourcepos=\\"1:1-1:33\\" dir=\\"auto\\">Best. Release. <strong>Ever.</strong> <gl-emoji title=\\"rocket\\" data-name=\\"rocket\\" data-unicode-version=\\"6.0\\">🚀</gl-emoji></p>",
"evidences": Array [
Object {
diff --git a/spec/frontend/releases/components/release_block_footer_spec.js b/spec/frontend/releases/components/release_block_footer_spec.js
index 8f4efad197f..d13cff49db2 100644
--- a/spec/frontend/releases/components/release_block_footer_spec.js
+++ b/spec/frontend/releases/components/release_block_footer_spec.js
@@ -4,6 +4,7 @@ import { cloneDeep } from 'lodash';
import { nextTick } from 'vue';
import originalOneReleaseQueryResponse from 'test_fixtures/graphql/releases/graphql/queries/one_release.query.graphql.json';
import { convertOneReleaseGraphQLResponse } from '~/releases/util';
+import { RELEASED_AT_ASC, RELEASED_AT_DESC, CREATED_ASC, CREATED_DESC } from '~/releases/constants';
import { trimText } from 'helpers/text_helper';
import ReleaseBlockFooter from '~/releases/components/release_block_footer.vue';
@@ -43,88 +44,118 @@ describe('Release block footer', () => {
const tagInfoSectionLink = () => tagInfoSection().findComponent(GlLink);
const authorDateInfoSection = () => wrapper.find('.js-author-date-info');
- describe('with all props provided', () => {
- beforeEach(() => factory());
-
- it('renders the commit icon', () => {
- const commitIcon = commitInfoSection().findComponent(GlIcon);
-
- expect(commitIcon.exists()).toBe(true);
- expect(commitIcon.props('name')).toBe('commit');
- });
-
- it('renders the commit SHA with a link', () => {
- const commitLink = commitInfoSectionLink();
-
- expect(commitLink.exists()).toBe(true);
- expect(commitLink.text()).toBe(release.commit.shortId);
- expect(commitLink.attributes('href')).toBe(release.commitPath);
- });
-
- it('renders the tag icon', () => {
- const commitIcon = tagInfoSection().findComponent(GlIcon);
-
- expect(commitIcon.exists()).toBe(true);
- expect(commitIcon.props('name')).toBe('tag');
- });
-
- it('renders the tag name with a link', () => {
- const commitLink = tagInfoSection().findComponent(GlLink);
-
- expect(commitLink.exists()).toBe(true);
- expect(commitLink.text()).toBe(release.tagName);
- expect(commitLink.attributes('href')).toBe(release.tagPath);
- });
-
- it('renders the author and creation time info', () => {
- expect(trimText(authorDateInfoSection().text())).toBe(
- `Created 1 year ago by ${release.author.username}`,
- );
- });
-
- describe('when the release date is in the past', () => {
- it('prefixes the creation info with "Created"', () => {
- expect(trimText(authorDateInfoSection().text())).toEqual(expect.stringMatching(/^Created/));
- });
- });
-
- describe('renders the author and creation time info with future release date', () => {
- beforeEach(() => {
- factory({ releasedAt: mockFutureDate });
- });
-
- it('renders the release date without the author name', () => {
- expect(trimText(authorDateInfoSection().text())).toBe(
- `Will be created in 1 month by ${release.author.username}`,
- );
- });
- });
-
- describe('when the release date is in the future', () => {
- beforeEach(() => {
- factory({ releasedAt: mockFutureDate });
- });
-
- it('prefixes the creation info with "Will be created"', () => {
- expect(trimText(authorDateInfoSection().text())).toEqual(
- expect.stringMatching(/^Will be created/),
- );
- });
- });
-
- it("renders the author's avatar image", () => {
- const avatarImg = authorDateInfoSection().find('img');
-
- expect(avatarImg.exists()).toBe(true);
- expect(avatarImg.attributes('src')).toBe(release.author.avatarUrl);
- });
-
- it("renders a link to the author's profile", () => {
- const authorLink = authorDateInfoSection().findComponent(GlLink);
-
- expect(authorLink.exists()).toBe(true);
- expect(authorLink.attributes('href')).toBe(release.author.webUrl);
- });
+ describe.each`
+ sortFlag | expectedInfoString
+ ${null} | ${'Created'}
+ ${CREATED_ASC} | ${'Created'}
+ ${CREATED_DESC} | ${'Created'}
+ ${RELEASED_AT_ASC} | ${'Released'}
+ ${RELEASED_AT_DESC} | ${'Released'}
+ `('with sorting set to $sortFlag', ({ sortFlag, expectedInfoString }) => {
+ const dateAt =
+ expectedInfoString === 'Created' ? originalRelease.createdAt : originalRelease.releasedAt;
+
+ describe.each`
+ dateType | dateFlag | expectedInfoStringPrefix | expectedDateString
+ ${'empty'} | ${undefined} | ${null} | ${null}
+ ${'in the past'} | ${dateAt} | ${null} | ${'1 year ago'}
+ ${'in the future'} | ${mockFutureDate} | ${'Will be'} | ${'in 1 month'}
+ `(
+ 'with date set to $dateType',
+ ({ dateFlag, expectedInfoStringPrefix, expectedDateString }) => {
+ describe.each`
+ authorType | authorFlag | expectedAuthorString
+ ${'empty'} | ${undefined} | ${null}
+ ${'present'} | ${originalRelease.author} | ${'by administrator'}
+ `('with author set to $authorType', ({ authorFlag, expectedAuthorString }) => {
+ const propsData = { sort: sortFlag, author: authorFlag };
+ if (dateFlag !== '') {
+ propsData.createdAt = dateFlag;
+ propsData.releasedAt = dateFlag;
+ }
+
+ beforeEach(() => {
+ factory({ ...propsData });
+ });
+
+ const expectedString = [
+ expectedInfoStringPrefix,
+ expectedInfoStringPrefix ? expectedInfoString.toLowerCase() : expectedInfoString,
+ expectedDateString,
+ expectedAuthorString,
+ ];
+
+ if (authorFlag || dateFlag) {
+ it('renders the author and creation time info', () => {
+ expect(trimText(authorDateInfoSection().text())).toBe(
+ expectedString.filter((n) => n).join(' '),
+ );
+ });
+ if (authorFlag) {
+ it("renders the author's avatar image", () => {
+ const avatarImg = authorDateInfoSection().find('img');
+
+ expect(avatarImg.exists()).toBe(true);
+ expect(avatarImg.attributes('src')).toBe(release.author.avatarUrl);
+ });
+
+ it("renders a link to the author's profile", () => {
+ const authorLink = authorDateInfoSection().findComponent(GlLink);
+
+ expect(authorLink.exists()).toBe(true);
+ expect(authorLink.attributes('href')).toBe(release.author.webUrl);
+ });
+ } else {
+ it("does not render the author's avatar image", () => {
+ const avatarImg = authorDateInfoSection().find('img');
+
+ expect(avatarImg.exists()).toBe(false);
+ });
+
+ it("does not render a link to the author's profile", () => {
+ const authorLink = authorDateInfoSection().findComponent(GlLink);
+
+ expect(authorLink.exists()).toBe(false);
+ });
+ }
+ } else {
+ it('does not render the author and creation time info', () => {
+ expect(authorDateInfoSection().exists()).toBe(false);
+ });
+ }
+
+ it('renders the commit icon', () => {
+ const commitIcon = commitInfoSection().findComponent(GlIcon);
+
+ expect(commitIcon.exists()).toBe(true);
+ expect(commitIcon.props('name')).toBe('commit');
+ });
+
+ it('renders the commit SHA with a link', () => {
+ const commitLink = commitInfoSectionLink();
+
+ expect(commitLink.exists()).toBe(true);
+ expect(commitLink.text()).toBe(release.commit.shortId);
+ expect(commitLink.attributes('href')).toBe(release.commitPath);
+ });
+
+ it('renders the tag icon', () => {
+ const commitIcon = tagInfoSection().findComponent(GlIcon);
+
+ expect(commitIcon.exists()).toBe(true);
+ expect(commitIcon.props('name')).toBe('tag');
+ });
+
+ it('renders the tag name with a link', () => {
+ const commitLink = tagInfoSection().findComponent(GlLink);
+
+ expect(commitLink.exists()).toBe(true);
+ expect(commitLink.text()).toBe(release.tagName);
+ expect(commitLink.attributes('href')).toBe(release.tagPath);
+ });
+ });
+ },
+ );
});
describe('without any commit info', () => {
@@ -160,40 +191,4 @@ describe('Release block footer', () => {
expect(tagInfoSection().text()).toBe(release.tagName);
});
});
-
- describe('without any author info', () => {
- beforeEach(() => factory({ author: undefined }));
-
- it('renders the release date without the author name', () => {
- expect(trimText(authorDateInfoSection().text())).toBe(`Created 1 year ago`);
- });
- });
-
- describe('future release without any author info', () => {
- beforeEach(() => {
- factory({ author: undefined, releasedAt: mockFutureDate });
- });
-
- it('renders the release date without the author name', () => {
- expect(trimText(authorDateInfoSection().text())).toBe(`Will be created in 1 month`);
- });
- });
-
- describe('without a released at date', () => {
- beforeEach(() => factory({ releasedAt: undefined }));
-
- it('renders the author name without the release date', () => {
- expect(trimText(authorDateInfoSection().text())).toBe(
- `Created by ${release.author.username}`,
- );
- });
- });
-
- describe('without a release date or author info', () => {
- beforeEach(() => factory({ author: undefined, releasedAt: undefined }));
-
- it('does not render any author or release date info', () => {
- expect(authorDateInfoSection().exists()).toBe(false);
- });
- });
});