@@ -3,6 +3,8 @@ import { expect } from 'chai';
33import * as Octokit from '@octokit/rest' ;
44import { retry } from '@octokit/plugin-retry' ;
55
6+ import { faker } from '@faker-js/faker' ;
7+
68import {
79 getRepositoryFromNwo ,
810 getVariantAnalysis ,
@@ -15,6 +17,10 @@ import {
1517} from '../../../../src/vscode-tests/factories/remote-queries/shared/variant-analysis-submission' ;
1618import { MockGitHubApiServer } from '../../../../src/mocks/mock-gh-api-server' ;
1719
20+ import * as getRepoJson from '../../../../src/mocks/scenarios/problem-query-success/0-getRepo.json' ;
21+ import * as variantAnalysisJson from '../../../../src/mocks/scenarios/problem-query-success/1-submitVariantAnalysis.json' ;
22+ import * as variantAnalysisRepoJson from '../../../../src/mocks/scenarios/problem-query-success/9-getVariantAnalysisRepo.json' ;
23+
1824const mockCredentials = {
1925 getOctokit : ( ) => Promise . resolve ( new Octokit . Octokit ( { retry } ) )
2026} as unknown as Credentials ;
@@ -24,22 +30,26 @@ before(() => mockServer.startServer());
2430afterEach ( ( ) => mockServer . unloadScenario ( ) ) ;
2531after ( ( ) => mockServer . stopServer ( ) ) ;
2632
33+ const controllerRepoId = variantAnalysisJson . response . body . controller_repo . id ;
34+ const variantAnalysisId = variantAnalysisJson . response . body . id ;
35+ const repoTaskId = variantAnalysisRepoJson . response . body . repository . id ;
36+
2737describe ( 'submitVariantAnalysis' , ( ) => {
2838 it ( 'returns the submitted variant analysis' , async ( ) => {
2939 await mockServer . loadScenario ( 'problem-query-success' ) ;
3040
3141 const result = await submitVariantAnalysis ( mockCredentials , createMockSubmission ( ) ) ;
3242
3343 expect ( result ) . not . to . be . undefined ;
34- expect ( result . id ) . to . eq ( 146 ) ;
44+ expect ( result . id ) . to . eq ( variantAnalysisId ) ;
3545 } ) ;
3646} ) ;
3747
3848describe ( 'getVariantAnalysis' , ( ) => {
3949 it ( 'returns the variant analysis' , async ( ) => {
4050 await mockServer . loadScenario ( 'problem-query-success' ) ;
4151
42- const result = await getVariantAnalysis ( mockCredentials , 557804416 , 146 ) ;
52+ const result = await getVariantAnalysis ( mockCredentials , controllerRepoId , variantAnalysisId ) ;
4353
4454 expect ( result ) . not . to . be . undefined ;
4555 expect ( result . status ) . not . to . be . undefined ;
@@ -50,22 +60,22 @@ describe('getVariantAnalysisRepo', () => {
5060 it ( 'returns the variant analysis repo task' , async ( ) => {
5161 await mockServer . loadScenario ( 'problem-query-success' ) ;
5262
53- const result = await getVariantAnalysisRepo ( mockCredentials , 557804416 , 146 , 206444 ) ;
63+ const result = await getVariantAnalysisRepo ( mockCredentials , controllerRepoId , variantAnalysisId , repoTaskId ) ;
5464
5565 expect ( result ) . not . to . be . undefined ;
56- expect ( result . repository . id ) . to . eq ( 206444 ) ;
66+ expect ( result . repository . id ) . to . eq ( repoTaskId ) ;
5767 } ) ;
5868} ) ;
5969
6070describe ( 'getVariantAnalysisRepoResult' , ( ) => {
6171 it ( 'returns the variant analysis repo result' , async ( ) => {
6272 await mockServer . loadScenario ( 'problem-query-success' ) ;
6373
64- const result = await getVariantAnalysisRepoResult ( mockCredentials , ' https://objects-origin.githubusercontent.com/codeql-query-console/codeql-variant-analysis-repo-tasks/146/206444/f6752c5c-ad60-46ba-b8dc-977546108458' ) ;
74+ const result = await getVariantAnalysisRepoResult ( mockCredentials , ` https://objects-origin.githubusercontent.com/codeql-query-console/codeql-variant-analysis-repo-tasks/${ variantAnalysisId } / ${ repoTaskId } / ${ faker . datatype . uuid ( ) } ` ) ;
6575
6676 expect ( result ) . not . to . be . undefined ;
6777 expect ( result ) . to . be . an ( 'ArrayBuffer' ) ;
68- expect ( result . byteLength ) . to . eq ( 81841 ) ;
78+ expect ( result . byteLength ) . to . eq ( variantAnalysisRepoJson . response . body . artifact_size_in_bytes ) ;
6979 } ) ;
7080} ) ;
7181
@@ -76,6 +86,6 @@ describe('getRepositoryFromNwo', () => {
7686 const result = await getRepositoryFromNwo ( mockCredentials , 'github' , 'mrva-demo-controller-repo' ) ;
7787
7888 expect ( result ) . not . to . be . undefined ;
79- expect ( result . id ) . to . eq ( 557804416 ) ;
89+ expect ( result . id ) . to . eq ( getRepoJson . response . body . id ) ;
8090 } ) ;
8191} ) ;
0 commit comments