Loading src/gitlab_service.ts +1 −1 Original line number Diff line number Diff line Loading @@ -444,7 +444,7 @@ export async function handlePipelineAction(action: string, repositoryRoot: strin } try { const { response } = await fetch(endpoint, 'POST'); const { response } = await fetch(repositoryRoot, endpoint, 'POST'); return response; } catch (e) { throw new UserFriendlyError(`Failed to ${action} pipeline.`, e); Loading test/integration/pipeline_actions.test.js 0 → 100644 +56 −0 Original line number Diff line number Diff line const assert = require('assert'); const sinon = require('sinon'); const { tokenService } = require('../../src/services/token_service'); const pipelinesResponse = require('./fixtures/rest/pipelines.json'); const { getServer, createTextEndpoint, createQueryJsonEndpoint, createPostEndpoint, } = require('./test_infrastructure/mock_server'); const { GITLAB_URL } = require('./test_infrastructure/constants'); const { simulateQuickPickChoice } = require('./test_infrastructure/helpers'); const { showPicker } = require('../../src/pipeline_actions_picker'); const { instance: statusbar } = require('../../src/status_bar'); describe('Pipeline actions', async () => { let server; let statusBarRefreshSpy; const sandbox = sinon.createSandbox(); before(async () => { server = getServer([ createQueryJsonEndpoint('/projects/278964/pipelines', { '?ref=master': pipelinesResponse }), createTextEndpoint( '/projects/278964/snippets/222/files/master/test2.js/raw', 'second blob content', ), createPostEndpoint('/projects/278964/pipeline', pipelinesResponse[0]), // simulating returning a newly created pipeline ]); await tokenService.setToken(GITLAB_URL, 'abcd-secret'); }); beforeEach(async () => { server.resetHandlers(); statusBarRefreshSpy = sandbox.spy(statusbar, 'refresh'); }); afterEach(async () => { sandbox.restore(); }); after(async () => { server.close(); await tokenService.setToken(GITLAB_URL, undefined); }); it('creates a new pipeline', async () => { simulateQuickPickChoice(sandbox, 1); // Create a new pipeline from current branch await showPicker(); assert( statusBarRefreshSpy.calledOnce, 'status bar is refreshed after successful pipeline creation', ); }); }); Loading
src/gitlab_service.ts +1 −1 Original line number Diff line number Diff line Loading @@ -444,7 +444,7 @@ export async function handlePipelineAction(action: string, repositoryRoot: strin } try { const { response } = await fetch(endpoint, 'POST'); const { response } = await fetch(repositoryRoot, endpoint, 'POST'); return response; } catch (e) { throw new UserFriendlyError(`Failed to ${action} pipeline.`, e); Loading
test/integration/pipeline_actions.test.js 0 → 100644 +56 −0 Original line number Diff line number Diff line const assert = require('assert'); const sinon = require('sinon'); const { tokenService } = require('../../src/services/token_service'); const pipelinesResponse = require('./fixtures/rest/pipelines.json'); const { getServer, createTextEndpoint, createQueryJsonEndpoint, createPostEndpoint, } = require('./test_infrastructure/mock_server'); const { GITLAB_URL } = require('./test_infrastructure/constants'); const { simulateQuickPickChoice } = require('./test_infrastructure/helpers'); const { showPicker } = require('../../src/pipeline_actions_picker'); const { instance: statusbar } = require('../../src/status_bar'); describe('Pipeline actions', async () => { let server; let statusBarRefreshSpy; const sandbox = sinon.createSandbox(); before(async () => { server = getServer([ createQueryJsonEndpoint('/projects/278964/pipelines', { '?ref=master': pipelinesResponse }), createTextEndpoint( '/projects/278964/snippets/222/files/master/test2.js/raw', 'second blob content', ), createPostEndpoint('/projects/278964/pipeline', pipelinesResponse[0]), // simulating returning a newly created pipeline ]); await tokenService.setToken(GITLAB_URL, 'abcd-secret'); }); beforeEach(async () => { server.resetHandlers(); statusBarRefreshSpy = sandbox.spy(statusbar, 'refresh'); }); afterEach(async () => { sandbox.restore(); }); after(async () => { server.close(); await tokenService.setToken(GITLAB_URL, undefined); }); it('creates a new pipeline', async () => { simulateQuickPickChoice(sandbox, 1); // Create a new pipeline from current branch await showPicker(); assert( statusBarRefreshSpy.calledOnce, 'status bar is refreshed after successful pipeline creation', ); }); });