mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
## Summary - Supersedes #1913 with a KLIPY-hosted URL implementation. - Adds KLIPY GIF search and trending results to desktop message and forum composers. - Keeps selected GIFs hosted by KLIPY; Buzz stores only the external URL and media metadata (no imeta tag, since relays only accept hash-backed local `/media/` entries). - Aligns the Emoji/GIF picker with Buzz's standard segmented control, theme surfaces, and motion behavior. ## Relay-to-provider boundary - The relay proxies KLIPY search/share so the `BUZZ_KLIPY_API_KEY` never reaches the desktop; the key stays server-side behind a redacted `Debug` impl. - The dedicated GIF `reqwest` client sets `redirect::Policy::none()`. Because the API key rides in the request path, following a provider `3xx` could replay a key-bearing URL to an attacker-chosen host (an SSRF/key-disclosure primitive). With redirects disabled, a `3xx` returns as a non-success status that the handlers map to a generic `502`; the `Location` target is never read or forwarded. - Admission reuses the established NIP-98, membership, replay, and per-pubkey rate-limit gates, with an upstream response-size cap and allowlisting so KLIPY error bodies never cross the relay boundary. ## Accessibility - Under `prefers-reduced-motion: reduce`, the picker grid renders a static provider poster (a normalized `jpg` asset) instead of the animated preview, or a named static placeholder when no poster is available. It reacts to preference changes while mounted. `no-preference` keeps the animated preview. - Selected GIFs carry their title through `ImetaMedia`'s `displayLabel`, so the composer thumbnail, preview dialog, editor, lightbox, and remove control all derive one non-empty accessible name instead of an empty `Attachment ` label. Ordinary hashed uploads keep their existing hash-derived names. --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Kenny Lopez <klopez4212@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> Signed-off-by: Hayt <9e1c23a3fd83f61da34420e4e88ff1b16e45cafcc0cd9019eb07d4ecfa8ca9b0@buzz.block.builderlab.xyz> Co-authored-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz> Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Co-authored-by: Hayt <9e1c23a3fd83f61da34420e4e88ff1b16e45cafcc0cd9019eb07d4ecfa8ca9b0@buzz.block.builderlab.xyz>
108 lines
3.7 KiB
TypeScript
108 lines
3.7 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { installMockBridge } from "../helpers/bridge";
|
|
|
|
/**
|
|
* Composer tooltips set disableHoverableContent, so they must dismiss the
|
|
* instant the cursor leaves the trigger — including when it slides onto the
|
|
* tooltip popup itself (Radix's default hoverable-content behavior would
|
|
* keep it open, camping it over the message editor).
|
|
*/
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await installMockBridge(page);
|
|
});
|
|
|
|
/** Hover the trigger through the shared dwell, then slide the cursor onto the
|
|
* tooltip popup and assert the tooltip dismisses instead of persisting. */
|
|
async function expectTooltipDismissesOnLeave(
|
|
page: import("@playwright/test").Page,
|
|
trigger: import("@playwright/test").Locator,
|
|
tooltipName: string,
|
|
) {
|
|
await trigger.hover();
|
|
|
|
const tip = page.getByRole("tooltip", { name: tooltipName });
|
|
await page.waitForTimeout(400);
|
|
await expect(tip).toHaveCount(0);
|
|
await expect(tip).toBeVisible({ timeout: 1_000 });
|
|
|
|
// Slide off the trigger onto the tooltip popup.
|
|
const box = await tip.boundingBox();
|
|
if (!box) throw new Error("no tooltip box");
|
|
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, {
|
|
steps: 5,
|
|
});
|
|
|
|
await expect(tip).toBeHidden();
|
|
}
|
|
|
|
test("composer toolbar tooltip dismisses when cursor leaves the trigger", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
await expectTooltipDismissesOnLeave(
|
|
page,
|
|
page.getByTestId("message-insert-mention"),
|
|
"Mention someone",
|
|
);
|
|
});
|
|
|
|
test("adjacent composer tooltips each require a fresh dwell", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
await page.getByTestId("message-insert-mention").hover();
|
|
await page.waitForTimeout(400);
|
|
const mentionTooltip = page.getByRole("tooltip", { name: "Mention someone" });
|
|
await expect(mentionTooltip).toHaveCount(0);
|
|
await expect(mentionTooltip).toBeVisible({ timeout: 1_000 });
|
|
|
|
await page.getByRole("button", { name: "Attach file" }).hover();
|
|
await page.waitForTimeout(400);
|
|
const attachTooltip = page.getByRole("tooltip", { name: "Attach file" });
|
|
await expect(attachTooltip).toHaveCount(0);
|
|
await expect(attachTooltip).toBeVisible({ timeout: 1_000 });
|
|
});
|
|
|
|
test("formatting sub-toolbar tooltip dismisses when cursor leaves the trigger", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
// Open the formatting sub-toolbar (Bold / Italic / lists / Quote …).
|
|
await page.getByRole("button", { name: "Toggle formatting" }).first().click();
|
|
|
|
const bold = page.getByRole("button", { name: "Bold" });
|
|
await expect(bold).toBeVisible();
|
|
// The formatting strip animates into place; wait for its delayed entrance to
|
|
// settle so the pointer remains over the trigger for the full dwell.
|
|
await page.waitForTimeout(300);
|
|
|
|
// Tooltip text is "<label> (<shortcut>)" for items that carry a shortcut.
|
|
await expectTooltipDismissesOnLeave(page, bold, "Bold (⌘B)");
|
|
});
|
|
|
|
test("emoji picker tooltip dismisses when cursor leaves the trigger", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/");
|
|
await page.getByTestId("channel-general").click();
|
|
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
|
|
|
// The emoji button wraps its tooltip around a nested PopoverTrigger, so
|
|
// cover it separately from the plain toolbar buttons.
|
|
await expectTooltipDismissesOnLeave(
|
|
page,
|
|
page.getByTestId("composer-emoji-button"),
|
|
"Emoji",
|
|
);
|
|
});
|