@@ -21,13 +21,17 @@ import { EvalLogViewer } from '../../eval-log-viewer';
2121import { QueryRunner } from '../../queryRunner' ;
2222import { VariantAnalysisManager } from '../../remote-queries/variant-analysis-manager' ;
2323import { QueryHistoryInfo } from '../../query-history-info' ;
24- import { createMockLocalQuery , createMockQueryWithResults } from '../factories/local-queries/local-query-history-item' ;
24+ import {
25+ createMockLocalQueryInfo ,
26+ createMockQueryWithResults
27+ } from '../factories/local-queries/local-query-history-item' ;
2528import { createMockRemoteQueryHistoryItem } from '../factories/remote-queries/remote-query-history-item' ;
2629import { RemoteQueryHistoryItem } from '../../remote-queries/remote-query-history-item' ;
2730import { shuffleHistoryItems } from '../utils/query-history-helpers' ;
2831import { createMockVariantAnalysisHistoryItem } from '../factories/remote-queries/variant-analysis-history-item' ;
2932import { VariantAnalysisHistoryItem } from '../../remote-queries/variant-analysis-history-item' ;
3033import { QueryStatus } from '../../query-status' ;
34+ import { VariantAnalysisStatus } from '../../remote-queries/shared/variant-analysis' ;
3135
3236describe ( 'query-history' , ( ) => {
3337 const mockExtensionLocation = path . join ( tmpDir . name , 'mock-extension-location' ) ;
@@ -88,10 +92,10 @@ describe('query-history', () => {
8892 } as any as VariantAnalysisManager ;
8993
9094 localQueryHistory = [
91- createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , true ) ) ,
92- createMockLocalQuery ( 'b' , createMockQueryWithResults ( sandbox , true ) ) ,
93- createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , false ) ) ,
94- createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , true ) ) ,
95+ createMockLocalQueryInfo ( { dbName : 'a' , queryWithResults : createMockQueryWithResults ( { sandbox, didRunSuccessfully : true } ) } ) ,
96+ createMockLocalQueryInfo ( { dbName : 'b' , queryWithResults : createMockQueryWithResults ( { sandbox, didRunSuccessfully : true } ) } ) ,
97+ createMockLocalQueryInfo ( { dbName : 'a' , queryWithResults : createMockQueryWithResults ( { sandbox, didRunSuccessfully : false } ) } ) ,
98+ createMockLocalQueryInfo ( { dbName : 'a' , queryWithResults : createMockQueryWithResults ( { sandbox, didRunSuccessfully : true } ) } ) ,
9599 ] ;
96100 remoteQueryHistory = [
97101 createMockRemoteQueryHistoryItem ( { status : QueryStatus . Completed } ) ,
@@ -100,13 +104,24 @@ describe('query-history', () => {
100104 createMockRemoteQueryHistoryItem ( { status : QueryStatus . InProgress } )
101105 ] ;
102106 variantAnalysisHistory = [
103- createMockVariantAnalysisHistoryItem ( QueryStatus . Completed ) ,
104- createMockVariantAnalysisHistoryItem ( QueryStatus . InProgress ) ,
105- createMockVariantAnalysisHistoryItem ( QueryStatus . Failed ) ,
106- createMockVariantAnalysisHistoryItem ( QueryStatus . InProgress )
107+ createMockVariantAnalysisHistoryItem ( {
108+ historyItemStatus : QueryStatus . Completed ,
109+ variantAnalysisStatus : VariantAnalysisStatus . Succeeded
110+ } ) ,
111+ createMockVariantAnalysisHistoryItem ( {
112+ historyItemStatus : QueryStatus . InProgress ,
113+ variantAnalysisStatus : VariantAnalysisStatus . InProgress
114+ } ) ,
115+ createMockVariantAnalysisHistoryItem ( {
116+ historyItemStatus : QueryStatus . Failed ,
117+ variantAnalysisStatus : VariantAnalysisStatus . Failed
118+ } ) ,
119+ createMockVariantAnalysisHistoryItem ( {
120+ historyItemStatus : QueryStatus . InProgress ,
121+ variantAnalysisStatus : VariantAnalysisStatus . InProgress
122+ } )
107123 ] ;
108124 allHistory = shuffleHistoryItems ( [ ...localQueryHistory , ...remoteQueryHistory , ...variantAnalysisHistory ] ) ;
109-
110125 } ) ;
111126
112127 afterEach ( async ( ) => {
@@ -415,7 +430,7 @@ describe('query-history', () => {
415430 it ( 'should throw an error when a query is not successful' , async ( ) => {
416431 const thisQuery = localQueryHistory [ 3 ] ;
417432 queryHistoryManager = await createMockQueryHistory ( allHistory ) ;
418- allHistory [ 0 ] = createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , false ) ) ;
433+ allHistory [ 0 ] = createMockLocalQueryInfo ( { dbName : 'a' , queryWithResults : createMockQueryWithResults ( { sandbox, didRunSuccessfully : false } ) } ) ;
419434
420435 try {
421436 await ( queryHistoryManager as any ) . findOtherQueryToCompare ( thisQuery , [ thisQuery , allHistory [ 0 ] ] ) ;
@@ -696,40 +711,45 @@ describe('query-history', () => {
696711
697712 describe ( 'getTreeItem' , async ( ) => {
698713 it ( 'should get a tree item with raw results' , async ( ) => {
699- const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , true , /* raw results */ false ) ) ;
700- const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
714+ const mockQueryWithRawResults = createMockLocalQueryInfo ( { dbName : 'a' , queryWithResults : createMockQueryWithResults ( { sandbox, didRunSuccessfully : true , hasInterpretedResults : false } ) } ) ;
715+
716+ const treeItem = await historyTreeDataProvider . getTreeItem ( mockQueryWithRawResults ) ;
701717 expect ( treeItem . command ) . to . deep . eq ( {
702718 title : 'Query History Item' ,
703719 command : 'codeQLQueryHistory.itemClicked' ,
704- arguments : [ mockQuery ] ,
705- tooltip : labelProvider . getLabel ( mockQuery ) ,
720+ arguments : [ mockQueryWithRawResults ] ,
721+ tooltip : labelProvider . getLabel ( mockQueryWithRawResults ) ,
706722 } ) ;
707- expect ( treeItem . label ) . to . contain ( 'hucairz ' ) ;
723+ expect ( treeItem . label ) . to . contain ( 'query-file.ql ' ) ;
708724 expect ( treeItem . contextValue ) . to . eq ( 'rawResultsItem' ) ;
709725 expect ( treeItem . iconPath ) . to . deep . eq ( vscode . Uri . file ( mockExtensionLocation + '/media/drive.svg' ) . fsPath ) ;
710726 } ) ;
711727
712728 it ( 'should get a tree item with interpreted results' , async ( ) => {
713- const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , true , /* interpreted results */ true ) ) ;
714- const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
729+ const mockQueryWithInterpretedResults = createMockLocalQueryInfo ( { dbName : 'a' , queryWithResults : createMockQueryWithResults ( { sandbox, didRunSuccessfully : true , hasInterpretedResults : true } ) } ) ;
730+
731+ const treeItem = await historyTreeDataProvider . getTreeItem ( mockQueryWithInterpretedResults ) ;
715732 expect ( treeItem . contextValue ) . to . eq ( 'interpretedResultsItem' ) ;
716733 expect ( treeItem . iconPath ) . to . deep . eq ( vscode . Uri . file ( mockExtensionLocation + '/media/drive.svg' ) . fsPath ) ;
717734 } ) ;
718735
719736 it ( 'should get a tree item that did not complete successfully' , async ( ) => {
720- const mockQuery = createMockLocalQuery ( 'a' , createMockQueryWithResults ( sandbox , false ) , false ) ;
737+ const mockQuery = createMockLocalQueryInfo ( { dbName : 'a' , failureReason : 'failure reason' , queryWithResults : createMockQueryWithResults ( { sandbox, didRunSuccessfully : false } ) } ) ;
738+
721739 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
722740 expect ( treeItem . iconPath ) . to . eq ( vscode . Uri . file ( mockExtensionLocation + '/media/red-x.svg' ) . fsPath ) ;
723741 } ) ;
724742
725743 it ( 'should get a tree item that failed before creating any results' , async ( ) => {
726- const mockQuery = createMockLocalQuery ( 'a' , undefined , true ) ;
744+ const mockQuery = createMockLocalQueryInfo ( { dbName : 'a' , failureReason : 'failure reason' } ) ;
745+
727746 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
728747 expect ( treeItem . iconPath ) . to . eq ( vscode . Uri . file ( mockExtensionLocation + '/media/red-x.svg' ) . fsPath ) ;
729748 } ) ;
730749
731750 it ( 'should get a tree item that is in progress' , async ( ) => {
732- const mockQuery = createMockLocalQuery ( 'a' ) ;
751+ const mockQuery = createMockLocalQueryInfo ( { dbName : 'a' } ) ;
752+
733753 const treeItem = await historyTreeDataProvider . getTreeItem ( mockQuery ) ;
734754 expect ( treeItem . iconPath ) . to . deep . eq ( {
735755 id : 'sync~spin' , color : undefined
@@ -739,7 +759,7 @@ describe('query-history', () => {
739759
740760 describe ( 'getChildren' , ( ) => {
741761 it ( 'fetch children correctly' , ( ) => {
742- const mockQuery = createMockLocalQuery ( ) ;
762+ const mockQuery = createMockLocalQueryInfo ( { } ) ;
743763 historyTreeDataProvider . allHistory . push ( mockQuery ) ;
744764 expect ( historyTreeDataProvider . getChildren ( ) ) . to . deep . eq ( [ mockQuery ] ) ;
745765 expect ( historyTreeDataProvider . getChildren ( mockQuery ) ) . to . deep . eq ( [ ] ) ;
0 commit comments