88 deriveLogicalProjectKeyFromSettings ,
99 pickableProjectGroups ,
1010 derivePhysicalProjectKey ,
11+ deriveScopedProjectGroupLabel ,
1112 resolveScratchProjectScopeKey ,
1213 sortProjectsByGroupOrder ,
1314 type ProjectGroupingSettings ,
@@ -346,6 +347,7 @@ describe("buildProjectGroups", () => {
346347 } ) ;
347348 expect ( unlabeled . map ( ( group ) => group . label ) ) . toEqual ( [ "EtanHey/orchestrator" ] ) ;
348349 expect ( groups . map ( ( group ) => group . label ) ) . toEqual ( [ label ] ) ;
350+ expect ( deriveScopedProjectGroupLabel ( groups [ 0 ] ! , [ projects [ 0 ] ! ] ) ) . toBe ( label ) ;
349351 expect ( groups . map ( ( { key, memberProjectRefs } ) => ( { key, memberProjectRefs } ) ) ) . toEqual (
350352 unlabeled . map ( ( { key, memberProjectRefs } ) => ( { key, memberProjectRefs } ) ) ,
351353 ) ;
@@ -356,17 +358,32 @@ describe("buildProjectGroups", () => {
356358 [ environmentId ] : account ( "EtanHey" ) ,
357359 [ macB ] : account ( "EtanHey" ) ,
358360 } ;
359- const labels = ( projects : EnvironmentProject [ ] ) =>
360- buildProjectGroups ( { projects, settings : settings ( "repository" ) , repositoryAccounts } ) . map (
361- ( group ) => group . label ,
362- ) ;
363- expect ( labels ( linked ( "Orchestrator app" ) ) ) . toEqual ( [ "Orchestrator app" ] ) ;
364- expect (
365- labels ( [
366- ...linked ( ) ,
367- makeProject ( "other" , "/a/other" , { title : "Orchestrator" , repositoryIdentity : null } ) ,
368- ] ) ,
369- ) . toEqual ( [ "EtanHey/orchestrator" , "Orchestrator" ] ) ;
361+ const groups = ( projects : EnvironmentProject [ ] ) =>
362+ buildProjectGroups ( { projects, settings : settings ( "repository" ) , repositoryAccounts } ) ;
363+ expect ( groups ( linked ( "Orchestrator app" ) ) . map ( ( group ) => group . label ) ) . toEqual ( [
364+ "Orchestrator app" ,
365+ ] ) ;
366+ const differentlyNamed = linked ( ) . map ( ( project , index ) => ( {
367+ ...project ,
368+ title : index === 0 ? "Local project" : "Remote project" ,
369+ } ) ) ;
370+ const namedGroup = groups ( differentlyNamed ) [ 0 ] ! ;
371+ expect ( deriveScopedProjectGroupLabel ( namedGroup , differentlyNamed ) ) . toBe ( namedGroup . label ) ;
372+ for ( const project of differentlyNamed ) {
373+ expect ( deriveScopedProjectGroupLabel ( namedGroup , [ project ] ) ) . toBe ( project . title ) ;
374+ }
375+ const collisionProjects = linked ( ) ;
376+ const colliding = groups ( [
377+ ...collisionProjects ,
378+ makeProject ( "other" , "/a/other" , { title : "Orchestrator" , repositoryIdentity : null } ) ,
379+ ] ) ;
380+ expect ( colliding . map ( ( group ) => group . label ) ) . toEqual ( [
381+ "EtanHey/orchestrator" ,
382+ "Orchestrator" ,
383+ ] ) ;
384+ expect ( deriveScopedProjectGroupLabel ( colliding [ 0 ] ! , [ collisionProjects [ 0 ] ! ] ) ) . toBe (
385+ "EtanHey/orchestrator" ,
386+ ) ;
370387 } ) ;
371388
372389 it . each ( [
0 commit comments