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-02-04 15:09:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-04 15:09:00 +0300
commit88a0824944720b6edaaef56376713541b9a02118 (patch)
treef5fcc4f9755f249779cda9a8f02902d734af6e7e /spec/javascripts
parent7d19df2d34a9803d9f077c16315ba919b7ae2aa2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/jobs/components/job_app_spec.js20
-rw-r--r--spec/javascripts/jobs/store/actions_spec.js117
2 files changed, 115 insertions, 22 deletions
diff --git a/spec/javascripts/jobs/components/job_app_spec.js b/spec/javascripts/jobs/components/job_app_spec.js
index 0fcd6080106..31b49c45908 100644
--- a/spec/javascripts/jobs/components/job_app_spec.js
+++ b/spec/javascripts/jobs/components/job_app_spec.js
@@ -6,7 +6,6 @@ import axios from '~/lib/utils/axios_utils';
import jobApp from '~/jobs/components/job_app.vue';
import createStore from '~/jobs/store';
import * as types from '~/jobs/store/mutation_types';
-import { resetStore } from '../store/helpers';
import job from '../mock_data';
describe('Job App ', () => {
@@ -16,24 +15,29 @@ describe('Job App ', () => {
let vm;
let mock;
- const props = {
+ const initSettings = {
endpoint: `${gl.TEST_HOST}jobs/123.json`,
+ pagePath: `${gl.TEST_HOST}jobs/123`,
+ logState:
+ 'eyJvZmZzZXQiOjE3NDUxLCJuX29wZW5fdGFncyI6MCwiZmdfY29sb3IiOm51bGwsImJnX2NvbG9yIjpudWxsLCJzdHlsZV9tYXNrIjowfQ%3D%3D',
+ };
+
+ const props = {
runnerHelpUrl: 'help/runner',
deploymentHelpUrl: 'help/deployment',
runnerSettingsUrl: 'settings/ci-cd/runners',
variablesSettingsUrl: 'settings/ci-cd/variables',
terminalPath: 'jobs/123/terminal',
- pagePath: `${gl.TEST_HOST}jobs/123`,
projectPath: 'user-name/project-name',
subscriptionsMoreMinutesUrl: 'https://customers.gitlab.com/buy_pipeline_minutes',
- logState:
- 'eyJvZmZzZXQiOjE3NDUxLCJuX29wZW5fdGFncyI6MCwiZmdfY29sb3IiOm51bGwsImJnX2NvbG9yIjpudWxsLCJzdHlsZV9tYXNrIjowfQ%3D%3D',
};
const waitForJobReceived = () => waitForMutation(store, types.RECEIVE_JOB_SUCCESS);
const setupAndMount = ({ jobData = {}, traceData = {} } = {}) => {
- mock.onGet(props.endpoint).replyOnce(200, { ...job, ...jobData });
- mock.onGet(`${props.pagePath}/trace.json`).reply(200, traceData);
+ mock.onGet(initSettings.endpoint).replyOnce(200, { ...job, ...jobData });
+ mock.onGet(`${initSettings.pagePath}/trace.json`).reply(200, traceData);
+
+ store.dispatch('init', initSettings);
vm = mountComponentWithStore(Component, { props, store });
@@ -46,7 +50,6 @@ describe('Job App ', () => {
});
afterEach(() => {
- resetStore(store);
vm.$destroy();
mock.restore();
});
@@ -384,7 +387,6 @@ describe('Job App ', () => {
})
.then(done)
.catch(done.fail);
- done();
});
it('displays remaining time for a delayed job', done => {
diff --git a/spec/javascripts/jobs/store/actions_spec.js b/spec/javascripts/jobs/store/actions_spec.js
index c0e8dbf9b22..47257688bd5 100644
--- a/spec/javascripts/jobs/store/actions_spec.js
+++ b/spec/javascripts/jobs/store/actions_spec.js
@@ -15,6 +15,7 @@ import {
scrollBottom,
requestTrace,
fetchTrace,
+ startPollingTrace,
stopPollingTrace,
receiveTraceSuccess,
receiveTraceError,
@@ -241,6 +242,50 @@ describe('Job State actions', () => {
done,
);
});
+
+ describe('when job is incomplete', () => {
+ let tracePayload;
+
+ beforeEach(() => {
+ tracePayload = {
+ html: 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- :',
+ complete: false,
+ };
+
+ mock.onGet(`${TEST_HOST}/endpoint/trace.json`).replyOnce(200, tracePayload);
+ });
+
+ it('dispatches startPollingTrace', done => {
+ testAction(
+ fetchTrace,
+ null,
+ mockedState,
+ [],
+ [
+ { type: 'toggleScrollisInBottom', payload: true },
+ { type: 'receiveTraceSuccess', payload: tracePayload },
+ { type: 'startPollingTrace' },
+ ],
+ done,
+ );
+ });
+
+ it('does not dispatch startPollingTrace when timeout is non-empty', done => {
+ mockedState.traceTimeout = 1;
+
+ testAction(
+ fetchTrace,
+ null,
+ mockedState,
+ [],
+ [
+ { type: 'toggleScrollisInBottom', payload: true },
+ { type: 'receiveTraceSuccess', payload: tracePayload },
+ ],
+ done,
+ );
+ });
+ });
});
describe('error', () => {
@@ -265,16 +310,69 @@ describe('Job State actions', () => {
});
});
+ describe('startPollingTrace', () => {
+ let dispatch;
+ let commit;
+
+ beforeEach(() => {
+ jasmine.clock().install();
+
+ dispatch = jasmine.createSpy();
+ commit = jasmine.createSpy();
+
+ startPollingTrace({ dispatch, commit });
+ });
+
+ afterEach(() => {
+ jasmine.clock().uninstall();
+ });
+
+ it('should save the timeout id but not call fetchTrace', () => {
+ expect(commit).toHaveBeenCalledWith(types.SET_TRACE_TIMEOUT, 1);
+ expect(dispatch).not.toHaveBeenCalledWith('fetchTrace');
+ });
+
+ describe('after timeout has passed', () => {
+ beforeEach(() => {
+ jasmine.clock().tick(4000);
+ });
+
+ it('should clear the timeout id and fetchTrace', () => {
+ expect(commit).toHaveBeenCalledWith(types.SET_TRACE_TIMEOUT, 0);
+ expect(dispatch).toHaveBeenCalledWith('fetchTrace');
+ });
+ });
+ });
+
describe('stopPollingTrace', () => {
+ let origTimeout;
+
+ beforeEach(() => {
+ // Can't use spyOn(window, 'clearTimeout') because this caused unrelated specs to timeout
+ // https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23838#note_280277727
+ origTimeout = window.clearTimeout;
+ window.clearTimeout = jasmine.createSpy();
+ });
+
+ afterEach(() => {
+ window.clearTimeout = origTimeout;
+ });
+
it('should commit STOP_POLLING_TRACE mutation ', done => {
+ const traceTimeout = 7;
+
testAction(
stopPollingTrace,
null,
- mockedState,
- [{ type: types.STOP_POLLING_TRACE }],
+ { ...mockedState, traceTimeout },
+ [{ type: types.SET_TRACE_TIMEOUT, payload: 0 }, { type: types.STOP_POLLING_TRACE }],
[],
- done,
- );
+ )
+ .then(() => {
+ expect(window.clearTimeout).toHaveBeenCalledWith(traceTimeout);
+ })
+ .then(done)
+ .catch(done.fail);
});
});
@@ -292,15 +390,8 @@ describe('Job State actions', () => {
});
describe('receiveTraceError', () => {
- it('should commit RECEIVE_TRACE_ERROR mutation ', done => {
- testAction(
- receiveTraceError,
- null,
- mockedState,
- [{ type: types.RECEIVE_TRACE_ERROR }],
- [],
- done,
- );
+ it('should commit stop polling trace', done => {
+ testAction(receiveTraceError, null, mockedState, [], [{ type: 'stopPollingTrace' }], done);
});
});