@@ -110,7 +110,7 @@ test('runLogin uses cloud SDK auth, mints a workspace token, and stores it', asy
110110 }
111111} ) ;
112112
113- test ( 'runLogout clears cloud auth and workspace token even when a workspace is passed ' , async ( ) => {
113+ test ( 'runLogout preserves shared cloud auth and clears only the workspace token by default ' , async ( ) => {
114114 const calls : string [ ] = [ ] ;
115115 const restoreDeps = configureDeployCommandForTest ( {
116116 clearStoredAuth : async ( ) => {
@@ -124,6 +124,28 @@ test('runLogout clears cloud auth and workspace token even when a workspace is p
124124 try {
125125 await runLogout ( [ '--workspace' , 'acme' ] ) ;
126126 assert . deepEqual ( trap . exits , [ 0 ] ) ;
127+ assert . deepEqual ( calls , [ 'clear-workspace:acme' ] ) ;
128+ assert . match ( trap . stdout , / w o r k s p a c e l o g i n c l e a r e d / ) ;
129+ } finally {
130+ trap . restore ( ) ;
131+ restoreDeps ( ) ;
132+ }
133+ } ) ;
134+
135+ test ( 'runLogout clears shared cloud auth when explicitly requested' , async ( ) => {
136+ const calls : string [ ] = [ ] ;
137+ const restoreDeps = configureDeployCommandForTest ( {
138+ clearStoredAuth : async ( ) => {
139+ calls . push ( 'clear-auth' ) ;
140+ } ,
141+ clearStoredWorkspaceToken : async ( workspace ?: string ) => {
142+ calls . push ( `clear-workspace:${ workspace ?? '' } ` ) ;
143+ }
144+ } ) ;
145+ const trap = trapExit ( false ) ;
146+ try {
147+ await runLogout ( [ '--workspace' , 'acme' , '--cloud-auth' ] ) ;
148+ assert . deepEqual ( trap . exits , [ 0 ] ) ;
127149 assert . deepEqual ( calls , [ 'clear-auth' , 'clear-workspace:acme' ] ) ;
128150 assert . match ( trap . stdout , / l o g g e d o u t / ) ;
129151 } finally {
@@ -132,6 +154,28 @@ test('runLogout clears cloud auth and workspace token even when a workspace is p
132154 }
133155} ) ;
134156
157+ test ( 'runLogout treats --all as an alias for clearing shared cloud auth' , async ( ) => {
158+ const calls : string [ ] = [ ] ;
159+ const restoreDeps = configureDeployCommandForTest ( {
160+ clearStoredAuth : async ( ) => {
161+ calls . push ( 'clear-auth' ) ;
162+ } ,
163+ clearStoredWorkspaceToken : async ( workspace ?: string ) => {
164+ calls . push ( `clear-workspace:${ workspace ?? '' } ` ) ;
165+ }
166+ } ) ;
167+ const trap = trapExit ( false ) ;
168+ try {
169+ await runLogout ( [ '--all' ] ) ;
170+ assert . deepEqual ( trap . exits , [ 0 ] ) ;
171+ assert . deepEqual ( calls , [ 'clear-auth' , 'clear-workspace:' ] ) ;
172+ assert . match ( trap . stdout , / l o g g e d o u t / ) ;
173+ } finally {
174+ trap . restore ( ) ;
175+ restoreDeps ( ) ;
176+ }
177+ } ) ;
178+
135179test ( 'parseDeployArgs: single --input parses and forwards' , ( ) => {
136180 const parsed = parseDeployArgs ( [ './persona.json' , '--input' , 'TOPIC=Deploy v1' ] ) ;
137181
0 commit comments