Commit 3bd5e10e authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'ide-etag-polling' into 'master'

Fix IDE pipelines eTagPoll not stopping

Closes #47678

See merge request gitlab-org/gitlab-ce!19636
parents 1de36a68 d5dae8e5
...@@ -31,10 +31,15 @@ export const openMergeRequest = ({ commit, dispatch }, { projectPath, id }) => { ...@@ -31,10 +31,15 @@ export const openMergeRequest = ({ commit, dispatch }, { projectPath, id }) => {
commit(rootTypes.CLEAR_PROJECTS, null, { root: true }); commit(rootTypes.CLEAR_PROJECTS, null, { root: true });
commit(rootTypes.SET_CURRENT_MERGE_REQUEST, `${id}`, { root: true }); commit(rootTypes.SET_CURRENT_MERGE_REQUEST, `${id}`, { root: true });
commit(rootTypes.RESET_OPEN_FILES, null, { root: true }); commit(rootTypes.RESET_OPEN_FILES, null, { root: true });
dispatch('pipelines/stopPipelinePolling', null, { root: true });
dispatch('pipelines/clearEtagPoll', null, { root: true });
dispatch('pipelines/resetLatestPipeline', null, { root: true }); dispatch('pipelines/resetLatestPipeline', null, { root: true });
dispatch('setCurrentBranchId', '', { root: true }); dispatch('setCurrentBranchId', '', { root: true });
dispatch('pipelines/stopPipelinePolling', null, { root: true })
.then(() => {
dispatch('pipelines/clearEtagPoll', null, { root: true });
})
.catch(e => {
throw e;
});
router.push(`/project/${projectPath}/merge_requests/${id}`); router.push(`/project/${projectPath}/merge_requests/${id}`);
}; };
......
...@@ -12,8 +12,12 @@ let eTagPoll; ...@@ -12,8 +12,12 @@ let eTagPoll;
export const clearEtagPoll = () => { export const clearEtagPoll = () => {
eTagPoll = null; eTagPoll = null;
}; };
export const stopPipelinePolling = () => eTagPoll && eTagPoll.stop(); export const stopPipelinePolling = () => {
export const restartPipelinePolling = () => eTagPoll && eTagPoll.restart(); if (eTagPoll) eTagPoll.stop();
};
export const restartPipelinePolling = () => {
if (eTagPoll) eTagPoll.restart();
};
export const requestLatestPipeline = ({ commit }) => commit(types.REQUEST_LATEST_PIPELINE); export const requestLatestPipeline = ({ commit }) => commit(types.REQUEST_LATEST_PIPELINE);
export const receiveLatestPipelineError = ({ commit, dispatch }) => { export const receiveLatestPipelineError = ({ commit, dispatch }) => {
...@@ -51,9 +55,9 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => { ...@@ -51,9 +55,9 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => {
Visibility.change(() => { Visibility.change(() => {
if (!Visibility.hidden()) { if (!Visibility.hidden()) {
eTagPoll.restart(); dispatch('restartPipelinePolling');
} else { } else {
eTagPoll.stop(); dispatch('stopPipelinePolling');
} }
}); });
}; };
......
...@@ -45,12 +45,15 @@ describe('IDE pipelines list', () => { ...@@ -45,12 +45,15 @@ describe('IDE pipelines list', () => {
setTimeout(done); setTimeout(done);
}); });
afterEach(() => { afterEach(done => {
vm.$store.dispatch('pipelines/stopPipelinePolling');
vm.$store.dispatch('pipelines/clearEtagPoll');
vm.$destroy(); vm.$destroy();
mock.restore(); mock.restore();
vm.$store
.dispatch('pipelines/stopPipelinePolling')
.then(() => vm.$store.dispatch('pipelines/clearEtagPoll'))
.then(done)
.catch(done.fail);
}); });
it('renders pipeline data', () => { it('renders pipeline data', () => {
......
...@@ -199,28 +199,39 @@ describe('IDE merge requests actions', () => { ...@@ -199,28 +199,39 @@ describe('IDE merge requests actions', () => {
}); });
it('commits reset mutations and actions', done => { it('commits reset mutations and actions', done => {
testAction( const commit = jasmine.createSpy();
openMergeRequest, const dispatch = jasmine.createSpy().and.returnValue(Promise.resolve());
{ projectPath: 'gitlab-org/gitlab-ce', id: '1' }, openMergeRequest({ commit, dispatch }, { projectPath: 'gitlab-org/gitlab-ce', id: '1' });
mockedState,
[ setTimeout(() => {
{ type: 'CLEAR_PROJECTS' }, expect(commit.calls.argsFor(0)).toEqual(['CLEAR_PROJECTS', null, { root: true }]);
{ type: 'SET_CURRENT_MERGE_REQUEST', payload: '1' }, expect(commit.calls.argsFor(1)).toEqual(['SET_CURRENT_MERGE_REQUEST', '1', { root: true }]);
{ type: 'RESET_OPEN_FILES' }, expect(commit.calls.argsFor(2)).toEqual(['RESET_OPEN_FILES', null, { root: true }]);
],
[ expect(dispatch.calls.argsFor(0)).toEqual([
{ type: 'pipelines/stopPipelinePolling' }, 'pipelines/resetLatestPipeline',
{ type: 'pipelines/clearEtagPoll' }, null,
{ type: 'pipelines/resetLatestPipeline' }, { root: true },
{ type: 'setCurrentBranchId', payload: '' }, ]);
], expect(dispatch.calls.argsFor(1)).toEqual(['setCurrentBranchId', '', { root: true }]);
done, expect(dispatch.calls.argsFor(2)).toEqual([
); 'pipelines/stopPipelinePolling',
null,
{ root: true },
]);
expect(dispatch.calls.argsFor(3)).toEqual([
'pipelines/clearEtagPoll',
null,
{ root: true },
]);
done();
});
}); });
it('pushes new route', () => { it('pushes new route', () => {
openMergeRequest( openMergeRequest(
{ commit() {}, dispatch() {} }, { commit() {}, dispatch: () => Promise.resolve() },
{ projectPath: 'gitlab-org/gitlab-ce', id: '1' }, { projectPath: 'gitlab-org/gitlab-ce', id: '1' },
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment