@@ -767,12 +767,16 @@ describe('query-history', () => {
767767
768768 describe ( 'sorting' , ( ) => {
769769 const history = [
770- item ( 'a' , 2 , 'remote' , 24 ) ,
771- item ( 'b' , 10 , 'local' , 20 ) ,
772- item ( 'c' , 5 , 'local' , 30 ) ,
773- item ( 'd' , 1 , 'local' , 25 ) ,
774- item ( 'e' , 6 , 'remote' , 5 ) ,
770+ createMockRemoteQueryHistoryItem ( { userSpecifiedLabel : 'a' , executionStartTime : 2 , resultCount : 24 , status : QueryStatus . Completed } ) ,
771+ createMockLocalQueryInfo ( { userSpecifiedLabel : 'b' , startTime : new Date ( 10 ) , resultCount : 20 } ) ,
772+ createMockVariantAnalysisHistoryItem ( { userSpecifiedLabel : 'c' , executionStartTime : 15 , resultCount : 456 , historyItemStatus : QueryStatus . Completed , variantAnalysisStatus : VariantAnalysisStatus . Succeeded } ) ,
773+ createMockLocalQueryInfo ( { userSpecifiedLabel : 'd' , startTime : new Date ( 5 ) , resultCount : 30 } ) ,
774+ createMockVariantAnalysisHistoryItem ( { userSpecifiedLabel : 'e' , executionStartTime : 50 , resultCount : 15 , historyItemStatus : QueryStatus . InProgress , variantAnalysisStatus : VariantAnalysisStatus . InProgress } ) ,
775+ createMockLocalQueryInfo ( { userSpecifiedLabel : 'f' , startTime : new Date ( 1 ) , resultCount : 13 } ) ,
776+ createMockVariantAnalysisHistoryItem ( { userSpecifiedLabel : 'g' , executionStartTime : 7 , resultCount : 30 , historyItemStatus : QueryStatus . Failed , variantAnalysisStatus : VariantAnalysisStatus . Failed } ) ,
777+ createMockRemoteQueryHistoryItem ( { userSpecifiedLabel : 'h' , executionStartTime : 6 , resultCount : 5 , status : QueryStatus . InProgress } )
775778 ] ;
779+
776780 let treeDataProvider : HistoryTreeDataProvider ;
777781
778782 beforeEach ( async ( ) => {
@@ -798,51 +802,65 @@ describe('query-history', () => {
798802 } ) ;
799803
800804 it ( 'should get children for date ascending' , async ( ) => {
801- const expected = [ history [ 3 ] , history [ 0 ] , history [ 2 ] , history [ 4 ] , history [ 1 ] ] ;
805+ const expected = [ history [ 5 ] , history [ 0 ] , history [ 3 ] , history [ 7 ] , history [ 6 ] , history [ 1 ] , history [ 2 ] , history [ 4 ] ] ;
802806 treeDataProvider . sortOrder = SortOrder . DateAsc ;
803807
804808 const children = await treeDataProvider . getChildren ( ) ;
805809 expect ( children ) . to . deep . eq ( expected ) ;
806810 } ) ;
807811
808812 it ( 'should get children for date descending' , async ( ) => {
809- const expected = [ history [ 3 ] , history [ 0 ] , history [ 2 ] , history [ 4 ] , history [ 1 ] ] . reverse ( ) ;
813+ const expected = [ history [ 5 ] , history [ 0 ] , history [ 3 ] , history [ 7 ] , history [ 6 ] , history [ 1 ] , history [ 2 ] , history [ 4 ] ] . reverse ( ) ;
814+
810815 treeDataProvider . sortOrder = SortOrder . DateDesc ;
811816
812817 const children = await treeDataProvider . getChildren ( ) ;
813818 expect ( children ) . to . deep . eq ( expected ) ;
814819 } ) ;
815820
816821 it ( 'should get children for result count ascending' , async ( ) => {
817- const expected = [ history [ 4 ] , history [ 1 ] , history [ 0 ] , history [ 3 ] , history [ 2 ] ] ;
822+ const expected = [ history [ 7 ] , history [ 5 ] , history [ 4 ] , history [ 1 ] , history [ 0 ] , history [ 3 ] , history [ 6 ] , history [ 2 ] ] ;
818823 treeDataProvider . sortOrder = SortOrder . CountAsc ;
819824
820825 const children = await treeDataProvider . getChildren ( ) ;
826+
821827 expect ( children ) . to . deep . eq ( expected ) ;
822828 } ) ;
823829
824830 it ( 'should get children for result count descending' , async ( ) => {
825- const expected = [ history [ 4 ] , history [ 1 ] , history [ 0 ] , history [ 3 ] , history [ 2 ] ] . reverse ( ) ;
831+ const expected = [ history [ 7 ] , history [ 5 ] , history [ 4 ] , history [ 1 ] , history [ 0 ] , history [ 3 ] , history [ 6 ] , history [ 2 ] ] . reverse ( ) ;
826832 treeDataProvider . sortOrder = SortOrder . CountDesc ;
827833
828834 const children = await treeDataProvider . getChildren ( ) ;
829835 expect ( children ) . to . deep . eq ( expected ) ;
830836 } ) ;
831837
832- it ( 'should get children for result count ascending when there are no results' , async ( ) => {
833- // fall back to name
834- const thisHistory = [ item ( 'a' , 10 ) , item ( 'b' , 50 ) , item ( 'c' , 1 ) ] ;
838+ it ( 'should fall back to name ascending when there are no results' , async ( ) => {
839+ const thisHistory = [
840+ createMockLocalQueryInfo ( { userSpecifiedLabel : 'a' , resultCount : 0 , startTime : new Date ( 10 ) } ) ,
841+ createMockLocalQueryInfo ( { userSpecifiedLabel : 'b' , resultCount : 0 , startTime : new Date ( 1 ) } ) ,
842+ createMockVariantAnalysisHistoryItem ( { userSpecifiedLabel : 'c' , resultCount : 0 , historyItemStatus : QueryStatus . Completed , variantAnalysisStatus : VariantAnalysisStatus . Failed } ) ,
843+ createMockRemoteQueryHistoryItem ( { userSpecifiedLabel : 'd' , resultCount : 0 , executionStartTime : 50 , status : QueryStatus . Completed } ) ,
844+ createMockVariantAnalysisHistoryItem ( { userSpecifiedLabel : 'e' , resultCount : 0 , historyItemStatus : QueryStatus . InProgress , variantAnalysisStatus : VariantAnalysisStatus . Failed } ) ,
845+ ] ;
835846 ( queryHistoryManager ! . treeDataProvider as any ) . history = [ ...thisHistory ] ;
836847 const expected = [ ...thisHistory ] ;
848+
837849 treeDataProvider . sortOrder = SortOrder . CountAsc ;
838850
839851 const children = await treeDataProvider . getChildren ( ) ;
852+
840853 expect ( children ) . to . deep . eq ( expected ) ;
841854 } ) ;
842855
843- it ( 'should get children for result count descending when there are no results' , async ( ) => {
844- // fall back to name
845- const thisHistory = [ item ( 'a' , 10 ) , item ( 'b' , 50 ) , item ( 'c' , 1 ) ] ;
856+ it ( 'should fall back to name descending when there are no results' , async ( ) => {
857+ const thisHistory = [
858+ createMockLocalQueryInfo ( { userSpecifiedLabel : 'a' , resultCount : 0 , startTime : new Date ( 10 ) } ) ,
859+ createMockLocalQueryInfo ( { userSpecifiedLabel : 'b' , resultCount : 0 , startTime : new Date ( 1 ) } ) ,
860+ createMockVariantAnalysisHistoryItem ( { userSpecifiedLabel : 'c' , resultCount : 0 , historyItemStatus : QueryStatus . Completed , variantAnalysisStatus : VariantAnalysisStatus . Failed } ) ,
861+ createMockRemoteQueryHistoryItem ( { userSpecifiedLabel : 'd' , resultCount : 0 , executionStartTime : 50 , status : QueryStatus . Completed } ) ,
862+ createMockVariantAnalysisHistoryItem ( { userSpecifiedLabel : 'e' , resultCount : 0 , historyItemStatus : QueryStatus . InProgress , variantAnalysisStatus : VariantAnalysisStatus . Failed } ) ,
863+ ] ;
846864 ( queryHistoryManager ! . treeDataProvider as any ) . history = [ ...thisHistory ] ;
847865 const expected = [ ...thisHistory ] . reverse ( ) ;
848866 treeDataProvider . sortOrder = SortOrder . CountDesc ;
0 commit comments