Skip to content

Commit af11a14

Browse files
committed
Fix standalone toast hosts and update polish regression coverage
Signed-off-by: Arjun Mahanti <[email protected]>
1 parent f4591e1 commit af11a14

16 files changed

Lines changed: 277 additions & 159 deletions

‎src/bundled/emoji/EmojiPicker.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ export function EmojiPicker({
8787
session.emoji.snapshot,
8888
);
8989
useLayoutEffect(() => {
90-
// The popover is positioned against the action row; intermediate tool groups
90+
// The popover is positioned against the composer; intermediate tool groups
9191
// may be narrower and are not its available width.
9292
const container = reaction
9393
? document.documentElement
94-
: controls.current?.offsetParent;
94+
: (controls.current?.closest("form") ?? controls.current?.offsetParent);
9595
if (!open || disabled || !(container instanceof HTMLElement)) return;
9696
const resize = () =>
9797
setLayout({

‎tests/browser/agents.spec.mjs‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ test("Old Buzz library reads the existing library with exact linked keys and ses
4747
await agents
4848
.getByRole("button", { name: "A Brain: 2 identities", exact: true })
4949
.click();
50+
const identities = page.getByRole("dialog", {
51+
name: "A Brain identities",
52+
exact: true,
53+
});
5054
for (const npub of npubs)
51-
await expect(agents.getByText(npub, { exact: true })).toBeVisible();
55+
await expect(identities.getByText(npub, { exact: true })).toBeVisible();
5256
for (const key of keys)
53-
await expect(agents.getByText(key, { exact: true })).toHaveCount(0);
57+
await expect(identities.getByText(key, { exact: true })).toHaveCount(0);
58+
await page.keyboard.press("Escape");
5459
await expect(
5560
page.getByText(/current Buzz library, read-only/),
5661
).toBeVisible();
@@ -184,8 +189,10 @@ test("Old Buzz library reads the existing library with exact linked keys and ses
184189
await agents
185190
.getByRole("button", { name: "A Brain: 2 identities", exact: true })
186191
.click();
192+
187193
for (const npub of npubs)
188-
await expect(agents.getByText(npub, { exact: true })).toBeVisible();
194+
await expect(identities.getByText(npub, { exact: true })).toBeVisible();
195+
await page.keyboard.press("Escape");
189196
await expect(page.getByText(/Archive visibility is unknown/)).toBeVisible();
190197
await page
191198
.getByRole("button", { name: "Toggle missing archive", exact: true })

‎tests/browser/avatar-shapes.spec.mjs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,18 @@ test("avatar shapes paint at every size and preserve pointer/keyboard profile co
157157
await threadControl.hover();
158158
const threadShape = await threadControl.evaluate((element) => ({
159159
control: getComputedStyle(element).maskImage,
160+
radius: getComputedStyle(element).borderRadius,
160161
background: getComputedStyle(element, "::before").maskImage,
161162
avatar: getComputedStyle(
162163
element.querySelector('[data-avatar-shape="squircle"]'),
163164
).maskImage,
164165
}));
165166
expect(threadShape.control).toBe("none");
166-
expect(threadShape.background.startsWith(threadShape.avatar)).toBe(true);
167+
expect(threadShape.background).toBe("none");
168+
expect(parseFloat(threadShape.radius)).toBeGreaterThanOrEqual(
169+
(await threadControl.boundingBox()).height / 2,
170+
);
171+
expect(threadShape.avatar).not.toBe("none");
167172
await threadControl.screenshot({
168173
path: testInfo.outputPath("agent-first-thread-hover.png"),
169174
});

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,20 @@ test("message actions reveal, copy, restore focus and reply across responsive la
5050
await page
5151
.getByRole("menuitem", { name: "Copy message", exact: true })
5252
.click();
53-
await expect(row.getByRole("status")).toHaveText("Message copied");
53+
await expect(
54+
page
55+
.getByRole("region", { name: "App notifications" })
56+
.getByText("Message copied", { exact: true }),
57+
).toBeVisible();
5458
expect(await page.evaluate(() => window.copiedMessages)).toEqual([
5559
event.content,
5660
]);
5761
await row.getByRole("button", { name: "Copy link", exact: true }).click();
58-
await expect(row.getByRole("status")).toHaveText("Link copied");
62+
await expect(
63+
page
64+
.getByRole("region", { name: "App notifications" })
65+
.getByText("Link copied", { exact: true }),
66+
).toBeVisible();
5967
const copiedLink = await page.evaluate(() => window.copiedMessages.at(-1));
6068
expect(copiedLink).toBe(`buzz://message?channel=alpha&id=${event.id}`);
6169
await row.getByRole("button", { name: "Reply", exact: true }).click();
@@ -185,7 +193,11 @@ test("copied Buzz links and the desktop alias reveal their destination from a co
185193
);
186194
await row.hover();
187195
await row.getByRole("button", { name: "Copy link", exact: true }).click();
188-
await expect(row.getByRole("status")).toHaveText("Link copied");
196+
await expect(
197+
page
198+
.getByRole("region", { name: "App notifications" })
199+
.getByText("Link copied", { exact: true }),
200+
).toBeVisible();
189201
const copiedLink = await page.evaluate(() => window.copiedMessageLink);
190202
expect(copiedLink).toBe(`buzz://message?channel=alpha&id=${event.id}`);
191203
const sharedConversation = page

‎tests/browser/profile-channel-focus.spec.mjs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ async function expectPaintedRing(page, list, row) {
88
expect(
99
await row.evaluate((element) => element.matches(":focus-visible")),
1010
).toBe(true);
11-
const bounds = await list.boundingBox();
11+
const listBounds = await list.boundingBox();
12+
// Navigation rows paint their focus ring outside the unbordered list.
13+
const bounds = {
14+
x: listBounds.x - 4,
15+
y: listBounds.y - 4,
16+
width: listBounds.width + 8,
17+
height: listBounds.height + 8,
18+
};
1219
const image = await page.screenshot({
1320
clip: {
1421
x: Math.floor(bounds.x),
@@ -81,7 +88,7 @@ test("profile channel focus ring paints on one row and both list boundaries", as
8188
await page
8289
.locator("html")
8390
.evaluate((html) => html.setAttribute("data-keyboard-navigation", ""));
84-
await single.getByRole("button", { name: "#One" }).focus();
91+
await single.getByRole("button", { name: "One" }).focus();
8592
await expectPaintedRing(page, single, single.getByRole("button"));
8693

8794
await panel.getByRole("button", { name: "Close channel panel" }).click();

‎tests/browser/profiles.spec.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ test("profile plumbing: exact avatar/mention targets, thread enrichment, lifecyc
179179
await expect(panel.getByRole("tab", { name: "Memories" })).toBeVisible();
180180
await panel.getByRole("tab", { name: "Channels" }).click();
181181
await expect(panel.getByRole("region", { name: "Channels" })).toContainText(
182-
"#One",
182+
"One",
183183
);
184184
expect(
185185
await page.evaluate(() => window.profilesFixture.report.memoryReads),

‎tests/browser/reactions.spec.mjs‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,51 @@ sourceTest(
347347
).toHaveCount(0);
348348
},
349349
);
350+
351+
// Browser-only: the documented gallery owns a separate root/iframe, so app-level
352+
// provider coverage cannot prove that its portaled clipboard feedback is wired.
353+
sourceTest(
354+
"standalone message gallery hosts clipboard success and failure toasts",
355+
async ({ page }) => {
356+
const errors = [];
357+
page.on("pageerror", (error) => errors.push(String(error)));
358+
await page.addInitScript(() => {
359+
let attempts = 0;
360+
Object.defineProperty(navigator, "clipboard", {
361+
configurable: true,
362+
value: {
363+
writeText: async () => {
364+
if (++attempts === 1) throw new Error("Clipboard unavailable");
365+
},
366+
},
367+
});
368+
});
369+
await page.goto("/tests/fixtures/message-gallery.html");
370+
const row = page.locator("[data-message-id]").first();
371+
const notifications = page.getByRole("region", {
372+
name: "App notifications",
373+
});
374+
const copy = async () => {
375+
await row.hover();
376+
await row
377+
.getByRole("button", { name: "More message actions", exact: true })
378+
.click();
379+
await page
380+
.getByRole("menuitem", { name: "Copy message", exact: true })
381+
.click();
382+
};
383+
await copy();
384+
await expect(
385+
notifications.getByText(
386+
"Couldn’t copy. Try again from the message menu.",
387+
{ exact: true },
388+
),
389+
).toBeVisible();
390+
await copy();
391+
await expect(
392+
notifications.getByText("Message copied", { exact: true }),
393+
).toBeVisible();
394+
await expect(row).toBeVisible();
395+
expect(errors).toEqual([]);
396+
},
397+
);

‎tests/fixtures/avatar-shapes.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ToastProvider } from "../../src/shared/design-system/ui/Toast";
12
// Real avatar consumers with local display-only data, no session/broker/network reads.
23
import "../../src/shared/styles/globals.css";
34
import { useState } from "react";
@@ -123,4 +124,8 @@ function Fixture() {
123124
}
124125
const root = document.getElementById("root");
125126
if (!root) throw new Error("Missing fixture root");
126-
createRoot(root).render(<Fixture />);
127+
createRoot(root).render(
128+
<ToastProvider>
129+
<Fixture />
130+
</ToastProvider>,
131+
);

‎tests/fixtures/conversation.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ToastProvider } from "../../src/shared/design-system/ui/Toast";
12
// Automated boundary proof only. No live broker, persistent messages or real keys.
23
import { Context } from "@deepseek-ai/cordis";
34
import {
@@ -359,7 +360,9 @@ const root = document.getElementById("root");
359360
if (!root) throw new Error("Missing fixture root");
360361
createRoot(root).render(
361362
<StrictMode>
362-
<Fixture />
363+
<ToastProvider>
364+
<Fixture />
365+
</ToastProvider>
363366
</StrictMode>,
364367
);
365368
window.addEventListener("pagehide", () => {

‎tests/fixtures/diffs.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ToastProvider } from "../../src/shared/design-system/ui/Toast";
12
// Local signed fixture through real session history/thread/live owners. No relay writes.
23
import { Context } from "@deepseek-ai/cordis";
34
import { useEffect, useState, useSyncExternalStore } from "react";
@@ -225,4 +226,9 @@ function Preview() {
225226
);
226227
}
227228
const element = document.getElementById("root");
228-
if (element) createRoot(element).render(<Preview />);
229+
if (element)
230+
createRoot(element).render(
231+
<ToastProvider>
232+
<Preview />
233+
</ToastProvider>,
234+
);

0 commit comments

Comments
 (0)