@@ -54,8 +54,8 @@ class TestClientProvider {
5454
5555 @test
5656 public async getStartClusterSets ( ) {
57- await this . expectInstallations ( [ "a1" , " a2", "a3" ] , await this . provider . getStartClusterSets ( { } as User , { } as Workspace , { } as WorkspaceInstance ) , "default case" ) ;
58- this . expectInstallations ( [ "a1" , "a2" , "a3" , "con1" ] , await this . provider . getStartClusterSets ( {
57+ await this . expectInstallations ( [ [ " a2", "a3" ] ] , await this . provider . getStartClusterSets ( { } as User , { } as Workspace , { } as WorkspaceInstance ) , "default case" ) ;
58+ await this . expectInstallations ( [ [ "con1" ] , [ "a2" , "a3" ] ] , await this . provider . getStartClusterSets ( {
5959 rolesOrPermissions : [ "new-workspace-cluster" ]
6060 } as User , { } as Workspace , { } as WorkspaceInstance ) , "new workspace cluster" ) ;
6161 }
@@ -102,13 +102,27 @@ class TestClientProvider {
102102 expect ( constraintInverseMoreResources ( clusters , { getsMoreResources : true } as ExtendedUser , { } as Workspace , { } as WorkspaceInstance ) . map ( c => c . name ) , "inverse more resources" ) . to . be . eql ( [ "b1" ] ) ;
103103 }
104104
105- private async expectInstallations ( expected : string [ ] , actual : IWorkspaceClusterStartSet , msg : string ) {
105+ private async expectInstallations ( expectedSets : string [ ] [ ] , actual : IWorkspaceClusterStartSet , msg : string ) {
106106 const a : string [ ] = [ ] ;
107107 for await ( const c of actual ) {
108108 a . push ( c . installation ) ;
109109 }
110110
111- expect ( a . sort ( ) , msg ) . to . be . eql ( expected ) ;
111+ // we check:
112+ // - the order of returned sets
113+ // - identical content of said sets
114+ // - NOT the order of clusters within a set
115+ let i = 0 ;
116+ for ( ; i < expectedSets . length ; i ++ ) {
117+ const eSet = expectedSets [ i ] ;
118+ const aSet = a . splice ( 0 , eSet . length ) ;
119+ expect ( aSet . sort ( ) , `returned set does not match (${ msg } )` ) . to . be . eql ( eSet . sort ( ) ) ;
120+ }
121+
122+ const eOverage = expectedSets . slice ( i ) . reduce ( ( p , c ) => [ ...p , ...c ] , [ ] ) ;
123+ const aOverage = a ;
124+ expect ( eOverage , `missing some cluster(s)/sets (${ msg } )` ) . to . be . empty ;
125+ expect ( aOverage , `got too many cluster(s)/sets (${ msg } )` ) . to . be . empty ;
112126 }
113127
114128}
0 commit comments