Skip to content

Commit d1af29a

Browse files
wesbillmanCarlclaudePrincess DonutMongo
authored
test: fix six cross-branch CI flakes (#1002)
Signed-off-by: Wes <[email protected]> Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Princess Donut <5d97ac8c272fa949af56c71e586146b1706e5c4c3daa125db5b4625e12e0686c@buzz.block.builderlab.xyz> Co-authored-by: Mongo <81cabd2ca1792494372ed410283c00770c0cf35afca052e940fa522883212b45@buzz.block.builderlab.xyz> Co-authored-by: Mordecai <f314b6033b6e13df94c8e9e1187d3666b6b9ce54e66ee986e31cdaa909e8dcbc@buzz.block.builderlab.xyz>
1 parent 75c501b commit d1af29a

6 files changed

Lines changed: 49 additions & 24 deletions

File tree

‎src/bundled/channels/MemberAdministration.test.tsx‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
within,
1313
} from "@testing-library/react";
1414
import userEvent from "@testing-library/user-event";
15-
import { formatPublicKey } from "../../shared/identity/public-key";
15+
import { canonicalPublicKey } from "../../shared/identity/public-key";
1616
import { beforeEach, afterEach, expect, it, vi } from "vitest";
1717
import { createRelaySession } from "../../features/relay/session";
1818
import { keypair, profile, signed } from "../../features/relay/testing";
@@ -1147,15 +1147,18 @@ it.each([false, true])(
11471147
),
11481148
).toHaveLength(before + 1);
11491149
// Session revocation also clears optional names; identify the row by its stable key.
1150+
// Labels lengthen the npub suffix until visible keys differ, and these keys are random.
1151+
const npub = required(canonicalPublicKey(t.target.pubkey));
11501152
const targetRow = () =>
11511153
required(
11521154
screen
11531155
.getAllByRole("button", { name: /^Open profile for/ })
1154-
.find((button) =>
1155-
button
1156+
.find((button) => {
1157+
const suffix = button
11561158
.getAttribute("aria-label")
1157-
?.includes(`(${formatPublicKey(t.target.pubkey)})`),
1158-
)
1159+
?.match(/\(npub…(\w+)\)/)?.[1];
1160+
return !!suffix && npub.endsWith(suffix);
1161+
})
11591162
?.closest("li"),
11601163
);
11611164
if (failure) {

‎tests/browser/inbox-edit.spec.mjs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,14 @@ for (const submitted of [false, true])
125125
await openPage(page, "Inbox");
126126
const inbox = page.getByRole("region", { name: "Inbox", exact: true });
127127
await expect(inbox.getByText("Checking recent activity…")).toHaveCount(0);
128-
const conversation = inbox
129-
.getByRole("list", { name: "Inbox conversations" })
130-
.getByRole("listitem")
131-
.filter({ hasText: "Broadcast reply" });
132-
await conversation.getByRole("button", { name: /^Open / }).click();
128+
// The preview can settle on either reply as thread inputs arrive; the
129+
// conversation's accessible identity is the stable target for this test.
130+
await inbox
131+
.getByRole("button", {
132+
name: "Open Alice Fixture in #Alpha",
133+
exact: true,
134+
})
135+
.click();
133136
const detail = inbox.getByRole("region", { name: "Inbox detail" });
134137
const editor = detail.getByRole("textbox", {
135138
name: "Reply to thread",

‎tests/browser/me-workspace.spec.mjs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ test("Me sidebar shares working activity, keyboard preview and local panel navig
155155
.getByRole("button", { name: "Close Agent Activity tab", exact: true })
156156
.click();
157157
await expect(alpha).toBeFocused();
158-
await page.clock.install();
159-
await page.clock.pauseAt(new Date());
158+
// The installed clock runs, so pause at a fixed instant ahead of it rather
159+
// than a test-side timestamp that the page clock may already have passed.
160+
const base = Date.now();
161+
await page.clock.install({ time: base });
162+
await page.clock.pauseAt(base + 1_000);
160163
// Cross the closed trigger, then reopen by keyboard before hover dismissal.
161164
await alpha.hover();
162165
await page.mouse.move(0, 0);

‎tests/browser/message-overlays.spec.mjs‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -542,25 +542,36 @@ test("comment actions revealed while the drawer slides realign when it settles",
542542
.getByRole("button", { name: "Hide comments", exact: true })
543543
.click();
544544
await expect(drawer).toBeHidden();
545-
// Hold the opening slide early in its transform transition, once it exists.
545+
// The role hides at once, but the closing slide runs on. Reopening before it
546+
// ends reverses that slide from near the open position. Visibility turns
547+
// hidden only once the slide has ended.
548+
await expect
549+
.poll(() =>
550+
page
551+
.locator('aside[aria-label="Media comments"]')
552+
.evaluate((node) => getComputedStyle(node).visibility),
553+
)
554+
.toBe("hidden");
555+
// Hold the opening slide early in its transform transition. transitionrun is
556+
// dispatched after a frame, which can outlast the slide on a loaded runner.
557+
// A mutation callback runs before any frame, and getAnimations() flushes
558+
// style, so it creates the slide still at its start.
546559
await page.evaluate(() => {
560+
const drawer = document.querySelector('aside[aria-label="Media comments"]');
561+
const viewer = drawer.closest("[data-comments-hidden]");
547562
window.drawerHeld = new Promise((resolve) => {
548-
const hold = (event) => {
549-
if (
550-
event.propertyName !== "transform" ||
551-
!event.target.matches('aside[aria-label="Media comments"]')
552-
)
553-
return;
554-
document.removeEventListener("transitionrun", hold);
555-
const slide = event.target
563+
const observer = new MutationObserver(() => {
564+
if (viewer.hasAttribute("data-comments-hidden")) return;
565+
observer.disconnect();
566+
const slide = drawer
556567
.getAnimations()
557568
.find((animation) => animation.transitionProperty === "transform");
558569
slide.pause();
559570
slide.currentTime = 40;
560571
window.drawerSlide = slide;
561572
resolve();
562-
};
563-
document.addEventListener("transitionrun", hold);
573+
});
574+
observer.observe(viewer, { attributeFilter: ["data-comments-hidden"] });
564575
});
565576
});
566577
await review

‎tests/browser/sidebar-unread.spec.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ test("session changes discard the previous sidebar targets and manual unread sti
466466
).toBeVisible();
467467
await expectCueHidden(page, "below");
468468
await openChannelDetails(page);
469-
await page.getByText("Diagnostics", { exact: true }).click();
469+
await page.getByText("Diagnostics", { exact: true }).press("Enter");
470470
await page
471471
.getByRole("button", { name: "Mark unread on this device", exact: true })
472472
.click();

‎tests/browser/voice-notes.spec.mjs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ test("rejects a full attachment draft before opening the microphone", async ({
392392
buffer: Buffer.from("test"),
393393
})),
394394
);
395+
// The attachment rows grow as the draft settles, moving the toolbar under a
396+
// pointer aimed at its earlier position. Click once every file is Ready.
397+
await expect(
398+
page.getByRole("status").filter({ hasText: /· Ready$/ }),
399+
).toHaveCount(10);
395400
await page
396401
.getByRole("button", { name: "Record voice note", exact: true })
397402
.click();

0 commit comments

Comments
 (0)