Skip to content

Commit f062679

Browse files
loganjLarry
andcommitted
test(desktop): pin members sidebar visible order to full canonical npub
The full-npub ordering change bound its five unit cases to compareMembersByRole only. The visible members-sidebar roster sorts through compareMembersForModal, whose delegation to the shared name stage had no regression: reverting just that delegation back to formatMemberName(...).localeCompare kept every existing test green. Add one focused e2e case on the existing small-sidebar workflow seams: the two unnamed fixtures from the memberUtils unit pair join the three-member "random" roster — both visible in the initial virtual window, no 500-member roster needed — arriving in the opposite of the expected order, and the rendered roster must place V24 before V5. The full canonical npubs disagree with the compact labels for exactly this pair, so a display-label order fails the assertion. Falsified against ec7a9cf by reverting only the modal delegation (byte-identical to parent a1ffa77): the new case failed at the order assertion while both existing members-sidebar workflows stayed green; restored production passes all three. Production files are untouched and byte-identical to ec7a9cf. Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson <[email protected]>
1 parent 28e3241 commit f062679

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ const OWNED_RELAY_AGENT_PUBKEY =
2727
"a1b2c3d4e5f60718293a4b5c6d7e8f90112233445566778899aabbccddeeff00";
2828
const DM_RELAY_AGENT_PUBKEY =
2929
"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
30+
// Unnamed roster fixtures whose two plausible orders disagree (the e2e twin
31+
// of the memberUtils unit pair): both keys share the `npub1qqq…` head, so
32+
// the compact display labels order V5 first (`…2hcx` < `…2w5c`) while the
33+
// full canonical npubs order V24 first (`…vq53…` < `…zsfj…`). Only the
34+
// full-npub order is correct for the roster.
35+
const UNNAMED_MEMBER_V5_PUBKEY =
36+
"0000000000000000000000000000000000000000000000000000000000000005";
37+
const UNNAMED_MEMBER_V24_PUBKEY =
38+
"0000000000000000000000000000000000000000000000000000000000000018";
3039

3140
type MockFeedWindow = Window & {
3241
__BUZZ_E2E_EMIT_MOCK_MESSAGE__?: (input: {
@@ -4254,6 +4263,57 @@ test("members sidebar virtualizes large channel rosters", async ({ page }) => {
42544263
).toBeVisible();
42554264
});
42564265

4266+
test("members sidebar orders unnamed members by full canonical npub", async ({
4267+
page,
4268+
}) => {
4269+
await page.goto("/");
4270+
const channelId = await page
4271+
.getByTestId("channel-random")
4272+
.getAttribute("data-channel-id");
4273+
if (!channelId) {
4274+
throw new Error("Random channel id missing.");
4275+
}
4276+
4277+
// Added in the opposite of the expected order, so incoming membership
4278+
// order can never satisfy the assertion on its own.
4279+
await invokeMockCommand(page, "add_channel_members", {
4280+
channelId,
4281+
pubkeys: [UNNAMED_MEMBER_V5_PUBKEY, UNNAMED_MEMBER_V24_PUBKEY],
4282+
role: "member",
4283+
});
4284+
4285+
await openMembersSidebar(page, "random");
4286+
// "random" seeds alice, the mock identity, and bob, so the two unnamed
4287+
// fixtures round out a five-row roster that the initial virtual window
4288+
// renders entirely — both fixtures are visible without scrolling.
4289+
await expect(
4290+
page.getByTestId(`sidebar-member-${UNNAMED_MEMBER_V24_PUBKEY}`),
4291+
).toBeVisible();
4292+
await expect(
4293+
page.getByTestId(`sidebar-member-${UNNAMED_MEMBER_V5_PUBKEY}`),
4294+
).toBeVisible();
4295+
4296+
// The compact labels (`npub1qqq…2hcx` < `npub1qqq…2w5c`) would order V5
4297+
// first; the full canonical npubs disagree and order V24 first. The
4298+
// rendered roster must follow the full key, not the display label.
4299+
const renderedOrder = await page
4300+
.getByTestId("members-sidebar-people")
4301+
.locator('[data-index] > [data-testid^="sidebar-member-"]')
4302+
.evaluateAll((rows) =>
4303+
rows.map(
4304+
(row) =>
4305+
(row as HTMLElement).dataset.testid?.slice(
4306+
"sidebar-member-".length,
4307+
) ?? "",
4308+
),
4309+
);
4310+
const v24Position = renderedOrder.indexOf(UNNAMED_MEMBER_V24_PUBKEY);
4311+
const v5Position = renderedOrder.indexOf(UNNAMED_MEMBER_V5_PUBKEY);
4312+
expect(v24Position).toBeGreaterThanOrEqual(0);
4313+
expect(v5Position).toBeGreaterThanOrEqual(0);
4314+
expect(v24Position).toBeLessThan(v5Position);
4315+
});
4316+
42574317
test("opening a human-only members sidebar skips managed runtime discovery", async ({
42584318
page,
42594319
}) => {

0 commit comments

Comments
 (0)