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>2020-05-26 15:08:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-26 15:08:22 +0300
commit1691cbe307f7698b3ee39811278990c43b6751a5 (patch)
tree2bd7d5b7143242f540a9edde92c83c791ebf8af4 /spec/javascripts
parent27c6c4bf061c3a2289ce4808b1b354535994d09d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/releases/components/app_index_spec.js184
-rw-r--r--spec/javascripts/releases/mock_data.js148
-rw-r--r--spec/javascripts/releases/stores/modules/list/actions_spec.js131
-rw-r--r--spec/javascripts/releases/stores/modules/list/helpers.js6
-rw-r--r--spec/javascripts/releases/stores/modules/list/mutations_spec.js55
5 files changed, 0 insertions, 524 deletions
diff --git a/spec/javascripts/releases/components/app_index_spec.js b/spec/javascripts/releases/components/app_index_spec.js
deleted file mode 100644
index 020937d07e5..00000000000
--- a/spec/javascripts/releases/components/app_index_spec.js
+++ /dev/null
@@ -1,184 +0,0 @@
-import { range as rge } from 'lodash';
-import Vue from 'vue';
-import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
-import app from '~/releases/components/app_index.vue';
-import createStore from '~/releases/stores';
-import listModule from '~/releases/stores/modules/list';
-import api from '~/api';
-import { resetStore } from '../stores/modules/list/helpers';
-import {
- pageInfoHeadersWithoutPagination,
- pageInfoHeadersWithPagination,
- release,
- releases,
-} from '../mock_data';
-import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
-import waitForPromises from 'spec/helpers/wait_for_promises';
-
-describe('Releases App ', () => {
- const Component = Vue.extend(app);
- let store;
- let vm;
- let releasesPagination;
-
- const props = {
- projectId: 'gitlab-ce',
- documentationPath: 'help/releases',
- illustrationPath: 'illustration/path',
- };
-
- beforeEach(() => {
- store = createStore({ modules: { list: listModule } });
- releasesPagination = rge(21).map(index => ({
- ...convertObjectPropsToCamelCase(release, { deep: true }),
- tagName: `${index}.00`,
- }));
- });
-
- afterEach(() => {
- resetStore(store);
- vm.$destroy();
- });
-
- describe('while loading', () => {
- beforeEach(() => {
- spyOn(api, 'releases').and.returnValue(Promise.resolve({ data: [], headers: {} }));
- vm = mountComponentWithStore(Component, { props, store });
- });
-
- it('renders loading icon', done => {
- expect(vm.$el.querySelector('.js-loading')).not.toBeNull();
- expect(vm.$el.querySelector('.js-empty-state')).toBeNull();
- expect(vm.$el.querySelector('.js-success-state')).toBeNull();
- expect(vm.$el.querySelector('.gl-pagination')).toBeNull();
-
- waitForPromises()
- .then(done)
- .catch(done.fail);
- });
- });
-
- describe('with successful request', () => {
- beforeEach(() => {
- spyOn(api, 'releases').and.returnValue(
- Promise.resolve({ data: releases, headers: pageInfoHeadersWithoutPagination }),
- );
- vm = mountComponentWithStore(Component, { props, store });
- });
-
- it('renders success state', done => {
- waitForPromises()
- .then(() => {
- expect(vm.$el.querySelector('.js-loading')).toBeNull();
- expect(vm.$el.querySelector('.js-empty-state')).toBeNull();
- expect(vm.$el.querySelector('.js-success-state')).not.toBeNull();
- expect(vm.$el.querySelector('.gl-pagination')).toBeNull();
-
- done();
- })
- .catch(done.fail);
- });
- });
-
- describe('with successful request and pagination', () => {
- beforeEach(() => {
- spyOn(api, 'releases').and.returnValue(
- Promise.resolve({ data: releasesPagination, headers: pageInfoHeadersWithPagination }),
- );
- vm = mountComponentWithStore(Component, { props, store });
- });
-
- it('renders success state', done => {
- waitForPromises()
- .then(() => {
- expect(vm.$el.querySelector('.js-loading')).toBeNull();
- expect(vm.$el.querySelector('.js-empty-state')).toBeNull();
- expect(vm.$el.querySelector('.js-success-state')).not.toBeNull();
- expect(vm.$el.querySelector('.gl-pagination')).not.toBeNull();
-
- done();
- })
- .catch(done.fail);
- });
- });
-
- describe('with empty request', () => {
- beforeEach(() => {
- spyOn(api, 'releases').and.returnValue(Promise.resolve({ data: [], headers: {} }));
- vm = mountComponentWithStore(Component, { props, store });
- });
-
- it('renders empty state', done => {
- waitForPromises()
- .then(() => {
- expect(vm.$el.querySelector('.js-loading')).toBeNull();
- expect(vm.$el.querySelector('.js-empty-state')).not.toBeNull();
- expect(vm.$el.querySelector('.js-success-state')).toBeNull();
- expect(vm.$el.querySelector('.gl-pagination')).toBeNull();
-
- done();
- })
- .catch(done.fail);
- });
- });
-
- describe('"New release" button', () => {
- const findNewReleaseButton = () => vm.$el.querySelector('.js-new-release-btn');
-
- beforeEach(() => {
- spyOn(api, 'releases').and.returnValue(Promise.resolve({ data: [], headers: {} }));
- });
-
- const factory = additionalProps => {
- vm = mountComponentWithStore(Component, {
- props: {
- ...props,
- ...additionalProps,
- },
- store,
- });
- };
-
- describe('when the user is allowed to create a new Release', () => {
- const newReleasePath = 'path/to/new/release';
-
- beforeEach(() => {
- factory({ newReleasePath });
- });
-
- it('renders the "New release" button', done => {
- waitForPromises()
- .then(() => {
- expect(findNewReleaseButton()).not.toBeNull();
-
- done();
- })
- .catch(done.fail);
- });
-
- it('renders the "New release" button with the correct href', done => {
- waitForPromises()
- .then(() => {
- expect(findNewReleaseButton().getAttribute('href')).toBe(newReleasePath);
-
- done();
- })
- .catch(done.fail);
- });
- });
-
- describe('when the user is not allowed to create a new Release', () => {
- beforeEach(() => factory());
-
- it('does not render the "New release" button', done => {
- waitForPromises()
- .then(() => {
- expect(findNewReleaseButton()).toBeNull();
-
- done();
- })
- .catch(done.fail);
- });
- });
- });
-});
diff --git a/spec/javascripts/releases/mock_data.js b/spec/javascripts/releases/mock_data.js
deleted file mode 100644
index 72875dff172..00000000000
--- a/spec/javascripts/releases/mock_data.js
+++ /dev/null
@@ -1,148 +0,0 @@
-export const pageInfoHeadersWithoutPagination = {
- 'X-NEXT-PAGE': '',
- 'X-PAGE': '1',
- 'X-PER-PAGE': '20',
- 'X-PREV-PAGE': '',
- 'X-TOTAL': '19',
- 'X-TOTAL-PAGES': '1',
-};
-
-export const pageInfoHeadersWithPagination = {
- 'X-NEXT-PAGE': '2',
- 'X-PAGE': '1',
- 'X-PER-PAGE': '20',
- 'X-PREV-PAGE': '',
- 'X-TOTAL': '21',
- 'X-TOTAL-PAGES': '2',
-};
-
-export const release = {
- name: 'Bionic Beaver',
- tag_name: '18.04',
- description: '## changelog\n\n* line 1\n* line2',
- description_html: '<div><h2>changelog</h2><ul><li>line1</li<li>line 2</li></ul></div>',
- author_name: 'Release bot',
- author_email: 'release-bot@example.com',
- created_at: '2012-05-28T05:00:00-07:00',
- commit: {
- id: '2695effb5807a22ff3d138d593fd856244e155e7',
- short_id: '2695effb',
- title: 'Initial commit',
- created_at: '2017-07-26T11:08:53.000+02:00',
- parent_ids: ['2a4b78934375d7f53875269ffd4f45fd83a84ebe'],
- message: 'Initial commit',
- author: {
- avatar_url: 'uploads/-/system/user/avatar/johndoe/avatar.png',
- id: 482476,
- name: 'John Doe',
- path: '/johndoe',
- state: 'active',
- status_tooltip_html: null,
- username: 'johndoe',
- web_url: 'https://gitlab.com/johndoe',
- },
- authored_date: '2012-05-28T04:42:42-07:00',
- committer_name: 'Jack Smith',
- committer_email: 'jack@example.com',
- committed_date: '2012-05-28T04:42:42-07:00',
- },
- assets: {
- count: 6,
- sources: [
- {
- format: 'zip',
- url: 'https://gitlab.com/gitlab-org/gitlab-foss/-/archive/v11.3.12/gitlab-ce-v11.3.12.zip',
- },
- {
- format: 'tar.gz',
- url:
- 'https://gitlab.com/gitlab-org/gitlab-foss/-/archive/v11.3.12/gitlab-ce-v11.3.12.tar.gz',
- },
- {
- format: 'tar.bz2',
- url:
- 'https://gitlab.com/gitlab-org/gitlab-foss/-/archive/v11.3.12/gitlab-ce-v11.3.12.tar.bz2',
- },
- {
- format: 'tar',
- url: 'https://gitlab.com/gitlab-org/gitlab-foss/-/archive/v11.3.12/gitlab-ce-v11.3.12.tar',
- },
- ],
- links: [
- {
- name: 'release-18.04.dmg',
- url: 'https://my-external-hosting.example.com/scrambled-url/',
- external: true,
- },
- {
- name: 'binary-linux-amd64',
- url:
- 'https://gitlab.com/gitlab-org/gitlab-foss/-/jobs/artifacts/v11.6.0-rc4/download?job=rspec-mysql+41%2F50',
- external: false,
- },
- ],
- },
-};
-
-export const releases = [
- release,
- {
- name: 'JoJos Bizarre Adventure',
- tag_name: '19.00',
- description: '## changelog\n\n* line 1\n* line2',
- description_html: '<div><h2>changelog</h2><ul><li>line1</li<li>line 2</li></ul></div>',
- author_name: 'Release bot',
- author_email: 'release-bot@example.com',
- created_at: '2012-05-28T05:00:00-07:00',
- commit: {
- id: '2695effb5807a22ff3d138d593fd856244e155e7',
- short_id: '2695effb',
- title: 'Initial commit',
- created_at: '2017-07-26T11:08:53.000+02:00',
- parent_ids: ['2a4b78934375d7f53875269ffd4f45fd83a84ebe'],
- message: 'Initial commit',
- author: {
- avatar_url: 'uploads/-/system/user/avatar/johndoe/avatar.png',
- id: 482476,
- name: 'John Doe',
- path: '/johndoe',
- state: 'active',
- status_tooltip_html: null,
- username: 'johndoe',
- web_url: 'https://gitlab.com/johndoe',
- },
- authored_date: '2012-05-28T04:42:42-07:00',
- committer_name: 'Jack Smith',
- committer_email: 'jack@example.com',
- committed_date: '2012-05-28T04:42:42-07:00',
- },
- assets: {
- count: 4,
- sources: [
- {
- format: 'tar.gz',
- url:
- 'https://gitlab.com/gitlab-org/gitlab-foss/-/archive/v11.3.12/gitlab-ce-v11.3.12.tar.gz',
- },
- {
- format: 'tar.bz2',
- url:
- 'https://gitlab.com/gitlab-org/gitlab-foss/-/archive/v11.3.12/gitlab-ce-v11.3.12.tar.bz2',
- },
- {
- format: 'tar',
- url:
- 'https://gitlab.com/gitlab-org/gitlab-foss/-/archive/v11.3.12/gitlab-ce-v11.3.12.tar',
- },
- ],
- links: [
- {
- name: 'binary-linux-amd64',
- url:
- 'https://gitlab.com/gitlab-org/gitlab-foss/-/jobs/artifacts/v11.6.0-rc4/download?job=rspec-mysql+41%2F50',
- external: false,
- },
- ],
- },
- },
-];
diff --git a/spec/javascripts/releases/stores/modules/list/actions_spec.js b/spec/javascripts/releases/stores/modules/list/actions_spec.js
deleted file mode 100644
index bf85e18997b..00000000000
--- a/spec/javascripts/releases/stores/modules/list/actions_spec.js
+++ /dev/null
@@ -1,131 +0,0 @@
-import testAction from 'spec/helpers/vuex_action_helper';
-import {
- requestReleases,
- fetchReleases,
- receiveReleasesSuccess,
- receiveReleasesError,
-} from '~/releases/stores/modules/list/actions';
-import state from '~/releases/stores/modules/list/state';
-import * as types from '~/releases/stores/modules/list/mutation_types';
-import api from '~/api';
-import { parseIntPagination, convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
-import { pageInfoHeadersWithoutPagination, releases as originalReleases } from '../../../mock_data';
-
-describe('Releases State actions', () => {
- let mockedState;
- let pageInfo;
- let releases;
-
- beforeEach(() => {
- mockedState = state();
- pageInfo = parseIntPagination(pageInfoHeadersWithoutPagination);
- releases = convertObjectPropsToCamelCase(originalReleases, { deep: true });
- });
-
- describe('requestReleases', () => {
- it('should commit REQUEST_RELEASES mutation', done => {
- testAction(requestReleases, null, mockedState, [{ type: types.REQUEST_RELEASES }], [], done);
- });
- });
-
- describe('fetchReleases', () => {
- describe('success', () => {
- it('dispatches requestReleases and receiveReleasesSuccess', done => {
- spyOn(api, 'releases').and.callFake((id, options) => {
- expect(id).toEqual(1);
- expect(options.page).toEqual('1');
- return Promise.resolve({ data: releases, headers: pageInfoHeadersWithoutPagination });
- });
-
- testAction(
- fetchReleases,
- { projectId: 1 },
- mockedState,
- [],
- [
- {
- type: 'requestReleases',
- },
- {
- payload: { data: releases, headers: pageInfoHeadersWithoutPagination },
- type: 'receiveReleasesSuccess',
- },
- ],
- done,
- );
- });
-
- it('dispatches requestReleases and receiveReleasesSuccess on page two', done => {
- spyOn(api, 'releases').and.callFake((_, options) => {
- expect(options.page).toEqual('2');
- return Promise.resolve({ data: releases, headers: pageInfoHeadersWithoutPagination });
- });
-
- testAction(
- fetchReleases,
- { page: '2', projectId: 1 },
- mockedState,
- [],
- [
- {
- type: 'requestReleases',
- },
- {
- payload: { data: releases, headers: pageInfoHeadersWithoutPagination },
- type: 'receiveReleasesSuccess',
- },
- ],
- done,
- );
- });
- });
-
- describe('error', () => {
- it('dispatches requestReleases and receiveReleasesError', done => {
- spyOn(api, 'releases').and.returnValue(Promise.reject());
-
- testAction(
- fetchReleases,
- { projectId: null },
- mockedState,
- [],
- [
- {
- type: 'requestReleases',
- },
- {
- type: 'receiveReleasesError',
- },
- ],
- done,
- );
- });
- });
- });
-
- describe('receiveReleasesSuccess', () => {
- it('should commit RECEIVE_RELEASES_SUCCESS mutation', done => {
- testAction(
- receiveReleasesSuccess,
- { data: releases, headers: pageInfoHeadersWithoutPagination },
- mockedState,
- [{ type: types.RECEIVE_RELEASES_SUCCESS, payload: { pageInfo, data: releases } }],
- [],
- done,
- );
- });
- });
-
- describe('receiveReleasesError', () => {
- it('should commit RECEIVE_RELEASES_ERROR mutation', done => {
- testAction(
- receiveReleasesError,
- null,
- mockedState,
- [{ type: types.RECEIVE_RELEASES_ERROR }],
- [],
- done,
- );
- });
- });
-});
diff --git a/spec/javascripts/releases/stores/modules/list/helpers.js b/spec/javascripts/releases/stores/modules/list/helpers.js
deleted file mode 100644
index 435ca36047e..00000000000
--- a/spec/javascripts/releases/stores/modules/list/helpers.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import state from '~/releases/stores/modules/list/state';
-
-// eslint-disable-next-line import/prefer-default-export
-export const resetStore = store => {
- store.replaceState(state());
-};
diff --git a/spec/javascripts/releases/stores/modules/list/mutations_spec.js b/spec/javascripts/releases/stores/modules/list/mutations_spec.js
deleted file mode 100644
index 3035b916ff6..00000000000
--- a/spec/javascripts/releases/stores/modules/list/mutations_spec.js
+++ /dev/null
@@ -1,55 +0,0 @@
-import state from '~/releases/stores/modules/list/state';
-import mutations from '~/releases/stores/modules/list/mutations';
-import * as types from '~/releases/stores/modules/list/mutation_types';
-import { parseIntPagination } from '~/lib/utils/common_utils';
-import { pageInfoHeadersWithoutPagination, releases } from '../../../mock_data';
-
-describe('Releases Store Mutations', () => {
- let stateCopy;
- let pageInfo;
-
- beforeEach(() => {
- stateCopy = state();
- pageInfo = parseIntPagination(pageInfoHeadersWithoutPagination);
- });
-
- describe('REQUEST_RELEASES', () => {
- it('sets isLoading to true', () => {
- mutations[types.REQUEST_RELEASES](stateCopy);
-
- expect(stateCopy.isLoading).toEqual(true);
- });
- });
-
- describe('RECEIVE_RELEASES_SUCCESS', () => {
- beforeEach(() => {
- mutations[types.RECEIVE_RELEASES_SUCCESS](stateCopy, { pageInfo, data: releases });
- });
-
- it('sets is loading to false', () => {
- expect(stateCopy.isLoading).toEqual(false);
- });
-
- it('sets hasError to false', () => {
- expect(stateCopy.hasError).toEqual(false);
- });
-
- it('sets data', () => {
- expect(stateCopy.releases).toEqual(releases);
- });
-
- it('sets pageInfo', () => {
- expect(stateCopy.pageInfo).toEqual(pageInfo);
- });
- });
-
- describe('RECEIVE_RELEASES_ERROR', () => {
- it('resets data', () => {
- mutations[types.RECEIVE_RELEASES_ERROR](stateCopy);
-
- expect(stateCopy.isLoading).toEqual(false);
- expect(stateCopy.releases).toEqual([]);
- expect(stateCopy.pageInfo).toEqual({});
- });
- });
-});