@@ -16,6 +16,7 @@ import { Browser, Target } from "../src/services";
1616import { revisit , settle , visit } from "../src/surfaces/browser" ;
1717import type { Identity , Target as TargetShape } from "../src/target" ;
1818import { WORKOS_EMULATOR_PORT } from "../targets/cloud" ;
19+ import { verifyAdmin } from "./support/admin-mfa" ;
1920import { cookieOf } from "./support/session" ;
2021
2122const V2_IMPORT_API = "/api/auth/v2-import" ;
@@ -84,6 +85,22 @@ const markMoved = (organizationId: string) =>
8485 executor_v2_moved_at : MOVED_AT ,
8586 } ) ;
8687
88+ /** Rename the identity's active org through the product's own settings route. */
89+ const renameOrg = ( target : TargetShape , identity : Identity , name : string ) : Effect . Effect < void > =>
90+ Effect . promise ( async ( ) => {
91+ const response = await fetch ( new URL ( "/api/account/name" , target . baseUrl ) , {
92+ method : "PATCH" ,
93+ headers : {
94+ ...identity . headers ,
95+ origin : new URL ( target . baseUrl ) . origin ,
96+ "content-type" : "application/json" ,
97+ } ,
98+ body : JSON . stringify ( { name } ) ,
99+ } ) ;
100+ if ( ! response . ok ) throw new Error ( `/api/account/name failed (${ response . status } )` ) ;
101+ await response . body ?. cancel ( ) ;
102+ } ) ;
103+
87104const noticeOf = ( page : Page ) => page . getByRole ( "dialog" ) ;
88105
89106/** Open the dashboard and wait for the v2 answer it renders the notice from. */
@@ -132,7 +149,7 @@ scenario(
132149 expect ( pair ) . toContain ( `v2 · ${ V2_SLUG } ` ) ;
133150 expect ( await notice . getByText ( "Changes made here won't sync to v2." ) . count ( ) ) . toBe ( 1 ) ;
134151
135- const open = notice . getByRole ( "link" , { name : ` Open ${ org . name } in v2` } ) ;
152+ const open = notice . getByRole ( "link" , { name : " Open in v2" , exact : true } ) ;
136153 expect ( await open . getAttribute ( "href" ) , "the button opens the org in v2" ) . toBe (
137154 answer . moved ! . v2Url ,
138155 ) ;
@@ -257,3 +274,48 @@ scenario(
257274 } ) ;
258275 } ) ,
259276) ;
277+
278+ scenario (
279+ "v2 moved · a long organization name stays inside the notice" ,
280+ { timeout : 180_000 } ,
281+ Effect . gen ( function * ( ) {
282+ const target = yield * Target ;
283+ const browser = yield * Browser ;
284+ const identity = yield * target . newIdentity ( ) ;
285+ const longName = "Synthetic Extraordinarily Long Organization Name For Layout Checks" ;
286+ // Renaming is an organization setting, which needs a verified admin session; the browser
287+ // below uses the plain session.
288+ yield * renameOrg ( target , yield * verifyAdmin ( target . baseUrl , identity ) , longName ) ;
289+ const org = yield * orgOf ( target , identity ) ;
290+ expect ( org . name , "the rename reached the dashboard's org" ) . toBe ( longName ) ;
291+ yield * markMoved ( org . id ) ;
292+
293+ yield * browser . session ( identity , async ( { page, step } ) => {
294+ await step ( "Open the moved org's dashboard" , async ( ) => {
295+ await openDashboard ( page , org . slug ) ;
296+ await noticeOf ( page )
297+ . getByRole ( "heading" , { name : `${ longName } now lives in Executor v2` } )
298+ . waitFor ( ) ;
299+ } ) ;
300+
301+ await step ( "See the pair and both buttons inside the notice" , async ( ) => {
302+ const notice = noticeOf ( page ) ;
303+ const box = await notice . boundingBox ( ) ;
304+ if ( box === null ) throw new Error ( "the notice has no layout box" ) ;
305+ const right = box . x + box . width ;
306+ for ( const [ label , part ] of [
307+ [ "the v1 → v2 pair" , notice . getByTestId ( "v2-moved-pair" ) ] ,
308+ [ "Keep using v1" , notice . getByRole ( "button" , { name : "Keep using v1" } ) ] ,
309+ [ "Open in v2" , notice . getByRole ( "link" , { name : "Open in v2" , exact : true } ) ] ,
310+ ] as const ) {
311+ const partBox = await part . boundingBox ( ) ;
312+ if ( partBox === null ) throw new Error ( `${ label } has no layout box` ) ;
313+ expect ( partBox . x , `${ label } starts inside the notice` ) . toBeGreaterThanOrEqual ( box . x ) ;
314+ expect ( partBox . x + partBox . width , `${ label } ends inside the notice` ) . toBeLessThanOrEqual (
315+ right ,
316+ ) ;
317+ }
318+ } ) ;
319+ } ) ;
320+ } ) ,
321+ ) ;
0 commit comments