@@ -147,15 +147,41 @@ describe("buildProjectGroups", () => {
147147 ) ;
148148 } ) ;
149149
150- it ( "keeps the repository label when shared titles match its repository name" , ( ) => {
150+ it ( "keeps the shared title when it matches the repository name across machines " , ( ) => {
151151 const projects = [
152152 makeProject ( "first" , "/work/t3code" , { title : "t3code" } ) ,
153- makeProject ( "second" , "/work/t3code-2" , { title : "t3code" } ) ,
153+ makeProject ( "second" , "/work/t3code-2" , {
154+ title : "t3code" ,
155+ environmentId : EnvironmentId . make ( "remote" ) ,
156+ } ) ,
157+ ] ;
158+
159+ expect ( buildProjectGroups ( { projects, settings : settings ( "repository" ) } ) [ 0 ] ?. label ) . toBe (
160+ "t3code" ,
161+ ) ;
162+ } ) ;
163+
164+ it ( "falls back to the repository label until grouped project titles agree" , ( ) => {
165+ const projects = [
166+ makeProject ( "first" , "/work/t3code" , { title : "local-checkout" } ) ,
167+ makeProject ( "second" , "/work/t3code-2" , {
168+ title : "remote-checkout" ,
169+ environmentId : EnvironmentId . make ( "remote" ) ,
170+ } ) ,
154171 ] ;
155172
156173 expect ( buildProjectGroups ( { projects, settings : settings ( "repository" ) } ) [ 0 ] ?. label ) . toBe (
157174 "T3 Code" ,
158175 ) ;
176+
177+ const renamedProjects = projects . map ( ( project ) => ( { ...project , title : "t3code" } ) ) ;
178+ for ( const mode of [ "repository" , "repository_path" ] as const ) {
179+ const input = { projects : renamedProjects , settings : settings ( mode ) } ;
180+ expect ( buildProjectGroups ( input ) [ 0 ] ?. label ) . toBe ( "t3code" ) ;
181+ expect (
182+ buildProjectGroups ( { ...input , projects : renamedProjects . toReversed ( ) } ) [ 0 ] ?. label ,
183+ ) . toBe ( "t3code" ) ;
184+ }
159185 } ) ;
160186
161187 it ( "keeps physical clones in separate groups when requested" , ( ) => {
0 commit comments