@@ -37,7 +37,15 @@ export async function setupHistoryExplorerController() {
3737 replaceRootItems ( historyBrowserController ) ;
3838 }
3939 }
40- historyBrowserController . items . replace ( [ historyBrowserController . createTestItem ( '-' , 'loading...' ) ] ) ;
40+
41+ const refresh = ( token ?: vscode . CancellationToken ) => {
42+ historyBrowserController . items . replace ( [ historyBrowserController . createTestItem ( '-' , 'loading...' ) ] ) ;
43+ replaceRootItems ( historyBrowserController ) ;
44+ }
45+ refresh ( ) ;
46+
47+ // Add a manual Refresh button
48+ historyBrowserController . refreshHandler = refresh ;
4149
4250}
4351
@@ -54,7 +62,7 @@ async function addTestInstances(item: vscode.TestItem, controller: vscode.TestCo
5462 "POST" ,
5563 spec ,
5664 { apiVersion : 1 , namespace, path : "/action/query" } ,
57- { query : "SELECT InstanceIndex, DateTime, Duration FROM %UnitTest_Result.TestInstance" } ,
65+ { query : "SELECT TOP 10 InstanceIndex, DateTime, Duration FROM %UnitTest_Result.TestInstance ORDER BY DateTime DESC " } ,
5866 ) ;
5967 if ( response ) {
6068 const portalUri = vscode . Uri . from ( {
@@ -68,6 +76,7 @@ async function addTestInstances(item: vscode.TestItem, controller: vscode.TestCo
6876 `${ element . DateTime } ` ,
6977 portalUri . with ( { query : `Index=${ element . InstanceIndex } &$NAMESPACE=${ namespace } ` } )
7078 ) ;
79+ child . sortText = ( 1e12 - element . InstanceIndex ) . toString ( ) . padStart ( 12 , "0" ) ;
7180 child . description = `run ${ element . InstanceIndex } ` ;
7281 child . canResolveChildren = true ;
7382 item . children . add ( child ) ;
@@ -209,8 +218,8 @@ async function addTestAsserts(item: vscode.TestItem, controller: vscode.TestCont
209218 }
210219
211220 response ?. data ?. result ?. content ?. forEach ( element => {
212- // Prefix the label with an underscore-padded integer to preserve order
213- const child = controller . createTestItem ( `${ item . id } : ${ element . ID } ` , ` ${ element . Counter . toString ( ) . padStart ( element . MaxCounter . toString ( ) . length , "_ " ) } . ${ element . Action } ` ) ;
221+ const child = controller . createTestItem ( ` ${ item . id } : ${ element . ID } ` , ` ${ element . Action } ` ) ;
222+ child . sortText = `${ element . Counter . toString ( ) . padStart ( element . MaxCounter . toString ( ) . length , "0 " ) } ` ;
214223 child . description = element . Description ;
215224 child . canResolveChildren = false ;
216225 item . children . add ( child ) ;
@@ -246,3 +255,11 @@ export function replaceRootItems(controller: vscode.TestController) {
246255 rootMap . forEach ( item => rootItems . push ( item ) ) ;
247256 controller . items . replace ( rootItems ) ;
248257}
258+
259+ export function refreshHistoryRootItem ( serverName : string , namespace : string ) {
260+ const item = historyBrowserController . items . get ( serverName + ":" + namespace ) ;
261+ if ( item ) {
262+ item . children . replace ( [ ] ) ;
263+ addTestInstances ( item , historyBrowserController ) ;
264+ }
265+ }
0 commit comments