@@ -418,6 +418,129 @@ test('Local workspace can be renamed from Workspaces drawer', async ({ page }) =
418418 . toBe ( renamedTitle )
419419} )
420420
421+ test ( 'Active Local non-PR workspace can be renamed from Workspaces drawer' , async ( {
422+ page,
423+ } ) => {
424+ const activeWorkspaceId = 'active_local_workspace_rename_allowed'
425+ const originalTitle = 'Active local rename original title'
426+ const renamedTitle = 'Active local rename updated title'
427+
428+ await waitForAppReady ( page )
429+
430+ await seedLocalWorkspaceContexts ( page , [
431+ {
432+ id : activeWorkspaceId ,
433+ repo : '' ,
434+ workspaceScope : 'local' ,
435+ head : 'feat/active-local-rename-allowed' ,
436+ prTitle : originalTitle ,
437+ prContextState : 'inactive' ,
438+ prNumber : null ,
439+ tabs : [
440+ {
441+ id : 'component' ,
442+ path : 'src/component.tsx' ,
443+ language : 'tsx' ,
444+ role : 'component' ,
445+ content : 'export const App = () => <main>active local rename allowed</main>' ,
446+ order : 0 ,
447+ source : 'workspace' ,
448+ dirty : false ,
449+ } ,
450+ ] ,
451+ activeTabId : 'component' ,
452+ } ,
453+ ] )
454+
455+ await page . reload ( )
456+ await waitForAppReady ( page )
457+
458+ const workspacesToggle = page . getByRole ( 'button' , {
459+ name : 'Workspaces' ,
460+ exact : true ,
461+ } )
462+ await workspacesToggle . click ( )
463+
464+ const workspaceSelect = page . getByLabel ( 'Stored workspace' )
465+ const renameButton = page . getByRole ( 'button' , { name : 'Rename' , exact : true } )
466+ await expect ( renameButton ) . toBeVisible ( )
467+
468+ await expect ( workspaceSelect ) . toHaveValue ( activeWorkspaceId )
469+ await expect ( renameButton ) . toBeEnabled ( )
470+
471+ page . once ( 'dialog' , async dialog => {
472+ expect ( dialog . type ( ) ) . toBe ( 'prompt' )
473+ expect ( dialog . defaultValue ( ) ) . toBe ( originalTitle )
474+ await dialog . accept ( renamedTitle )
475+ } )
476+
477+ await renameButton . click ( )
478+ await expect ( page . locator ( '#workspaces-status' ) ) . toContainText ( 'Renamed workspace.' )
479+
480+ const records = await getAllWorkspaceRecords ( page )
481+ const renamedRecord = records . find ( record => record ?. id === activeWorkspaceId )
482+
483+ expect ( renamedRecord ) . toBeTruthy ( )
484+ expect ( typeof renamedRecord ?. prTitle === 'string' ? renamedRecord . prTitle : '' ) . toBe (
485+ renamedTitle ,
486+ )
487+
488+ const selectedLabelText = await page
489+ . locator ( '#workspaces-select option:checked' )
490+ . textContent ( )
491+ expect ( String ( selectedLabelText ?? '' ) . trim ( ) ) . toBe ( renamedTitle )
492+ await expect ( page . locator ( '#workspace-context-status' ) ) . toContainText ( renamedTitle )
493+ } )
494+
495+ test ( 'Active Local PR-associated workspace cannot be renamed from Workspaces drawer' , async ( {
496+ page,
497+ } ) => {
498+ const activeWorkspaceId = 'active_local_workspace_rename_blocked_pr_associated'
499+
500+ await waitForAppReady ( page )
501+
502+ await seedLocalWorkspaceContexts ( page , [
503+ {
504+ id : activeWorkspaceId ,
505+ repo : '' ,
506+ workspaceScope : 'local' ,
507+ head : 'feat/active-local-rename-blocked' ,
508+ prTitle : 'PR-associated local workspace' ,
509+ prContextState : 'active' ,
510+ prNumber : 97 ,
511+ tabs : [
512+ {
513+ id : 'component' ,
514+ path : 'src/component.tsx' ,
515+ language : 'tsx' ,
516+ role : 'component' ,
517+ content : 'export const App = () => <main>active local rename blocked</main>' ,
518+ order : 0 ,
519+ source : 'workspace' ,
520+ dirty : false ,
521+ } ,
522+ ] ,
523+ activeTabId : 'component' ,
524+ } ,
525+ ] )
526+
527+ await page . reload ( )
528+ await waitForAppReady ( page )
529+
530+ const workspacesToggle = page . getByRole ( 'button' , {
531+ name : 'Workspaces' ,
532+ exact : true ,
533+ } )
534+ await workspacesToggle . click ( )
535+
536+ const workspaceSelect = page . getByLabel ( 'Stored workspace' )
537+ const renameButton = page . getByRole ( 'button' , { name : 'Rename' , exact : true } )
538+ await expect ( renameButton ) . toBeVisible ( )
539+
540+ await expect ( workspaceSelect ) . toHaveValue ( activeWorkspaceId )
541+ await expect ( renameButton ) . toBeDisabled ( )
542+ } )
543+
421544test ( 'chat stays usable after opening a Local workspace with PAT connected' , async ( {
422545 page,
423546} ) => {
0 commit comments