Skip to content

Commit a1ffa77

Browse files
loganjLarry
andcommitted
test(desktop): pin virtualization spec to rendered-window truth
Tests-only fix for PR-D2 per Astra review of the revised candidate (approved 4b2a046b; the original 4d9add22 candidate was rejected and not applied). No production change: both edits land in the existing members-sidebar virtualization spec in channels.spec.ts. ## Summary - First-window endpoint: generated members have no display name, so the roster sorts them by their npub fallback label; sequential pubkeys with a shared `npub1qqq...` prefix order by checksum tail, not numeric position. Resolving the first generated row from the pubkeys the initial window actually rendered replaces the unstable `pubkeys[0]` assumption. - Tail endpoint: the fully-scrolled tail check no longer samples `pubkeys.at(-1)` (subject to window luck). The sidebar's own "Members - N" header must equal the fixture-known roster total (3 seeded + 500 generated), and the final row is located by VirtualizedList's stamped `data-index` on the last item, a fixed target a virtualizer clamped mid-roster can never render. Validation at this exact delta (tests-only, evidence reused from the approved candidate; no full suite run, no re-review): focused virtualization spec 1/1 green, members-sidebar shard 12/12 green, biome and e2e build/typecheck clean. A midpoint negative control (skipping to the middle of the roster) fails the new tail endpoint. Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson <[email protected]>
1 parent 4763cbe commit a1ffa77

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

‎desktop/tests/e2e/channels.spec.ts‎

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,8 +4176,26 @@ test("members sidebar virtualizes large channel rosters", async ({ page }) => {
41764176
await expect(memberRows.first()).toBeVisible();
41774177
expect(await memberRows.count()).toBeLessThan(50);
41784178

4179+
// Generated members have no display name, so the roster sorts them by
4180+
// their npub fallback label: these sequential pubkeys share a `npub1qqq…`
4181+
// prefix and order by the checksum tail, not their numeric value. Resolve
4182+
// a generated member from the rows the initial window actually rendered
4183+
// instead of assuming `pubkeys[0]` sorts into that window.
4184+
const generatedPubkeySet = new Set(pubkeys);
4185+
const renderedPubkeys = await memberRows.evaluateAll((rows) =>
4186+
rows.map(
4187+
(row) =>
4188+
(row as HTMLElement).dataset.testid?.slice("sidebar-member-".length) ??
4189+
"",
4190+
),
4191+
);
4192+
const firstRenderedGeneratedPubkey = renderedPubkeys.find((pubkey) =>
4193+
generatedPubkeySet.has(pubkey),
4194+
);
4195+
expect(firstRenderedGeneratedPubkey).toBeTruthy();
4196+
41794197
const firstGeneratedRow = memberList.getByTestId(
4180-
`sidebar-member-${pubkeys[0]}`,
4198+
`sidebar-member-${firstRenderedGeneratedPubkey}`,
41814199
);
41824200
await expect
41834201
.poll(() =>
@@ -4214,8 +4232,24 @@ test("members sidebar virtualizes large channel rosters", async ({ page }) => {
42144232
element.scrollTop = element.scrollHeight;
42154233
element.dispatchEvent(new Event("scroll"));
42164234
});
4217-
await expect(
4218-
memberList.getByTestId(`sidebar-member-${pubkeys.at(-1)}`),
4235+
// Fully scrolling must render the roster's true tail, and the tail
4236+
// endpoint must be known independently of whatever the virtual window
4237+
// happens to render. The sidebar's own roster accounting — the
4238+
// "Members · N" header — must read exactly the fixture-known total
4239+
// ("random" seeds alice, the mock identity, and bob; this test adds the
4240+
// 500 generated pubkeys on top), so fixture or classification drift
4241+
// fails loudly here instead of silently weakening the tail check.
4242+
const rosterCount = 3 + pubkeys.length;
4243+
await expect(memberList.getByText(/^Members · \d+$/)).toHaveText(
4244+
`Members · ${rosterCount}`,
4245+
);
4246+
// VirtualizedList stamps each rendered row with its item index, so the
4247+
// final item's row is a fixed target that no window sample can pick in
4248+
// its place: a virtualizer clamped mid-roster never renders it.
4249+
await expect(
4250+
memberList.locator(
4251+
`[data-index="${rosterCount - 1}"] > [data-testid^="sidebar-member-"]`,
4252+
),
42194253
).toBeVisible();
42204254
});
42214255

0 commit comments

Comments
 (0)