Skip to content

Commit c4d0a20

Browse files
committed
fix(test): strengthens S7 with discriminating org name
1 parent e031bfd commit c4d0a20

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tests/acceptance/org-order-stability.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ Feature: Freeze org display order in RepoSelector after initial sort
4545

4646
Scenario: S7 - Frozen order invalidated on simultaneous add and remove
4747
Given the RepoSelector displays 3 orgs sorted as "alice", "acme-corp", "delta-inc" with order frozen
48-
When the user's org access changes so that "delta-inc" is removed and "beta-org" is added and beta-org finishes loading
49-
Then the org header order becomes "alice", "acme-corp", "beta-org"
48+
When the user's org access changes so that "delta-inc" is removed and "aaa-org" is added and aaa-org finishes loading
49+
Then the org header order becomes "alice", "aaa-org", "acme-corp"
5050
And "delta-inc" no longer appears in the list

tests/acceptance/steps/org-order-stability.steps.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const aliceEntry = { login: "alice", avatarUrl: "", type: "user" as const };
5151
const acmeEntry = { login: "acme-corp", avatarUrl: "", type: "org" as const };
5252
const betaEntry = { login: "beta-org", avatarUrl: "", type: "org" as const };
5353
const 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 ──────────────────────────────────────────
5657
function makeOrgRepos(org: string): RepoEntry[] {
@@ -75,7 +76,7 @@ function getOrgHeaderOrder(orgNames: string[]): string[] {
7576
// ── Helper: accordion (6+ orgs) org header order ─────────────────────────────
7677
function 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

Comments
 (0)