@@ -3,28 +3,18 @@ import * as path from 'path';
33import * as sinon from 'sinon' ;
44
55import { commands , extensions , TextDocument , window , workspace } from 'vscode' ;
6- import { setupServer } from 'msw/node' ;
76import * as Octokit from '@octokit/rest' ;
87import { retry } from '@octokit/plugin-retry' ;
98
109import { CodeQLExtensionInterface } from '../../../extension' ;
11- import { createRequestHandlers } from '../../../mocks/request-handlers' ;
1210import * as config from '../../../config' ;
1311import { Credentials } from '../../../authentication' ;
12+ import { MockGitHubApiServer } from '../../../mocks/mock-gh-api-server' ;
1413
15- const server = setupServer ( ) ;
16-
17- before ( ( ) => server . listen ( ) ) ;
18-
19- afterEach ( ( ) => server . resetHandlers ( ) ) ;
20-
21- after ( ( ) => server . close ( ) ) ;
22-
23- async function loadScenario ( scenarioName : string ) {
24- const handlers = await createRequestHandlers ( path . join ( __dirname , '../../../../src/mocks/scenarios' , scenarioName ) ) ;
25-
26- server . use ( ...handlers ) ;
27- }
14+ const mockServer = new MockGitHubApiServer ( ) ;
15+ before ( ( ) => mockServer . startServer ( ) ) ;
16+ afterEach ( ( ) => mockServer . unloadScenario ( ) ) ;
17+ after ( ( ) => mockServer . stopServer ( ) ) ;
2818
2919async function showQlDocument ( name : string ) : Promise < TextDocument > {
3020 const folderPath = workspace . workspaceFolders ! [ 0 ] . uri . fsPath ;
@@ -34,7 +24,7 @@ async function showQlDocument(name: string): Promise<TextDocument> {
3424 return document ;
3525}
3626
37- describe ( 'Variant Analysis Integration' , function ( ) {
27+ describe ( 'Variant Analysis Submission Integration' , function ( ) {
3828 this . timeout ( 10_000 ) ;
3929
4030 let sandbox : sinon . SinonSandbox ;
@@ -75,7 +65,7 @@ describe('Variant Analysis Integration', function() {
7565
7666 describe ( 'Successful scenario' , ( ) => {
7767 beforeEach ( async ( ) => {
78- await loadScenario ( 'problem-query-success' ) ;
68+ await mockServer . loadScenario ( 'problem-query-success' ) ;
7969 } ) ;
8070
8171 it ( 'opens the variant analysis view' , async ( ) => {
@@ -98,7 +88,7 @@ describe('Variant Analysis Integration', function() {
9888
9989 describe ( 'Missing controller repo' , ( ) => {
10090 beforeEach ( async ( ) => {
101- await loadScenario ( 'missing-controller-repo' ) ;
91+ await mockServer . loadScenario ( 'missing-controller-repo' ) ;
10292 } ) ;
10393
10494 it ( 'shows the error message' , async ( ) => {
@@ -119,7 +109,7 @@ describe('Variant Analysis Integration', function() {
119109
120110 describe ( 'Submission failure' , ( ) => {
121111 beforeEach ( async ( ) => {
122- await loadScenario ( 'submission-failure' ) ;
112+ await mockServer . loadScenario ( 'submission-failure' ) ;
123113 } ) ;
124114
125115 it ( 'shows the error message' , async ( ) => {
0 commit comments