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-03-25 00:07:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-25 00:07:54 +0300
commitc4db541c1b2c97ab1eda354ea3899489fe5c33e5 (patch)
tree45d5d381232179082ea11136e3b53211b37349d5 /spec/frontend
parent603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/blob/blob_file_dropzone_spec.js7
-rw-r--r--spec/frontend/boards/board_new_issue_spec.js8
-rw-r--r--spec/frontend/diffs/components/diff_file_header_spec.js6
-rw-r--r--spec/frontend/helpers/jquery.js12
-rw-r--r--spec/frontend/mocks/node/jquery.js15
-rw-r--r--spec/frontend/notes/components/notes_app_spec.js2
-rw-r--r--spec/frontend/releases/stores/modules/detail/actions_spec.js19
-rw-r--r--spec/frontend/releases/stores/modules/detail/mutations_spec.js77
-rw-r--r--spec/frontend/test_setup.js9
-rw-r--r--spec/frontend/vue_shared/components/file_row_spec.js13
10 files changed, 60 insertions, 108 deletions
diff --git a/spec/frontend/blob/blob_file_dropzone_spec.js b/spec/frontend/blob/blob_file_dropzone_spec.js
index 4e9a05418df..cbd36abd4ff 100644
--- a/spec/frontend/blob/blob_file_dropzone_spec.js
+++ b/spec/frontend/blob/blob_file_dropzone_spec.js
@@ -5,10 +5,6 @@ describe('BlobFileDropzone', () => {
preloadFixtures('blob/show.html');
let dropzone;
let replaceFileButton;
- const jQueryMock = {
- enable: jest.fn(),
- disable: jest.fn(),
- };
beforeEach(() => {
loadFixtures('blob/show.html');
@@ -18,7 +14,6 @@ describe('BlobFileDropzone', () => {
dropzone = $('.js-upload-blob-form .dropzone').get(0).dropzone;
dropzone.processQueue = jest.fn();
replaceFileButton = $('#submit-all');
- $.fn.extend(jQueryMock);
});
describe('submit button', () => {
@@ -43,7 +38,7 @@ describe('BlobFileDropzone', () => {
replaceFileButton.click();
expect(window.alert).not.toHaveBeenCalled();
- expect(jQueryMock.enable).toHaveBeenCalled();
+ expect(replaceFileButton.is(':disabled')).toEqual(true);
expect(dropzone.processQueue).toHaveBeenCalled();
});
});
diff --git a/spec/frontend/boards/board_new_issue_spec.js b/spec/frontend/boards/board_new_issue_spec.js
index 4eb7f0c131e..94afc8a2b45 100644
--- a/spec/frontend/boards/board_new_issue_spec.js
+++ b/spec/frontend/boards/board_new_issue_spec.js
@@ -1,6 +1,5 @@
/* global List */
-import $ from 'jquery';
import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
@@ -15,9 +14,6 @@ describe('Issue boards new issue form', () => {
let list;
let mock;
let newIssueMock;
- const jQueryMock = {
- enable: jest.fn(),
- };
const promiseReturn = {
data: {
iid: 100,
@@ -53,8 +49,6 @@ describe('Issue boards new issue form', () => {
},
}).$mount(document.querySelector('.test-container'));
- $.fn.extend(jQueryMock);
-
return Vue.nextTick();
});
@@ -118,7 +112,7 @@ describe('Issue boards new issue form', () => {
return Vue.nextTick()
.then(submitIssue)
.then(() => {
- expect(jQueryMock.enable).toHaveBeenCalled();
+ expect(vm.$el.querySelector('.btn-success').disabled).toBe(false);
});
});
diff --git a/spec/frontend/diffs/components/diff_file_header_spec.js b/spec/frontend/diffs/components/diff_file_header_spec.js
index 8e6a5576015..e0b7e0bc0f3 100644
--- a/spec/frontend/diffs/components/diff_file_header_spec.js
+++ b/spec/frontend/diffs/components/diff_file_header_spec.js
@@ -61,7 +61,6 @@ describe('DiffFileHeader component', () => {
const findTitleLink = () => wrapper.find({ ref: 'titleWrapper' });
const findExpandButton = () => wrapper.find({ ref: 'expandDiffToFullFileButton' });
const findFileActions = () => wrapper.find('.file-actions');
- const findActiveHeader = () => wrapper.find('.is-active');
const findModeChangedLine = () => wrapper.find({ ref: 'fileMode' });
const findLfsLabel = () => wrapper.find('.label-lfs');
const findToggleDiscussionsButton = () => wrapper.find({ ref: 'toggleDiscussionsButton' });
@@ -144,11 +143,6 @@ describe('DiffFileHeader component', () => {
expect(wrapper.find(ClipboardButton).exists()).toBe(true);
});
- it('contains a active header class if this is the active file header', () => {
- createComponent({ isActive: true });
- expect(findActiveHeader().exists()).toBe(true);
- });
-
describe('for submodule', () => {
const submoduleDiffFile = {
...diffFile,
diff --git a/spec/frontend/helpers/jquery.js b/spec/frontend/helpers/jquery.js
index 6421a592c0c..4af5f904394 100644
--- a/spec/frontend/helpers/jquery.js
+++ b/spec/frontend/helpers/jquery.js
@@ -1,6 +1,18 @@
import $ from 'jquery';
+// Expose jQuery so specs using jQuery plugins can be imported nicely.
+// Here is an issue to explore better alternatives:
+// https://gitlab.com/gitlab-org/gitlab/issues/12448
global.$ = $;
global.jQuery = $;
+// Fail tests for unmocked requests
+$.ajax = () => {
+ const err = new Error(
+ 'Unexpected unmocked jQuery.ajax() call! Make sure to mock jQuery.ajax() in tests.',
+ );
+ global.fail(err);
+ throw err;
+};
+
export default $;
diff --git a/spec/frontend/mocks/node/jquery.js b/spec/frontend/mocks/node/jquery.js
deleted file mode 100644
index 5c82f65406e..00000000000
--- a/spec/frontend/mocks/node/jquery.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/* eslint-disable import/no-commonjs */
-
-const $ = jest.requireActual('jquery');
-
-// Fail tests for unmocked requests
-$.ajax = () => {
- const err = new Error(
- 'Unexpected unmocked jQuery.ajax() call! Make sure to mock jQuery.ajax() in tests.',
- );
- global.fail(err);
- throw err;
-};
-
-// jquery is not an ES6 module
-module.exports = $;
diff --git a/spec/frontend/notes/components/notes_app_spec.js b/spec/frontend/notes/components/notes_app_spec.js
index 2d0cca18647..60e866542a6 100644
--- a/spec/frontend/notes/components/notes_app_spec.js
+++ b/spec/frontend/notes/components/notes_app_spec.js
@@ -1,4 +1,4 @@
-import $ from 'helpers/jquery';
+import $ from 'jquery';
import AxiosMockAdapter from 'axios-mock-adapter';
import Vue from 'vue';
import { mount } from '@vue/test-utils';
diff --git a/spec/frontend/releases/stores/modules/detail/actions_spec.js b/spec/frontend/releases/stores/modules/detail/actions_spec.js
index 88346083f5a..70f7432c65d 100644
--- a/spec/frontend/releases/stores/modules/detail/actions_spec.js
+++ b/spec/frontend/releases/stores/modules/detail/actions_spec.js
@@ -24,7 +24,14 @@ describe('Release detail actions', () => {
let error;
beforeEach(() => {
- state = createState();
+ state = createState({
+ projectId: '18',
+ tagName: 'v1.3',
+ releasesPagePath: 'path/to/releases/page',
+ markdownDocsPath: 'path/to/markdown/docs',
+ markdownPreviewPath: 'path/to/markdown/preview',
+ updateReleaseApiDocsPath: 'path/to/api/docs',
+ });
release = cloneDeep(originalRelease);
mock = new MockAdapter(axios);
gon.api_version = 'v4';
@@ -36,16 +43,6 @@ describe('Release detail actions', () => {
mock.restore();
});
- describe('setInitialState', () => {
- it(`commits ${types.SET_INITIAL_STATE} with the provided object`, () => {
- const initialState = {};
-
- return testAction(actions.setInitialState, initialState, state, [
- { type: types.SET_INITIAL_STATE, payload: initialState },
- ]);
- });
- });
-
describe('requestRelease', () => {
it(`commits ${types.REQUEST_RELEASE}`, () =>
testAction(actions.requestRelease, undefined, state, [{ type: types.REQUEST_RELEASE }]));
diff --git a/spec/frontend/releases/stores/modules/detail/mutations_spec.js b/spec/frontend/releases/stores/modules/detail/mutations_spec.js
index 81b2dde75ab..d49c8854ca2 100644
--- a/spec/frontend/releases/stores/modules/detail/mutations_spec.js
+++ b/spec/frontend/releases/stores/modules/detail/mutations_spec.js
@@ -5,115 +5,106 @@
* is resolved
*/
-import state from '~/releases/stores/modules/detail/state';
+import createState from '~/releases/stores/modules/detail/state';
import mutations from '~/releases/stores/modules/detail/mutations';
import * as types from '~/releases/stores/modules/detail/mutation_types';
import { release } from '../../../mock_data';
describe('Release detail mutations', () => {
- let stateClone;
+ let state;
let releaseClone;
beforeEach(() => {
- stateClone = state();
- releaseClone = JSON.parse(JSON.stringify(release));
- });
-
- describe(types.SET_INITIAL_STATE, () => {
- it('populates the state with initial values', () => {
- const initialState = {
- projectId: '18',
- tagName: 'v1.3',
- releasesPagePath: 'path/to/releases/page',
- markdownDocsPath: 'path/to/markdown/docs',
- markdownPreviewPath: 'path/to/markdown/preview',
- };
-
- mutations[types.SET_INITIAL_STATE](stateClone, initialState);
-
- expect(stateClone).toEqual(expect.objectContaining(initialState));
+ state = createState({
+ projectId: '18',
+ tagName: 'v1.3',
+ releasesPagePath: 'path/to/releases/page',
+ markdownDocsPath: 'path/to/markdown/docs',
+ markdownPreviewPath: 'path/to/markdown/preview',
+ updateReleaseApiDocsPath: 'path/to/api/docs',
});
+ releaseClone = JSON.parse(JSON.stringify(release));
});
describe(types.REQUEST_RELEASE, () => {
it('set state.isFetchingRelease to true', () => {
- mutations[types.REQUEST_RELEASE](stateClone);
+ mutations[types.REQUEST_RELEASE](state);
- expect(stateClone.isFetchingRelease).toEqual(true);
+ expect(state.isFetchingRelease).toEqual(true);
});
});
describe(types.RECEIVE_RELEASE_SUCCESS, () => {
it('handles a successful response from the server', () => {
- mutations[types.RECEIVE_RELEASE_SUCCESS](stateClone, releaseClone);
+ mutations[types.RECEIVE_RELEASE_SUCCESS](state, releaseClone);
- expect(stateClone.fetchError).toEqual(undefined);
+ expect(state.fetchError).toEqual(undefined);
- expect(stateClone.isFetchingRelease).toEqual(false);
+ expect(state.isFetchingRelease).toEqual(false);
- expect(stateClone.release).toEqual(releaseClone);
+ expect(state.release).toEqual(releaseClone);
});
});
describe(types.RECEIVE_RELEASE_ERROR, () => {
it('handles an unsuccessful response from the server', () => {
const error = { message: 'An error occurred!' };
- mutations[types.RECEIVE_RELEASE_ERROR](stateClone, error);
+ mutations[types.RECEIVE_RELEASE_ERROR](state, error);
- expect(stateClone.isFetchingRelease).toEqual(false);
+ expect(state.isFetchingRelease).toEqual(false);
- expect(stateClone.release).toBeUndefined();
+ expect(state.release).toBeUndefined();
- expect(stateClone.fetchError).toEqual(error);
+ expect(state.fetchError).toEqual(error);
});
});
describe(types.UPDATE_RELEASE_TITLE, () => {
it("updates the release's title", () => {
- stateClone.release = releaseClone;
+ state.release = releaseClone;
const newTitle = 'The new release title';
- mutations[types.UPDATE_RELEASE_TITLE](stateClone, newTitle);
+ mutations[types.UPDATE_RELEASE_TITLE](state, newTitle);
- expect(stateClone.release.name).toEqual(newTitle);
+ expect(state.release.name).toEqual(newTitle);
});
});
describe(types.UPDATE_RELEASE_NOTES, () => {
it("updates the release's notes", () => {
- stateClone.release = releaseClone;
+ state.release = releaseClone;
const newNotes = 'The new release notes';
- mutations[types.UPDATE_RELEASE_NOTES](stateClone, newNotes);
+ mutations[types.UPDATE_RELEASE_NOTES](state, newNotes);
- expect(stateClone.release.description).toEqual(newNotes);
+ expect(state.release.description).toEqual(newNotes);
});
});
describe(types.REQUEST_UPDATE_RELEASE, () => {
it('set state.isUpdatingRelease to true', () => {
- mutations[types.REQUEST_UPDATE_RELEASE](stateClone);
+ mutations[types.REQUEST_UPDATE_RELEASE](state);
- expect(stateClone.isUpdatingRelease).toEqual(true);
+ expect(state.isUpdatingRelease).toEqual(true);
});
});
describe(types.RECEIVE_UPDATE_RELEASE_SUCCESS, () => {
it('handles a successful response from the server', () => {
- mutations[types.RECEIVE_UPDATE_RELEASE_SUCCESS](stateClone, releaseClone);
+ mutations[types.RECEIVE_UPDATE_RELEASE_SUCCESS](state, releaseClone);
- expect(stateClone.updateError).toEqual(undefined);
+ expect(state.updateError).toEqual(undefined);
- expect(stateClone.isUpdatingRelease).toEqual(false);
+ expect(state.isUpdatingRelease).toEqual(false);
});
});
describe(types.RECEIVE_UPDATE_RELEASE_ERROR, () => {
it('handles an unsuccessful response from the server', () => {
const error = { message: 'An error occurred!' };
- mutations[types.RECEIVE_UPDATE_RELEASE_ERROR](stateClone, error);
+ mutations[types.RECEIVE_UPDATE_RELEASE_ERROR](state, error);
- expect(stateClone.isUpdatingRelease).toEqual(false);
+ expect(state.isUpdatingRelease).toEqual(false);
- expect(stateClone.updateError).toEqual(error);
+ expect(state.updateError).toEqual(error);
});
});
});
diff --git a/spec/frontend/test_setup.js b/spec/frontend/test_setup.js
index 203781bb6fc..fff76f158dd 100644
--- a/spec/frontend/test_setup.js
+++ b/spec/frontend/test_setup.js
@@ -1,6 +1,5 @@
import Vue from 'vue';
import * as jqueryMatchers from 'custom-jquery-matchers';
-import $ from 'jquery';
import { config as testUtilsConfig } from '@vue/test-utils';
import Translate from '~/vue_shared/translate';
import { initializeTestTimeout } from './helpers/timeout';
@@ -9,11 +8,9 @@ import { setupManualMocks } from './mocks/mocks_helper';
import customMatchers from './matchers';
import './helpers/dom_shims';
-
-// Expose jQuery so specs using jQuery plugins can be imported nicely.
-// Here is an issue to explore better alternatives:
-// https://gitlab.com/gitlab-org/gitlab/issues/12448
-window.jQuery = $;
+import './helpers/jquery';
+import '~/commons/jquery';
+import '~/commons/bootstrap';
process.on('unhandledRejection', global.promiseRejectionHandler);
diff --git a/spec/frontend/vue_shared/components/file_row_spec.js b/spec/frontend/vue_shared/components/file_row_spec.js
index 75d1ce9cc5b..b3ced84ddb5 100644
--- a/spec/frontend/vue_shared/components/file_row_spec.js
+++ b/spec/frontend/vue_shared/components/file_row_spec.js
@@ -72,19 +72,6 @@ describe('File row component', () => {
});
});
- it('is marked as viewed if clicked', () => {
- createComponent({
- file: {
- ...file(),
- type: 'blob',
- fileHash: '#123456789',
- },
- level: 0,
- viewedFiles: ['#123456789'],
- });
- expect(wrapper.classes()).toContain('is-viewed');
- });
-
it('indents row based on level', () => {
createComponent({
file: file('t4'),