@@ -50,74 +50,47 @@ function projectGroup(projects: Project[]) {
5050}
5151
5252describe ( "scopeProjectSettingsGroup" , ( ) => {
53- it ( "keeps the sidebar icon when the remote checkout was registered first" , ( ) => {
54- const group = projectGroup ( [
55- makeProject ( remoteEnvironmentId ) ,
56- makeProject ( localEnvironmentId , { projectIcon : customIcon } ) ,
57- ] ) ;
58- const scoped = scopeProjectSettingsGroup ( group , group . memberProjects ) ;
59-
60- expect ( scoped . environmentId ) . toBe ( localEnvironmentId ) ;
61- expect ( scoped . projectIcon ) . toEqual ( customIcon ) ;
62- expect ( scoped . memberProjects ) . toHaveLength ( 2 ) ;
63- expect ( scoped . memberProjects [ 0 ] ?. projectIcon ) . toBeNull ( ) ;
64- } ) ;
65-
66- it ( "keeps the favicon source and automatic title with the sidebar representative" , ( ) => {
67- const group = projectGroup ( [
68- makeProject ( remoteEnvironmentId , { title : "Remote repo" , faviconPath : "remote.svg" } ) ,
69- makeProject ( localEnvironmentId , { title : "Local repo" , faviconPath : "local.svg" } ) ,
70- ] ) ;
71- const scoped = scopeProjectSettingsGroup ( group , group . memberProjects ) ;
72-
73- expect ( scoped ) . toMatchObject ( {
74- environmentId : localEnvironmentId ,
75- workspaceRoot : "/local/repo" ,
53+ it ( "keeps the sidebar preview identity and edit targets when the remote checkout was registered first" , ( ) => {
54+ const local = makeProject ( localEnvironmentId , {
7655 title : "Local repo" ,
7756 faviconPath : "local.svg" ,
57+ projectIcon : customIcon ,
7858 } ) ;
79- } ) ;
80-
81- it ( "uses the selected environment when it excludes the sidebar representative" , ( ) => {
82- const group = projectGroup ( [
83- makeProject ( remoteEnvironmentId , { faviconPath : "remote.svg" } ) ,
84- makeProject ( localEnvironmentId , { projectIcon : customIcon } ) ,
85- ] ) ;
86- const members = group . memberProjects . filter (
87- ( member ) => member . environmentId === remoteEnvironmentId ,
88- ) ;
89- const scoped = scopeProjectSettingsGroup ( group , members ) ;
90-
91- expect ( scoped ) . toMatchObject ( {
92- environmentId : remoteEnvironmentId ,
93- id : "remote-project" ,
94- workspaceRoot : "/remote/repo" ,
59+ const remote = makeProject ( remoteEnvironmentId , {
60+ title : "Remote repo" ,
9561 faviconPath : "remote.svg" ,
96- projectIcon : null ,
9762 } ) ;
98- expect ( scoped . memberProjects ) . toHaveLength ( 1 ) ;
99- expect ( group . projectIcon ) . toEqual ( customIcon ) ;
63+ const group = projectGroup ( [ remote , local ] ) ;
64+ const scoped = scopeProjectSettingsGroup ( group , group . memberProjects ) ;
65+
66+ expect ( group ) . toMatchObject ( local ) ;
67+ expect ( scoped ) . toMatchObject ( local ) ;
68+ expect ( scoped . memberProjects ) . toBe ( group . memberProjects ) ;
69+ expect ( scoped . memberProjects ) . toMatchObject ( [ remote , local ] ) ;
10070 } ) ;
10171
102- it ( "uses the selected physical checkout among siblings on the same environment" , ( ) => {
103- const group = projectGroup ( [
104- makeProject ( localEnvironmentId , { projectIcon : customIcon } ) ,
105- makeProject ( localEnvironmentId , {
106- id : ProjectId . make ( "other-checkout" ) ,
107- workspaceRoot : "/local/other-repo" ,
108- projectIcon : { kind : "emoji" , emoji : "🐦" } ,
109- } ) ,
110- ] ) ;
111- const members = group . memberProjects . filter ( ( member ) => member . id === "other-checkout" ) ;
72+ it . each ( [
73+ [ remoteEnvironmentId , "local-project" ] ,
74+ [ localEnvironmentId , "other-checkout" ] ,
75+ ] ) ( "uses the complete selected checkout identity for %s/%s" , ( environmentId , id ) => {
76+ const local = makeProject ( localEnvironmentId , { projectIcon : customIcon } ) ;
77+ const selected = makeProject ( environmentId , {
78+ id : ProjectId . make ( id ) ,
79+ title : "Selected checkout" ,
80+ workspaceRoot : "/selected/repo" ,
81+ faviconPath : "selected.svg" ,
82+ projectIcon : null ,
83+ } ) ;
84+ const group = projectGroup ( [ local , selected ] ) ;
85+ const members = group . memberProjects . filter (
86+ ( member ) => member . environmentId === selected . environmentId && member . id === selected . id ,
87+ ) ;
11288 const scoped = scopeProjectSettingsGroup ( group , members ) ;
11389
114- expect ( scoped ) . toMatchObject ( {
115- environmentId : localEnvironmentId ,
116- id : "other-checkout" ,
117- workspaceRoot : "/local/other-repo" ,
118- projectIcon : { kind : "emoji" , emoji : "🐦" } ,
119- } ) ;
120- expect ( scoped . memberProjects ) . toHaveLength ( 1 ) ;
90+ expect ( scoped ) . toMatchObject ( selected ) ;
91+ expect ( scoped . memberProjects ) . toBe ( members ) ;
92+ expect ( scoped . memberProjects ) . toMatchObject ( [ selected ] ) ;
93+ expect ( group ) . toMatchObject ( local ) ;
12194 } ) ;
12295} ) ;
12396
0 commit comments