@@ -51,6 +51,7 @@ const aliceEntry = { login: "alice", avatarUrl: "", type: "user" as const };
5151const acmeEntry = { login : "acme-corp" , avatarUrl : "" , type : "org" as const } ;
5252const betaEntry = { login : "beta-org" , avatarUrl : "" , type : "org" as const } ;
5353const deltaEntry = { login : "delta-inc" , avatarUrl : "" , type : "org" as const } ;
54+ const aaaEntry = { login : "aaa-org" , avatarUrl : "" , type : "org" as const } ;
5455
5556// ── Helper: create one repo per org ──────────────────────────────────────────
5657function makeOrgRepos ( org : string ) : RepoEntry [ ] {
@@ -75,7 +76,7 @@ function getOrgHeaderOrder(orgNames: string[]): string[] {
7576// ── Helper: accordion (6+ orgs) org header order ─────────────────────────────
7677function getAccordionOrder ( orgNames : string [ ] ) : string [ ] {
7778 return orgNames
78- . map ( ( name ) => ( { name, btn : screen . getByRole ( "button" , { name : new RegExp ( name ) } ) } ) )
79+ . map ( ( name ) => ( { name, btn : screen . getByRole ( "button" , { name : new RegExp ( name . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g , "\\$&" ) ) } ) } ) )
7980 . sort ( ( a , b ) => {
8081 const pos = a . btn . compareDocumentPosition ( b . btn ) ;
8182 return pos & Node . DOCUMENT_POSITION_FOLLOWING ? - 1 : 1 ;
@@ -491,20 +492,23 @@ describeFeature(feature, ({ Scenario, Background, BeforeEachScenario, AfterEachS
491492 ) ;
492493
493494 When (
494- 'the user\'s org access changes so that "delta-inc" is removed and "beta -org" is added and beta -org finishes loading' ,
495+ 'the user\'s org access changes so that "delta-inc" is removed and "aaa -org" is added and aaa -org finishes loading' ,
495496 async ( ) => {
496- setSelectedOrgs ( [ "alice" , "acme-corp" , "beta-org" ] ) ;
497- setOrgEntries ( [ aliceEntry , acmeEntry , betaEntry ] ) ;
497+ // aaa-org sorts BEFORE acme-corp alphabetically. If the frozen order
498+ // is NOT invalidated, the replay logic appends aaa-org at the end
499+ // (alice, acme-corp, aaa-org) instead of re-sorting (alice, aaa-org, acme-corp).
500+ setSelectedOrgs ( [ "alice" , "acme-corp" , "aaa-org" ] ) ;
501+ setOrgEntries ( [ aliceEntry , acmeEntry , aaaEntry ] ) ;
498502
499503 await waitFor ( ( ) => {
500- screen . getByText ( "beta -org-repo" ) ;
504+ screen . getByText ( "aaa -org-repo" ) ;
501505 } ) ;
502506 }
503507 ) ;
504508
505- Then ( 'the org header order becomes "alice", "acme-corp ", "beta-org "' , ( ) => {
506- const order = getOrgHeaderOrder ( [ "alice" , "acme-corp " , "beta-org " ] ) ;
507- expect ( order ) . toEqual ( [ "alice" , "acme-corp " , "beta-org " ] ) ;
509+ Then ( 'the org header order becomes "alice", "aaa-org ", "acme-corp "' , ( ) => {
510+ const order = getOrgHeaderOrder ( [ "alice" , "aaa-org " , "acme-corp " ] ) ;
511+ expect ( order ) . toEqual ( [ "alice" , "aaa-org " , "acme-corp " ] ) ;
508512 } ) ;
509513
510514 And ( '"delta-inc" no longer appears in the list' , ( ) => {
0 commit comments