Skip to content

Commit 9cc3edf

Browse files
committed
Preserve palette focus rings and verify repeated reaction toggles
Signed-off-by: Arjun Mahanti <[email protected]>
1 parent 90c60c3 commit 9cc3edf

5 files changed

Lines changed: 86 additions & 5 deletions

File tree

‎src/app/AppearanceSettings.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function AppearanceSettings({
115115
>
116116
<div
117117
data-message-colors
118-
className="grid auto-cols-max grid-flow-col gap-2 overflow-x-auto"
118+
className="grid auto-cols-max grid-flow-col gap-2 overflow-x-auto p-1 scroll-p-1 [&>button]:scroll-m-1"
119119
>
120120
{BUBBLE_COLORS.map((color) => {
121121
const colorLabel =

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,12 @@ test("message actions reveal, copy, restore focus and reply across responsive la
209209
}),
210210
).toBeVisible();
211211
await root.getByRole("button", { name: "👍: You", exact: true }).click();
212-
await expect(root.getByRole("button", { name: /👍: 1/ })).toHaveCount(0);
213-
await expect(row.getByRole("button", { name: /👍: 1/ })).toHaveCount(0);
212+
await expect(
213+
root.getByRole("button", { name: "👍: You", exact: true }),
214+
).toHaveCount(0);
215+
await expect(
216+
row.getByRole("button", { name: "👍: You", exact: true }),
217+
).toHaveCount(0);
214218
await expect
215219
.poll(
216220
() =>
@@ -380,7 +384,9 @@ test("DM actions open the correct reply thread", async ({ page, app }) => {
380384
}),
381385
).toBeVisible();
382386
await row.getByRole("button", { name: "👍: You", exact: true }).click();
383-
await expect(row.getByRole("button", { name: /👍: 1/ })).toHaveCount(0);
387+
await expect(
388+
row.getByRole("button", { name: "👍: You", exact: true }),
389+
).toHaveCount(0);
384390
await expect
385391
.poll(
386392
() =>

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,54 @@ test("comment actions revealed while the drawer slides realign when it settles",
612612
await expect.poll(anchoring).toEqual({ ...settled, anchored: true });
613613
await shown();
614614
});
615+
616+
// Real pointer hit testing and preview transitions cannot be proved in jsdom.
617+
test("every repeated reaction toggles my reaction while its preview is open", async ({
618+
page,
619+
}) => {
620+
await page.goto("/tests/fixtures/emoji.html?reactions&repeated");
621+
const row = page.locator("[data-message-id]").first();
622+
const buttons = row.locator('button[data-reaction="😂"]');
623+
await expect(buttons).toHaveCount(2);
624+
const authors = await buttons.evaluateAll((nodes) =>
625+
nodes.map((node) => node.dataset.reactionAuthor),
626+
);
627+
for (const author of authors) {
628+
const button = row.locator(
629+
`button[data-reaction="😂"][data-reaction-author="${author}"]`,
630+
);
631+
await button.hover();
632+
await expect(page.locator(".buzz-preview-card[data-open]")).toBeVisible();
633+
await button.click();
634+
const mine = row.getByRole("button", { name: "😂: You", exact: true });
635+
await expect(mine).toBeVisible();
636+
await expect(button).toHaveAttribute("aria-disabled", "false");
637+
await button.click();
638+
await expect(mine).toHaveCount(0);
639+
await expect(buttons).toHaveCount(2);
640+
await button.click();
641+
await expect(mine).toBeVisible();
642+
await expect(mine).toHaveAttribute("aria-disabled", "false");
643+
await mine.hover();
644+
await expect(page.locator(".buzz-preview-card[data-open]")).toBeVisible();
645+
await mine.click();
646+
await expect(mine).toHaveCount(0);
647+
}
648+
});
649+
650+
// A direct pointer click does not wait for preview handoff animations to settle.
651+
test("clicking the second reaction during preview handoff toggles it", async ({
652+
page,
653+
}) => {
654+
await page.goto("/tests/fixtures/emoji.html?reactions&repeated&narrow");
655+
const row = page.locator("[data-message-id]").first();
656+
const buttons = row.locator('button[data-reaction="😂"]');
657+
await expect(buttons).toHaveCount(2);
658+
await buttons.first().hover();
659+
await expect(page.locator(".buzz-preview-card[data-open]")).toBeVisible();
660+
const box = await buttons.nth(1).boundingBox();
661+
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
662+
await expect(
663+
row.getByRole("button", { name: "😂: You", exact: true }),
664+
).toBeVisible();
665+
});

‎tests/browser/plugin-import.spec.mjs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ test("Settings controls scale together and keep enlarged labels reachable", asyn
269269
await checkButtons(appearance, scale);
270270
const colors = appearance.locator("[data-message-colors] button");
271271
await colors.first().focus();
272+
await page.keyboard.press("Shift+Tab");
273+
await page.keyboard.press("Tab");
272274
for (let index = 0; index < 6; index++) {
273275
if (index) await page.keyboard.press("Tab");
274276
await expect(colors.nth(index)).toBeFocused();
@@ -279,7 +281,17 @@ test("Settings controls scale together and keep enlarged labels reachable", asyn
279281
const palette = button
280282
.closest("[data-message-colors]")
281283
.getBoundingClientRect();
282-
return box.left >= palette.left && box.right <= palette.right;
284+
const style = getComputedStyle(button);
285+
const ring =
286+
parseFloat(style.outlineWidth) +
287+
parseFloat(style.outlineOffset);
288+
return (
289+
ring === 4 &&
290+
box.left - ring >= palette.left &&
291+
box.right + ring <= palette.right &&
292+
box.top - ring >= palette.top &&
293+
box.bottom + ring <= palette.bottom
294+
);
283295
}),
284296
)
285297
.toBe(true);

‎tests/fixtures/emoji.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,16 @@ const sessions = ["a", "b"].map((community) => {
190190
tags: [["e", root.id]],
191191
}),
192192
);
193+
const repeatedReactions = new URLSearchParams(location.search).has("repeated")
194+
? [member, keypair()].map((key, index) =>
195+
signed(key, {
196+
kind: 7,
197+
content: "😂",
198+
created_at: 30 + index,
199+
tags: [["e", root.id]],
200+
}),
201+
)
202+
: [];
193203
const ownReaction = signed(viewer, {
194204
kind: 7,
195205
content: "✅",
@@ -244,6 +254,7 @@ const sessions = ["a", "b"].map((community) => {
244254
reaction,
245255
...(wrap ? [...wrapReactions, ownReaction] : []),
246256
...longReactions,
257+
...repeatedReactions,
247258
]);
248259
return {
249260
...owner,
@@ -254,6 +265,7 @@ const sessions = ["a", "b"].map((community) => {
254265
reaction,
255266
...(wrap ? [...wrapReactions, ownReaction] : []),
256267
...longReactions,
268+
...repeatedReactions,
257269
broken,
258270
unloaded,
259271
single,

0 commit comments

Comments
 (0)