mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
## Summary Units 2–5 of the 23–30 Oct desktop Playwright flake audit: four E2E specs that raced scroll settles and focus. All four fixes are test-only. This is one of six PRs split from the reviewed `flakey-tests` branch (siblings below). ### `navigation.spec.ts:472` "composer Buzz chip labels wrap without orphaning their icons" 11 jobs failed in the window, 6 of them after the earlier fixes, including 4 of the 7 main runs that carry every fix. Run 40970053997 (Smoke shard 7) failed all three attempts. - **Mode A** (jobs 122971493553, 123066839967, 123572467962, 123819180597 and retry 2 of 123784825042): `fragmentStep` is null at :634. Rows key on `renderKey = localKey ?? id`, and a head refetch or live echo after the ack drops the `localKey`. The row remounts and loses the 220 px width the test set earlier. **Change:** re-land the test half of closed #6852. Set the width and measure in one `expect.poll`, and set the width again before each fragment measurement. - **Mode B** (jobs 123573056202, 123784199542, 123784825042 twice, 123804428893, 123818728963, 123819543461, and 122924164125): the tooltip-centre poll at :667 receives 81.35 or Infinity. Radix Tooltip closes when an ancestor of its trigger scrolls. In the failing attempt, the post-send settle took its last step 21 ms or less before focus. **Change:** wait for the sent row's `message-send-status` to clear. Then poll until the timeline sits at its floor and holds there for two animation frames, and only then focus the chip. `positionOverFragment` asserts `data-state` is open. There is no retry loop around the race. ### `huddle-transcription.spec.ts:637` "animates the responding agent with the shared speaker ring" - **Runs:** 9 jobs, always Smoke shard 4, attempt 1. On main: 39896948198, 40718743531, 40732061485, 40840949170, 40906253761, 40969965981 and 40983029157. On PRs: #8715 and #8666. `toBeFocused()` at :697 reads inactive. - **Cause:** `useComposerAutofocus` runs again once the editor mounts and takes focus from the focused trigger. - **Change:** wait for `message-input` to be focused before focusing the trigger, as the same spec already does at :855. ### `scroll-history.spec.ts:1289` "fast middle-page scroll settles with continuous mounted coverage" - **Runs:** 9 jobs. After the fixes: main 40980404335 (job 123819180518) and two attempts on #8720. The `viewportCoverage` poll expects < 100 and receives 200, the bottom spacer. - **Cause:** the bottom-settle intent armed when the channel first positions survives the prepend and the spec's `scrollTop` writes. Virtua's re-measure then pulls the list back to the floor. - **Change:** hover the timeline and wheel up 120 px first, since reader input cancels the intent. Then poll until the timeline is more than 32 px from the floor and steady for two frames. - The commit message calls the cancelling listener `listenForReaderScroll`, a name introduced by sibling #8742. On `main`, the same wheel listener is inline in `useVirtualizedBottomSettle`, so this fix doesn't depend on that PR. ### `custom-emoji.spec.ts:370` "reacting with a custom emoji renders via the loopback media proxy" - **Runs:** main 40787609859 and 40983029157 (Smoke shard 3), and #8241. The inline "Add reaction" opacity reads "1", not "0". - **Cause:** the non-modal Radix Popover returns focus to its trigger in a `setTimeout(0)` after its 100 ms exit animation. That can land after the spec's blur. - **Change:** wait for the "Open reactions" trigger to be focused, then blur. ### Related issue None found. Sibling #8744 also edits `navigation.spec.ts`, in a separate hunk. The two merge cleanly in either order. #8622 adds an unrelated test at the end of `navigation.spec.ts`, and #7812 (stale since 10-06) adds tests elsewhere in three of these files. ### Testing Not run locally, because Playwright bogs this machine down. Flake Check will repeat the touched specs. `pnpm typecheck` and `pnpm check` pass. An ad hoc `tsc` run over the four specs found the same pre-existing errors as on their `main` copies (navigation 7, huddle 17, scroll-history 0, custom-emoji 2). Pushed with `git push --no-verify`, because the pre-push suites fail when the laptop is under load. ### Readiness An agent review of the combined `flakey-tests` branch (b432453af) found no blockers. `buzz-review-completed` is not added, because the human test step (AGENTS.md "Before opening a PR", step 3) hasn't happened yet. ### Siblings - #8739 ci: Hermit fetch deadline and sccache fallback - #8740 test(relay): thread_window aux-page hold and `api::media` Postgres tests - #8741 test(mobile): RunnerTests title fade and alert wait - #8742 fix(desktop): deep-linked message hold (product change) - #8744 test(desktop): five settle classes and remote-owned-mentions 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1159 lines
41 KiB
TypeScript
1159 lines
41 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
import { installMockBridge } from "../helpers/bridge";
|
|
import { openSettings } from "../helpers/settings";
|
|
import { addSendMessageStep } from "../helpers/workflows";
|
|
|
|
const ENGINEERING_CHANNEL_ID = "1c7e1c02-87bb-5e88-b2da-5a7a9432d0c9";
|
|
const WATERCOLOR_CHANNEL_ID = "a27e1ee9-76a6-5bdf-a5d5-1d85610dad11";
|
|
const FORUM_POST_ID = "mock-forum-release-thread";
|
|
const FORUM_REPLY_ID = "mock-forum-release-reply";
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await installMockBridge(page);
|
|
});
|
|
|
|
/**
|
|
* Inline message chips no longer change their label when metadata resolves, so
|
|
* a single hover can land while the chip is still the plain (untriggered) span.
|
|
* Re-arm the pointer until the metadata tooltip is mounted.
|
|
*/
|
|
async function hoverUntilMetadataTooltip(
|
|
page: import("@playwright/test").Page,
|
|
chip: import("@playwright/test").Locator,
|
|
) {
|
|
await expect
|
|
.poll(async () => {
|
|
await page.getByTestId("chat-title").hover();
|
|
await chip.hover();
|
|
return page
|
|
.getByRole("tooltip")
|
|
.locator('[data-buzz-tooltip-metadata-content=""]')
|
|
.count();
|
|
})
|
|
.toBeGreaterThan(0);
|
|
}
|
|
|
|
async function navigateToWorkflows(page: import("@playwright/test").Page) {
|
|
await page.goto("/");
|
|
await page.getByTestId("open-workflows-view").click();
|
|
await expect(page).toHaveURL(/#\/workflows$/);
|
|
await expect(page.getByTestId("workflows-view")).toBeVisible();
|
|
}
|
|
|
|
async function createWorkflow(
|
|
page: import("@playwright/test").Page,
|
|
name: string,
|
|
) {
|
|
await page.getByRole("button", { name: "Create Workflow" }).click();
|
|
const dialog = page.getByRole("dialog", { name: "Create workflow" });
|
|
await expect(dialog).toBeVisible();
|
|
|
|
const channelList = page.getByTestId("channel-combobox-list");
|
|
await expect(channelList).toBeVisible();
|
|
await channelList
|
|
.getByRole("option", { name: "agents", exact: true })
|
|
.click();
|
|
|
|
await dialog.getByRole("button", { name: "Edit workflow name" }).click();
|
|
await dialog.getByRole("textbox", { name: "Workflow name" }).fill(name);
|
|
await dialog.getByRole("button", { name: "Save workflow name" }).click();
|
|
|
|
await addSendMessageStep(dialog, "Workflow notification");
|
|
await dialog.getByRole("button", { name: "Create" }).click();
|
|
const activationConfirmation = page.getByRole("alertdialog", {
|
|
name: "This workflow may run often",
|
|
});
|
|
await Promise.race([
|
|
activationConfirmation.waitFor({ state: "visible" }),
|
|
dialog.waitFor({ state: "hidden" }),
|
|
]);
|
|
if (await activationConfirmation.isVisible()) {
|
|
await activationConfirmation
|
|
.getByRole("button", { name: "Turn on" })
|
|
.click();
|
|
}
|
|
await expect(dialog).not.toBeVisible();
|
|
}
|
|
|
|
test("global back and forward move across channel routes", async ({ page }) => {
|
|
await page.goto("/");
|
|
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
await page.getByTestId("channel-random").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("random");
|
|
|
|
await page.getByTestId("global-back").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
await page.getByTestId("global-forward").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("random");
|
|
});
|
|
|
|
test("back/forward keyboard chords work while the composer has focus", async ({
|
|
page,
|
|
}) => {
|
|
const backChord = process.platform === "darwin" ? "Meta+[" : "Alt+ArrowLeft";
|
|
const forwardChord =
|
|
process.platform === "darwin" ? "Meta+]" : "Alt+ArrowRight";
|
|
|
|
await page.goto("/");
|
|
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
await page.getByTestId("channel-random").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("random");
|
|
|
|
// The composer autofocuses on channel switch; make the regression
|
|
// condition explicit by clicking into it. The chords must still fire
|
|
// from inside the contenteditable (#3775).
|
|
await page.getByTestId("message-input").click();
|
|
await expect(page.getByTestId("message-input")).toBeFocused();
|
|
|
|
await page.keyboard.press(backChord);
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
await page.keyboard.press(forwardChord);
|
|
await expect(page.getByTestId("chat-title")).toHaveText("random");
|
|
|
|
// preventDefault kept the chord out of the editor — no stray characters.
|
|
await expect(page.getByTestId("message-input")).toHaveText("");
|
|
});
|
|
|
|
// FIXME: the forum post "Back to posts" header renders under the fixed top
|
|
// chrome drag region, which intercepts the click. Pre-existing breakage —
|
|
// this spec file was never registered in playwright.config.ts until now.
|
|
// The header-chrome rework (PR #941) covers this overlap class.
|
|
test.fixme("direct forum thread links close back to the forum route", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto(
|
|
`/#/channels/${WATERCOLOR_CHANNEL_ID}/posts/${FORUM_POST_ID}`,
|
|
);
|
|
|
|
await expect(page.getByTestId("chat-title")).toHaveText("watercooler");
|
|
await expect(
|
|
page.getByRole("button", { name: "Back to posts" }),
|
|
).toBeVisible();
|
|
|
|
await page.getByRole("button", { name: "Back to posts" }).click();
|
|
|
|
await expect(page).toHaveURL(
|
|
/#\/channels\/a27e1ee9-76a6-5bdf-a5d5-1d85610dad11$/,
|
|
);
|
|
await expect(
|
|
page.getByText("Release checklist: async feedback thread."),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("direct workflow detail links close back to workflows", async ({
|
|
page,
|
|
}) => {
|
|
const workflowName = `workflow_nav_${Date.now()}`;
|
|
|
|
await navigateToWorkflows(page);
|
|
await createWorkflow(page, workflowName);
|
|
|
|
const workflowCard = page
|
|
.locator('[data-testid^="workflow-card-"]')
|
|
.filter({ hasText: workflowName })
|
|
.first();
|
|
const workflowTestId = await workflowCard.getAttribute("data-testid");
|
|
const workflowId = workflowTestId?.replace("workflow-card-", "");
|
|
|
|
expect(workflowId).toBeTruthy();
|
|
|
|
await page.goto(`/#/workflows/${workflowId}`);
|
|
|
|
const dialog = page.getByRole("dialog", { name: "Edit workflow" });
|
|
await expect(dialog.getByText(workflowName, { exact: true })).toBeVisible();
|
|
await expect(
|
|
dialog.getByRole("button", { name: "Trigger: Message Posted" }),
|
|
).toBeVisible();
|
|
await expect(dialog.getByRole("button", { name: "Run history" })).toHaveCount(
|
|
0,
|
|
);
|
|
await dialog.getByRole("button", { name: "Close", exact: true }).click();
|
|
|
|
await expect(page).toHaveURL(/#\/workflows$/);
|
|
await expect(page.getByTestId("workflows-view")).toBeVisible();
|
|
});
|
|
|
|
test("forum reply deep links survive reload", async ({ page }) => {
|
|
await page.goto(
|
|
`/#/channels/${WATERCOLOR_CHANNEL_ID}/posts/${FORUM_POST_ID}?replyId=${FORUM_REPLY_ID}`,
|
|
);
|
|
|
|
await expect(page.getByTestId("chat-title")).toHaveText("watercooler");
|
|
await expect(
|
|
page.getByText("Looks good to me. We should ship it."),
|
|
).toBeVisible();
|
|
|
|
await page.reload();
|
|
|
|
await expect(page.getByTestId("chat-title")).toHaveText("watercooler");
|
|
await expect(
|
|
page.getByText("Looks good to me. We should ship it."),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("back and forward restore open thread panels", async ({ page }) => {
|
|
await page.goto("/");
|
|
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
const rootMessage = page
|
|
.getByTestId("message-timeline")
|
|
.getByTestId("message-row")
|
|
.first();
|
|
await rootMessage.hover();
|
|
await rootMessage.getByRole("button", { name: "Reply" }).click();
|
|
|
|
const threadPanel = page.getByTestId("message-thread-panel");
|
|
await expect(threadPanel).toBeVisible();
|
|
await expect(page).toHaveURL(/thread=/);
|
|
|
|
await page.getByTestId("channel-random").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("random");
|
|
await expect(threadPanel).not.toBeVisible();
|
|
|
|
await page.getByTestId("global-back").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
await expect(threadPanel).toBeVisible();
|
|
|
|
await page.getByTestId("global-forward").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("random");
|
|
await expect(threadPanel).not.toBeVisible();
|
|
});
|
|
|
|
test("back undoes closing a thread panel", async ({ page }) => {
|
|
await page.goto("/");
|
|
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
const rootMessage = page
|
|
.getByTestId("message-timeline")
|
|
.getByTestId("message-row")
|
|
.first();
|
|
await rootMessage.hover();
|
|
await rootMessage.getByRole("button", { name: "Reply" }).click();
|
|
|
|
const threadPanel = page.getByTestId("message-thread-panel");
|
|
await expect(threadPanel).toBeVisible();
|
|
|
|
await threadPanel.getByRole("button", { name: "Close panel" }).click();
|
|
await expect(threadPanel).not.toBeVisible();
|
|
|
|
await page.getByTestId("global-back").click();
|
|
await expect(threadPanel).toBeVisible();
|
|
});
|
|
|
|
test("open thread panels survive reload", async ({ page }) => {
|
|
await page.goto("/");
|
|
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
const rootMessage = page
|
|
.getByTestId("message-timeline")
|
|
.getByTestId("message-row")
|
|
.first();
|
|
await rootMessage.hover();
|
|
await rootMessage.getByRole("button", { name: "Reply" }).click();
|
|
|
|
const threadPanel = page.getByTestId("message-thread-panel");
|
|
await expect(threadPanel).toBeVisible();
|
|
await expect(page).toHaveURL(/thread=/);
|
|
|
|
await page.reload();
|
|
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
await expect(threadPanel).toBeVisible();
|
|
});
|
|
|
|
test("inbox unread-only choice survives navigation and reload", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
const options = page.getByRole("button", { name: "Inbox options" });
|
|
const unreadOnly = page.getByRole("switch", { name: "Show unread only" });
|
|
await options.click();
|
|
await expect(unreadOnly).not.toBeChecked();
|
|
|
|
for (const enabled of [true, false]) {
|
|
await unreadOnly.setChecked(enabled);
|
|
await page.keyboard.press("Escape");
|
|
await page.getByTestId("open-agents-view").click();
|
|
await expect(page.getByTestId("home-inbox-list")).not.toBeVisible();
|
|
await page.getByTestId("global-back").click();
|
|
await options.click();
|
|
await expect(unreadOnly).toBeChecked({ checked: enabled });
|
|
|
|
await page.reload();
|
|
await options.click();
|
|
await expect(unreadOnly).toBeChecked({ checked: enabled });
|
|
}
|
|
});
|
|
|
|
test("home inbox selection survives reload and back restores it", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
|
|
const inboxList = page.getByTestId("home-inbox-list");
|
|
await expect(inboxList).toBeVisible();
|
|
const items = inboxList.locator('[data-testid^="home-inbox-item-"]');
|
|
await expect(items.first()).toBeVisible();
|
|
|
|
// The wide-viewport default selection stays local-only — the URL records
|
|
// explicit selections, so background loads never touch the history stack.
|
|
await expect(page.getByTestId("home-inbox-detail")).toBeVisible();
|
|
expect(page.url()).not.toContain("item=");
|
|
const defaultUrl = page.url();
|
|
|
|
const selectedItem = items.first();
|
|
const selectedTestId = await selectedItem.getAttribute("data-testid");
|
|
const selectedItemId = selectedTestId?.replace("home-inbox-item-", "");
|
|
expect(selectedItemId).toBeTruthy();
|
|
await selectedItem.click();
|
|
await expect
|
|
.poll(() => page.url())
|
|
.toContain(`item=${encodeURIComponent(selectedItemId ?? "")}`);
|
|
|
|
await page.reload();
|
|
|
|
await expect(inboxList).toBeVisible();
|
|
await expect(page.getByTestId("home-inbox-detail")).toBeVisible();
|
|
expect(page.url()).toContain(
|
|
`item=${encodeURIComponent(selectedItemId ?? "")}`,
|
|
);
|
|
|
|
await page.getByTestId("global-back").click();
|
|
await expect.poll(() => page.url()).toBe(defaultUrl);
|
|
});
|
|
|
|
test("settings is a route: section survives reload, closing returns to the previous panel state", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
|
|
// Open a channel with a thread panel so there's panel state to come back to.
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
const rootMessage = page
|
|
.getByTestId("message-timeline")
|
|
.getByTestId("message-row")
|
|
.first();
|
|
await rootMessage.hover();
|
|
await rootMessage.getByRole("button", { name: "Reply" }).click();
|
|
const threadPanel = page.getByTestId("message-thread-panel");
|
|
await expect(threadPanel).toBeVisible();
|
|
const channelUrl = page.url();
|
|
|
|
await openSettings(page);
|
|
await expect(page).toHaveURL(/#\/settings/);
|
|
|
|
// Section switches rewrite the settings entry (replace, not push).
|
|
await page.getByTestId("settings-nav-notifications").click();
|
|
await expect(page).toHaveURL(/section=notifications/);
|
|
|
|
await page.reload();
|
|
await expect(page.getByTestId("settings-view")).toBeVisible();
|
|
await expect(page).toHaveURL(/section=notifications/);
|
|
|
|
await page.getByTestId("settings-back-to-app").click();
|
|
await expect.poll(() => page.url()).toBe(channelUrl);
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
await expect(threadPanel).toBeVisible();
|
|
});
|
|
|
|
test("settings shortcut returns without opening search dialog", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
const channelUrl = page.url();
|
|
|
|
// Open search via the ⌘K shortcut so the focus-request counter is non-zero,
|
|
// then close it. The Settings subtree remounts the sidebar + search on close,
|
|
// which must not replay the stale counter and resurrect search.
|
|
await page.evaluate(() => {
|
|
const isMac = /mac|iphone|ipad|ipod/i.test(navigator.platform);
|
|
window.dispatchEvent(
|
|
new KeyboardEvent("keydown", {
|
|
bubbles: true,
|
|
cancelable: true,
|
|
code: "KeyK",
|
|
ctrlKey: !isMac,
|
|
key: "k",
|
|
metaKey: isMac,
|
|
}),
|
|
);
|
|
});
|
|
await expect(page.getByTestId("search-dialog-input")).toBeFocused();
|
|
await page.keyboard.press("Escape");
|
|
await expect(page.getByTestId("search-results")).not.toBeVisible();
|
|
|
|
await page.keyboard.press(
|
|
process.platform === "darwin" ? "Meta+Comma" : "Control+Comma",
|
|
);
|
|
|
|
await expect(page).toHaveURL(/#\/settings/);
|
|
await page.getByTestId("settings-back-to-app").click();
|
|
|
|
await expect.poll(() => page.url()).toBe(channelUrl);
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
await expect(page.getByTestId("search-results")).not.toBeVisible();
|
|
});
|
|
|
|
test("mixed Buzz permalinks render as chips in the composer", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
const channelId = "9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50";
|
|
const owner = "a".repeat(64);
|
|
const pullRequestId = "c".repeat(64);
|
|
const issueId = "b".repeat(64);
|
|
const links = [
|
|
`buzz://message?channel=${channelId}&id=mock-general-welcome`,
|
|
`buzz://channel/${channelId}`,
|
|
`buzz://repo?owner=${owner}&d=buzz-world`,
|
|
`buzz://pr?id=${pullRequestId}&owner=${owner}&d=buzz-world`,
|
|
`buzz://issue?id=${issueId}&owner=${owner}&d=buzz-world`,
|
|
].join(" ");
|
|
const composerInput = page.getByTestId("message-input");
|
|
await composerInput.evaluate((element, text) => {
|
|
const clipboardData = new DataTransfer();
|
|
clipboardData.setData("text/plain", text);
|
|
element.dispatchEvent(
|
|
new ClipboardEvent("paste", {
|
|
bubbles: true,
|
|
cancelable: true,
|
|
clipboardData,
|
|
}),
|
|
);
|
|
}, links);
|
|
|
|
const chips = composerInput.locator('[data-composer-buzz-link=""]');
|
|
await expect(chips).toHaveCount(5);
|
|
await expect(chips.nth(0)).toHaveText("general");
|
|
await expect(chips.nth(1)).toHaveText("general");
|
|
await expect(chips.nth(2)).toHaveText("buzz-world");
|
|
// PR and issue chips both use repository identity only, matching rendered chips.
|
|
await expect(chips.nth(3)).toHaveText("buzz-world");
|
|
await expect(chips.nth(4)).toHaveText("buzz-world");
|
|
await expect(chips.nth(1)).toHaveClass(/inline-chip-icon-channel/);
|
|
await expect(chips.nth(2)).toHaveClass(/inline-chip-icon-repo/);
|
|
await expect(chips.nth(3)).toHaveClass(/inline-chip-icon-pr/);
|
|
await expect(chips.nth(4)).toHaveClass(/inline-chip-icon-issue/);
|
|
for (const index of [0, 1, 2, 3, 4]) {
|
|
const iconMask = await chips
|
|
.nth(index)
|
|
.evaluate((element) =>
|
|
getComputedStyle(element, "::before").getPropertyValue(
|
|
"-webkit-mask-image",
|
|
),
|
|
);
|
|
expect(iconMask).toContain("data:image/svg+xml");
|
|
}
|
|
await expect(composerInput).not.toContainText("buzz://");
|
|
});
|
|
|
|
test("composer Buzz chip labels wrap without orphaning their icons", async ({
|
|
page,
|
|
}) => {
|
|
await page.addInitScript(() => {
|
|
window.__BUZZ_E2E_EXTRA_PROJECT_EVENTS__ = [
|
|
{
|
|
id: "mock-project-relaytoolsobservabilityconsole-main",
|
|
kind: 30617,
|
|
pubkey:
|
|
"953d3363262e86b770419834c53d2446409db6d918a57f8f339d495d54ab001f",
|
|
created_at: Math.floor(Date.now() / 1000) - 60,
|
|
content:
|
|
"Operator tooling and observability console for relay deployments.",
|
|
tags: [
|
|
["d", "relaytoolsobservabilityconsole-main"],
|
|
["name", "relaytoolsobservabilityconsole-main"],
|
|
[
|
|
"description",
|
|
"Operator tooling and observability console for relay deployments.",
|
|
],
|
|
["clone", "https://github.com/block/relay-tools.git"],
|
|
],
|
|
},
|
|
];
|
|
});
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
|
|
const composerInput = page.getByTestId("message-input");
|
|
const repoLink =
|
|
"buzz://repo?owner=953d3363262e86b770419834c53d2446409db6d918a57f8f339d495d54ab001f&d=relaytoolsobservabilityconsole-main";
|
|
await composerInput.evaluate((element, text) => {
|
|
const clipboardData = new DataTransfer();
|
|
clipboardData.setData("text/plain", text);
|
|
element.dispatchEvent(
|
|
new ClipboardEvent("paste", {
|
|
bubbles: true,
|
|
cancelable: true,
|
|
clipboardData,
|
|
}),
|
|
);
|
|
}, repoLink);
|
|
|
|
const chip = composerInput.locator('[data-composer-buzz-link=""]');
|
|
const leadingFragment = chip.locator(".inline-chip-leading-fragment");
|
|
await expect(chip).toHaveText("relaytoolsobservabilityconsole-main");
|
|
const emptyLeadingFragmentHeight = await composerInput.evaluate((element) => {
|
|
const probe = document.createElement("span");
|
|
probe.className = "mention-chip wrapping-inline-chip";
|
|
const leading = document.createElement("span");
|
|
leading.className =
|
|
"inline-chip-leading-fragment inline-chip-with-icon inline-chip-icon-repo";
|
|
const remainder = document.createElement("span");
|
|
remainder.textContent = " leading-space";
|
|
probe.append(leading, remainder);
|
|
element.append(probe);
|
|
const height = leading.getBoundingClientRect().height;
|
|
probe.remove();
|
|
return height;
|
|
});
|
|
expect(emptyLeadingFragmentHeight).toBeGreaterThan(0);
|
|
const chipHeightAtWidth = async (width: number) => {
|
|
await composerInput.evaluate((element, nextWidth) => {
|
|
element.style.width = `${nextWidth}px`;
|
|
}, width);
|
|
return chip.evaluate((element) => {
|
|
const range = document.createRange();
|
|
range.selectNodeContents(element);
|
|
const rects = Array.from(range.getClientRects()).filter(
|
|
(rect) => rect.width > 0 && rect.height > 0,
|
|
);
|
|
return (
|
|
Math.max(...rects.map((rect) => rect.bottom)) -
|
|
Math.min(...rects.map((rect) => rect.top))
|
|
);
|
|
});
|
|
};
|
|
const wideHeight = await chipHeightAtWidth(420);
|
|
const mediumHeight = await chipHeightAtWidth(210);
|
|
const narrowHeight = await chipHeightAtWidth(90);
|
|
expect(mediumHeight).toBeGreaterThan(wideHeight);
|
|
expect(narrowHeight).toBeGreaterThan(mediumHeight);
|
|
await expect(chip).toHaveCSS("display", "inline");
|
|
await expect(chip).toHaveCSS("overflow-wrap", "anywhere");
|
|
await expect(leadingFragment).toHaveText("relay");
|
|
await expect
|
|
.poll(() =>
|
|
chip.evaluate((element) => {
|
|
const chipRange = document.createRange();
|
|
chipRange.selectNodeContents(element);
|
|
const leading = element.querySelector(".inline-chip-leading-fragment");
|
|
const composerBounds = element
|
|
.closest('[data-testid="message-input"]')
|
|
?.getBoundingClientRect();
|
|
const leadingBounds = leading?.getBoundingClientRect();
|
|
return {
|
|
chipWraps:
|
|
new Set(
|
|
Array.from(chipRange.getClientRects(), (rect) =>
|
|
Math.round(rect.y),
|
|
),
|
|
).size >= 2,
|
|
leadingContained:
|
|
Boolean(composerBounds && leadingBounds) &&
|
|
leadingBounds.right <= composerBounds.right,
|
|
leadingLineBoxes: leading?.getClientRects().length ?? 0,
|
|
};
|
|
}),
|
|
)
|
|
.toMatchObject({
|
|
chipWraps: true,
|
|
leadingContained: true,
|
|
leadingLineBoxes: 1,
|
|
});
|
|
|
|
await expect(chip).toHaveAttribute(
|
|
"title",
|
|
"Open repository relaytoolsobservabilityconsole-main",
|
|
);
|
|
await chipHeightAtWidth(420);
|
|
await composerInput.press("End");
|
|
await composerInput.pressSequentially(" after");
|
|
await expect(composerInput).toContainText(
|
|
"relaytoolsobservabilityconsole-main after",
|
|
);
|
|
await expect(chip).toHaveText("relaytoolsobservabilityconsole-main");
|
|
await page.getByTestId("send-message").click();
|
|
|
|
const sentRow = page.getByTestId("message-row").last();
|
|
const sentChip = sentRow.getByRole("button", {
|
|
name: "Open repository relaytoolsobservabilityconsole-main",
|
|
});
|
|
await expect(sentChip).toBeVisible();
|
|
await expect(sentChip).toHaveClass(/wrapping-inline-chip/);
|
|
// The optimistic message row can be re-created when the relay echo lands,
|
|
// dropping any inline style applied before the swap — apply the width and
|
|
// measure in one evaluate, polling until the chip settles into wrapped
|
|
// fragments with the expected cloned-box metrics.
|
|
await expect
|
|
.poll(() =>
|
|
sentChip.evaluate((element) => {
|
|
const container = element.parentElement;
|
|
if (container) container.style.width = "220px";
|
|
const chipStyle = getComputedStyle(element);
|
|
const rects = Array.from(element.getClientRects()).filter(
|
|
(rect) => rect.width > 0 && rect.height > 0,
|
|
);
|
|
const fragmentTops = Array.from(
|
|
new Set(rects.map((rect) => Math.round(rect.top))),
|
|
).sort((a, b) => a - b);
|
|
return {
|
|
boxDecorationBreak:
|
|
chipStyle.getPropertyValue("box-decoration-break") ||
|
|
chipStyle.getPropertyValue("-webkit-box-decoration-break"),
|
|
fragmentStep:
|
|
fragmentTops.length > 1 ? fragmentTops[1] - fragmentTops[0] : null,
|
|
lineHeight: Number.parseFloat(chipStyle.lineHeight),
|
|
wrapped: rects.length >= 2,
|
|
};
|
|
}),
|
|
)
|
|
.toMatchObject({
|
|
boxDecorationBreak: "clone",
|
|
fragmentStep: 22,
|
|
lineHeight: 22,
|
|
wrapped: true,
|
|
});
|
|
|
|
// The send and the wrap settle the timeline at its floor over several
|
|
// frames, and Radix closes an open tooltip whenever an ancestor of its
|
|
// trigger scrolls. That settle scrolls only when layout changes, and it ends
|
|
// at the floor. So focus the chip once the timeline sits at its floor and
|
|
// holds there for two frames: a timeline that hasn't started settling yet
|
|
// isn't at the floor. The send's ack is one more layout change: it drops
|
|
// the row's "Sending…" status, and the confirmed row can lose its header.
|
|
// Wait for it first, so the floor the poll sees is the final one.
|
|
await expect(sentRow.getByTestId("message-send-status")).toHaveCount(0);
|
|
const timeline = page.getByTestId("message-timeline");
|
|
await expect
|
|
.poll(() =>
|
|
timeline.evaluate(
|
|
(element) =>
|
|
new Promise<boolean>((resolve) => {
|
|
const atFloor = () =>
|
|
element.scrollHeight - element.clientHeight - element.scrollTop <=
|
|
1;
|
|
if (!atFloor()) {
|
|
resolve(false);
|
|
return;
|
|
}
|
|
const scrollTop = element.scrollTop;
|
|
requestAnimationFrame(() =>
|
|
requestAnimationFrame(() =>
|
|
resolve(atFloor() && element.scrollTop === scrollTop),
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
)
|
|
.toBe(true);
|
|
|
|
const tooltip = page.getByRole("tooltip");
|
|
await sentChip.focus();
|
|
const positionOverFragment = async (index: number) => {
|
|
// Virtua sets pointer-events: none on the timeline's rows while the list
|
|
// scrolls and clears it 150 ms after the last scroll event, longer than
|
|
// the floor wait's two frames. A move in that window misses the chip, and
|
|
// nothing sends it a pointermove once the rows take pointer events again,
|
|
// so the tooltip stays where focus opened it. Move only once the
|
|
// fragment's centre hit-tests to the chip.
|
|
let cursorX = Number.NaN;
|
|
let cursorY = Number.NaN;
|
|
await expect
|
|
.poll(async () => {
|
|
const fragment = await sentChip.evaluate((element, fragmentIndex) => {
|
|
const container = element.parentElement;
|
|
if (container) container.style.width = "220px";
|
|
const rects = Array.from(element.getClientRects()).filter(
|
|
(rect) => rect.width > 0 && rect.height > 0,
|
|
);
|
|
const rect = rects.at(fragmentIndex);
|
|
if (!rect) return null;
|
|
const x = rect.left + rect.width / 2;
|
|
const y = rect.top + rect.height / 2;
|
|
return {
|
|
hitsChip: element.contains(document.elementFromPoint(x, y)),
|
|
x,
|
|
y,
|
|
};
|
|
}, index);
|
|
if (!fragment) throw new Error(`Expected chip fragment ${index}`);
|
|
cursorX = fragment.x;
|
|
cursorY = fragment.y;
|
|
return fragment.hitsChip;
|
|
})
|
|
.toBe(true);
|
|
await page.mouse.move(cursorX, cursorY);
|
|
// A closing tooltip stays visible through its exit animation.
|
|
await expect(tooltip).toHaveAttribute("data-state", /open/);
|
|
let tooltipCenter = Number.NaN;
|
|
await expect
|
|
.poll(async () => {
|
|
const tooltipBox = await tooltip.boundingBox();
|
|
if (!tooltipBox) return Number.POSITIVE_INFINITY;
|
|
tooltipCenter = tooltipBox.x + tooltipBox.width / 2;
|
|
return Math.abs(tooltipCenter - cursorX);
|
|
})
|
|
.toBeLessThan(1);
|
|
return {
|
|
cursorX,
|
|
tooltipCenter,
|
|
};
|
|
};
|
|
|
|
const firstTooltip = await positionOverFragment(0);
|
|
const lastTooltip = await positionOverFragment(-1);
|
|
expect(
|
|
Math.abs(firstTooltip.tooltipCenter - firstTooltip.cursorX),
|
|
).toBeLessThan(1);
|
|
expect(
|
|
Math.abs(lastTooltip.tooltipCenter - lastTooltip.cursorX),
|
|
).toBeLessThan(1);
|
|
expect(
|
|
Math.abs(firstTooltip.tooltipCenter - lastTooltip.tooltipCenter),
|
|
).toBeGreaterThan(1);
|
|
});
|
|
|
|
test("message links to visible root messages open the thread panel", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
await expect(page.getByTestId("message-timeline")).toContainText(
|
|
"Welcome to general",
|
|
);
|
|
await page.evaluate(() => {
|
|
(
|
|
window as Window & { __BUZZ_E2E_DEFER_GET_EVENT__?: string | null }
|
|
).__BUZZ_E2E_DEFER_GET_EVENT__ = "mock-general-welcome";
|
|
});
|
|
|
|
const link =
|
|
"buzz://message?channel=9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50&id=mock-general-welcome";
|
|
const composerInput = page.getByTestId("message-input");
|
|
await composerInput.fill("Root link repro #random ");
|
|
await composerInput.focus();
|
|
await composerInput.evaluate((element, href) => {
|
|
const clipboardData = new DataTransfer();
|
|
clipboardData.setData("text/plain", href);
|
|
element.dispatchEvent(
|
|
new ClipboardEvent("paste", {
|
|
bubbles: true,
|
|
cancelable: true,
|
|
clipboardData,
|
|
}),
|
|
);
|
|
}, link);
|
|
const composerLink = composerInput.locator('[data-composer-message-link=""]');
|
|
await expect(composerLink).toHaveText(/general(?: · mock-gen)?/);
|
|
await expect(composerLink).toHaveClass(/mention-chip/);
|
|
await expect(composerLink).toHaveClass(/inline-chip-icon-message/);
|
|
await expect(composerLink).toHaveAttribute("data-buzz-link", "");
|
|
await expect(composerLink).toHaveAttribute("title", "Thread in #general");
|
|
await expect(composerInput).not.toContainText("buzz://message");
|
|
await page.getByTestId("send-message").click();
|
|
|
|
const linkMessage = page
|
|
.getByTestId("message-row")
|
|
.filter({ hasText: "Root link repro" })
|
|
.last();
|
|
await expect(linkMessage).toBeVisible();
|
|
const rootThreadLink = linkMessage.getByRole("button", {
|
|
name: "Open message in channel general",
|
|
});
|
|
await expect(rootThreadLink).toHaveText("general");
|
|
// The sent row can still be mounting here, and boundingBox() then reads
|
|
// null. Poll until the chip has laid out and keep that pending width.
|
|
let pendingChipWidth = 0;
|
|
await expect
|
|
.poll(async () => {
|
|
pendingChipWidth = (await rootThreadLink.boundingBox())?.width ?? 0;
|
|
return pendingChipWidth;
|
|
})
|
|
.toBeGreaterThan(0);
|
|
await expect
|
|
.poll(() =>
|
|
page.evaluate(
|
|
() =>
|
|
(window as Window & { __BUZZ_E2E_GET_EVENT_CALL_COUNT__?: number })
|
|
.__BUZZ_E2E_GET_EVENT_CALL_COUNT__ ?? 0,
|
|
),
|
|
)
|
|
.toBe(1);
|
|
await page.evaluate(() => {
|
|
(
|
|
window as Window & { __BUZZ_E2E_RELEASE_GET_EVENT__?: () => number }
|
|
).__BUZZ_E2E_RELEASE_GET_EVENT__?.();
|
|
});
|
|
await expect(rootThreadLink).toHaveText("general");
|
|
await expect(rootThreadLink).toHaveClass(/mention-chip/);
|
|
await expect(rootThreadLink).toHaveClass(/wrapping-inline-chip/);
|
|
await expect(rootThreadLink).toHaveCSS("display", "inline");
|
|
await expect(rootThreadLink).not.toHaveAttribute("title");
|
|
await expect
|
|
.poll(() =>
|
|
page.evaluate(
|
|
() =>
|
|
(
|
|
window as Window & {
|
|
__BUZZ_E2E_COMMAND_LOG__?: Array<{ command: string }>;
|
|
}
|
|
).__BUZZ_E2E_COMMAND_LOG__?.filter(
|
|
({ command }) => command === "get_event",
|
|
).length ?? 0,
|
|
),
|
|
)
|
|
.toBe(1);
|
|
await hoverUntilMetadataTooltip(page, rootThreadLink);
|
|
const messageTooltip = page.getByRole("tooltip");
|
|
await expect(
|
|
messageTooltip.locator('[data-buzz-tooltip-metadata-content=""]'),
|
|
).toHaveText("Welcome to general");
|
|
// The tooltip proves metadata resolved; the inline chip must still carry the
|
|
// channel label at the exact width it had while the fetch was in flight, and
|
|
// never the fetched snippet or the truncated event hash.
|
|
await expect(rootThreadLink).toHaveText("general");
|
|
expect((await rootThreadLink.boundingBox())?.width).toBe(pendingChipWidth);
|
|
await expect(
|
|
messageTooltip.locator('[data-buzz-tooltip-metadata-content=""]'),
|
|
).toHaveClass(/line-clamp-3/);
|
|
const messageFooter = messageTooltip.locator(
|
|
'[data-buzz-tooltip-metadata-type=""]',
|
|
);
|
|
await expect(messageFooter).toHaveText(
|
|
/#general · .+ · (just now|\d+[mhdw] ago)/,
|
|
);
|
|
await expect(messageFooter).toHaveCSS("white-space", "nowrap");
|
|
await expect(messageFooter).toHaveCSS("overflow", "hidden");
|
|
await expect(messageFooter).toHaveCSS("text-overflow", "ellipsis");
|
|
const messageChipBox = await rootThreadLink.boundingBox();
|
|
const messageTooltipBox = await messageTooltip.boundingBox();
|
|
if (!messageChipBox || !messageTooltipBox) {
|
|
throw new Error("Expected visible message chip and tooltip");
|
|
}
|
|
expect(
|
|
Math.abs(
|
|
messageTooltipBox.x +
|
|
messageTooltipBox.width / 2 -
|
|
(messageChipBox.x + messageChipBox.width / 2),
|
|
),
|
|
).toBeLessThanOrEqual(1);
|
|
await page.getByTestId("chat-title").hover();
|
|
await rootThreadLink.hover();
|
|
await expect(
|
|
page
|
|
.getByRole("tooltip")
|
|
.locator('[data-buzz-tooltip-metadata-content=""]'),
|
|
).toHaveText("Welcome to general");
|
|
await expect
|
|
.poll(() =>
|
|
page.evaluate(
|
|
() =>
|
|
(
|
|
window as Window & {
|
|
__BUZZ_E2E_COMMAND_LOG__?: Array<{ command: string }>;
|
|
}
|
|
).__BUZZ_E2E_COMMAND_LOG__?.filter(
|
|
({ command }) => command === "get_event",
|
|
).length ?? 0,
|
|
),
|
|
)
|
|
.toBe(1);
|
|
const randomChannelLink = linkMessage.getByRole("button", {
|
|
name: "Open channel random",
|
|
});
|
|
await expect(randomChannelLink).toBeVisible();
|
|
await expect(randomChannelLink).toHaveClass(/wrapping-inline-chip/);
|
|
await expect(randomChannelLink).toHaveCSS("display", "inline");
|
|
await expect(
|
|
randomChannelLink.locator(".inline-chip-leading-fragment"),
|
|
).toHaveText("rando");
|
|
await expect(randomChannelLink).not.toHaveAttribute("title");
|
|
await randomChannelLink.hover();
|
|
const channelTooltip = page.getByRole("tooltip");
|
|
await expect(
|
|
channelTooltip.locator('[data-buzz-tooltip-metadata-content=""]'),
|
|
).toHaveText("Off-topic, fun stuff");
|
|
const channelFooter = channelTooltip.locator(
|
|
'[data-buzz-tooltip-metadata-type=""]',
|
|
);
|
|
await expect(channelFooter).toHaveText("Public channel");
|
|
await expect(channelFooter).toHaveCSS("white-space", "normal");
|
|
await expect(channelFooter).toHaveCSS("overflow-wrap", "anywhere");
|
|
await rootThreadLink.hover();
|
|
await rootThreadLink.click({ button: "right" });
|
|
|
|
const linkMenu = page.locator("[data-buzz-link-context-menu]");
|
|
await expect(linkMenu).toBeVisible();
|
|
await randomChannelLink.click({ button: "right" });
|
|
await expect(linkMenu).toHaveCount(1);
|
|
await rootThreadLink.click({ button: "right" });
|
|
await expect(linkMenu).toHaveCount(1);
|
|
await expect(
|
|
linkMenu.getByRole("button", { name: "Open link" }),
|
|
).toBeVisible();
|
|
await linkMenu.getByRole("button", { name: "Copy link" }).click();
|
|
await expect
|
|
.poll(() =>
|
|
page.evaluate(() => {
|
|
return (
|
|
window as Window & {
|
|
__BUZZ_E2E_COMMAND_LOG__?: Array<{
|
|
command: string;
|
|
payload: { text?: string };
|
|
}>;
|
|
}
|
|
).__BUZZ_E2E_COMMAND_LOG__?.findLast(
|
|
({ command }) => command === "copy_text_to_clipboard",
|
|
)?.payload.text;
|
|
}),
|
|
)
|
|
.toBe(link);
|
|
|
|
await rootThreadLink.click({ button: "right" });
|
|
await linkMenu.getByRole("button", { name: "Open link" }).click();
|
|
|
|
const threadPanel = page.getByTestId("message-thread-panel");
|
|
await expect(threadPanel).toBeVisible();
|
|
await expect(page).toHaveURL(/thread=mock-general-welcome/);
|
|
await expect(threadPanel.getByTestId("message-thread-head")).toContainText(
|
|
"Welcome to general",
|
|
);
|
|
});
|
|
|
|
test("direct-message tooltip metadata stays on one physical line", async ({
|
|
page,
|
|
}) => {
|
|
const dmChannelId = "f48efb06-0c93-5025-aac9-2e646bb6bfa8";
|
|
const dmMessageId = "mock-dm-link-one-line";
|
|
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-alice-tyler").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("alice-tyler");
|
|
await page.evaluate((id) => {
|
|
window.__BUZZ_E2E_EMIT_MOCK_MESSAGE__?.({
|
|
channelName: "alice-tyler",
|
|
content: "DM source message",
|
|
id,
|
|
});
|
|
}, dmMessageId);
|
|
|
|
await page.getByTestId("channel-general").click();
|
|
await page
|
|
.getByTestId("message-input")
|
|
.fill(`DM link buzz://message?channel=${dmChannelId}&id=${dmMessageId}`);
|
|
await page.getByTestId("send-message").click();
|
|
|
|
const dmLink = page
|
|
.getByTestId("message-row")
|
|
.filter({ hasText: "DM link" })
|
|
.last()
|
|
.getByRole("button", { name: "Open message in channel alice-tyler" });
|
|
await expect(dmLink).toHaveText("alice-tyler");
|
|
await hoverUntilMetadataTooltip(page, dmLink);
|
|
|
|
const footer = page
|
|
.getByRole("tooltip")
|
|
.locator('[data-buzz-tooltip-metadata-type=""]');
|
|
await expect(footer).toContainText("Direct message with alice-tyler");
|
|
await expect(footer).toHaveCSS("white-space", "nowrap");
|
|
await expect(footer).toHaveCSS("overflow", "hidden");
|
|
await expect(footer).toHaveCSS("text-overflow", "ellipsis");
|
|
await expect
|
|
.poll(() =>
|
|
footer.evaluate((element) => {
|
|
const lineHeight = Number.parseFloat(
|
|
getComputedStyle(element).lineHeight,
|
|
);
|
|
return {
|
|
fitsOneLine: element.scrollHeight <= Math.ceil(lineHeight),
|
|
heightIsClipped: element.clientHeight === element.scrollHeight,
|
|
};
|
|
}),
|
|
)
|
|
.toEqual({ fitsOneLine: true, heightIsClipped: true });
|
|
});
|
|
|
|
test("message links explain when preview metadata is unavailable", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
|
|
const missingMessageId = "f".repeat(64);
|
|
await page
|
|
.getByTestId("message-input")
|
|
.fill(
|
|
`Missing preview buzz://message?channel=9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50&id=${missingMessageId}`,
|
|
);
|
|
await page.getByTestId("send-message").click();
|
|
|
|
const linkMessage = page
|
|
.getByTestId("message-row")
|
|
.filter({ hasText: "Missing preview" })
|
|
.last();
|
|
const missingMessageLink = linkMessage.getByRole("button", {
|
|
name: "Open message in channel general",
|
|
});
|
|
await expect(missingMessageLink).toHaveAccessibleName(
|
|
"Open message in channel general",
|
|
);
|
|
await expect(missingMessageLink).toHaveText("general");
|
|
// The label is metadata-independent now, so gate the hover on the state the
|
|
// failed lookup does change: the unavailable styling.
|
|
await expect(missingMessageLink).toHaveClass(/buzz-link-unavailable/);
|
|
await missingMessageLink.hover();
|
|
const unavailableTooltip = page.getByRole("tooltip");
|
|
await expect(unavailableTooltip).toHaveText("Message unavailable");
|
|
await expect(unavailableTooltip).toHaveCSS("pointer-events", "none");
|
|
|
|
const tooltipBox = await unavailableTooltip.boundingBox();
|
|
if (!tooltipBox) throw new Error("Unavailable tooltip bounds missing");
|
|
await page.mouse.move(
|
|
tooltipBox.x + tooltipBox.width / 2,
|
|
tooltipBox.y + tooltipBox.height / 2,
|
|
);
|
|
await expect(unavailableTooltip).toHaveCount(0);
|
|
});
|
|
|
|
test("message links reopen a closed thread when the same messageId is already in the URL", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto(
|
|
"/#/channels/9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50?messageId=mock-general-welcome",
|
|
);
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
const threadPanel = page.getByTestId("message-thread-panel");
|
|
await expect(threadPanel).toBeVisible();
|
|
await expect(threadPanel.getByTestId("message-thread-head")).toContainText(
|
|
"Welcome to general",
|
|
);
|
|
|
|
await threadPanel.getByRole("button", { name: "Close panel" }).click();
|
|
await expect(threadPanel).not.toBeVisible();
|
|
|
|
const link =
|
|
"buzz://message?channel=9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50&id=mock-general-welcome";
|
|
await page
|
|
.getByTestId("message-input")
|
|
.fill(`Reopen same root link repro ${link}`);
|
|
await page.getByTestId("send-message").click();
|
|
|
|
const linkMessage = page
|
|
.getByTestId("message-row")
|
|
.filter({ hasText: "Reopen same root link repro" })
|
|
.last();
|
|
await expect(linkMessage).toBeVisible();
|
|
const rootThreadLink = linkMessage.getByRole("button", {
|
|
name: "Open message in channel general",
|
|
});
|
|
await expect(rootThreadLink).toHaveText("general");
|
|
await rootThreadLink.click();
|
|
|
|
await expect(threadPanel).toBeVisible();
|
|
await expect(threadPanel.getByTestId("message-thread-head")).toContainText(
|
|
"Welcome to general",
|
|
);
|
|
});
|
|
|
|
test("message deep links survive reload", async ({ page }) => {
|
|
await page.goto(
|
|
`/#/channels/${ENGINEERING_CHANNEL_ID}?messageId=mock-engineering-shipped`,
|
|
);
|
|
|
|
await expect(page.getByTestId("chat-title")).toHaveText("engineering");
|
|
await expect(page.getByTestId("message-timeline")).toContainText(
|
|
"Engineering shipped the desktop build.",
|
|
);
|
|
|
|
await page.reload();
|
|
|
|
await expect(page.getByTestId("chat-title")).toHaveText("engineering");
|
|
await expect(page.getByTestId("message-timeline")).toContainText(
|
|
"Engineering shipped the desktop build.",
|
|
);
|
|
});
|
|
|
|
// Cold-start OS links are queued natively until AppShell mounts its router listener.
|
|
|
|
test("cold-start channel deep link drains after the router mounts", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
pendingNavigationDeepLinks: [
|
|
{
|
|
id: "navigation-channel-1",
|
|
kind: "channel",
|
|
channelId: ENGINEERING_CHANNEL_ID,
|
|
},
|
|
],
|
|
});
|
|
|
|
await page.goto("/");
|
|
|
|
await expect(page.getByTestId("chat-title")).toHaveText("engineering");
|
|
await expect(page).toHaveURL(
|
|
new RegExp(`#/channels/${ENGINEERING_CHANNEL_ID}$`),
|
|
);
|
|
await expect
|
|
.poll(() =>
|
|
page.evaluate(() =>
|
|
(window.__BUZZ_E2E_COMMAND_LOG__ ?? []).filter(
|
|
(entry) =>
|
|
entry.command === "acknowledge_pending_navigation_deep_link",
|
|
),
|
|
),
|
|
)
|
|
.toEqual([
|
|
{
|
|
command: "acknowledge_pending_navigation_deep_link",
|
|
payload: { id: "navigation-channel-1" },
|
|
},
|
|
]);
|
|
});
|
|
|
|
test("cold-start message deep link preserves its thread target", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
pendingNavigationDeepLinks: [
|
|
{
|
|
id: "navigation-message-1",
|
|
kind: "message",
|
|
channelId: WATERCOLOR_CHANNEL_ID,
|
|
messageId: "mock-forum-release-reply",
|
|
threadRootId: "mock-forum-release-thread",
|
|
},
|
|
],
|
|
});
|
|
|
|
await page.goto("/");
|
|
|
|
await expect(page.getByTestId("chat-title")).toHaveText("watercooler");
|
|
await expect(page).toHaveURL(/messageId=mock-forum-release-reply/);
|
|
await expect(page).toHaveURL(/threadRootId=mock-forum-release-thread/);
|
|
});
|