* fix(e2e): wait for shell-ready before reaction assertions after reload Bootstrap can still be in flight after domcontentloaded on reload; match #94/#87 by waiting on data-ready and the composer before asserting persisted message reactions. Co-authored-by: cynarAI <cynarAI@users.noreply.github.com> * fix(e2e): shell-ready waits on transport reload and /app redirect Apply waitForChatComposer after messaging-transport reload and allow more time for /app to redirect before asserting the composer. Co-authored-by: cynarAI <cynarAI@users.noreply.github.com> * ci: retrigger Product CI after team-computer flake Co-authored-by: cynarAI <cynarAI@users.noreply.github.com> * ci: retrigger Web E2E after runner OOM (exit 137) Co-authored-by: cynarAI <cynarAI@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: cynarAI <cynarAI@users.noreply.github.com> (cherry picked from commit 6248b6c0c9b2dd07563dbac981bd43032d324989)
66 lines
3.0 KiB
TypeScript
66 lines
3.0 KiB
TypeScript
import { expect, type Page, test } from "@playwright/test";
|
|
import { captureScreenshot, completeOnboarding, signup, waitForChatComposer } from "./helpers";
|
|
|
|
async function openComposer(page: Page) {
|
|
const stamp = Date.now();
|
|
await signup(page, `composer-paste-${stamp}@rakazo.test`, "password12", "Paste Test");
|
|
await completeOnboarding(page);
|
|
await page.goto("/app", { waitUntil: "domcontentloaded" });
|
|
await page.waitForURL(/\/app\/[^/]+$/, { timeout: 60_000 });
|
|
await waitForChatComposer(page);
|
|
return page.getByRole("combobox", { name: /Message/ });
|
|
}
|
|
|
|
test("pasting an image into the composer creates an attachment", async ({ page }, testInfo) => {
|
|
const composer = await openComposer(page);
|
|
await composer.click();
|
|
await page.evaluate(() => {
|
|
const target = document.querySelector("textarea[name='chat-message']");
|
|
if (!target) throw new Error("composer textarea not found");
|
|
const bytes = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
const file = new File([bytes], "paste.png", { type: "image/png" });
|
|
const clipboardData = {
|
|
files: [file],
|
|
types: ["Files"],
|
|
items: [{ kind: "file" }],
|
|
getData: () => "",
|
|
};
|
|
const event = new Event("paste", { bubbles: true, cancelable: true });
|
|
Object.defineProperty(event, "clipboardData", { value: clipboardData });
|
|
target.dispatchEvent(event);
|
|
});
|
|
await expect(page.getByRole("button", { name: "Remove paste.png" })).toBeVisible();
|
|
await captureScreenshot(page, testInfo, "composer-paste-attachment");
|
|
});
|
|
|
|
test("pasting text into the composer still inserts text", async ({ page, context }) => {
|
|
const composer = await openComposer(page);
|
|
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
|
await page.evaluate(() => navigator.clipboard.writeText("pasted words"));
|
|
await composer.click();
|
|
await page.keyboard.press("ControlOrMeta+v");
|
|
await expect(composer).toHaveValue("pasted words");
|
|
});
|
|
|
|
test("pasting an image with text keeps the attachment and inserts text", async ({ page }) => {
|
|
const composer = await openComposer(page);
|
|
await composer.click();
|
|
await page.evaluate(() => {
|
|
const target = document.querySelector("textarea[name='chat-message']");
|
|
if (!(target instanceof HTMLTextAreaElement)) throw new Error("composer textarea not found");
|
|
const bytes = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
const file = new File([bytes], "mixed.png", { type: "image/png" });
|
|
const clipboardData = {
|
|
files: [file],
|
|
types: ["Files", "text/plain"],
|
|
items: [{ kind: "file" }, { kind: "string" }],
|
|
getData: (type: string) => (type === "text/plain" ? "caption text" : ""),
|
|
};
|
|
const event = new Event("paste", { bubbles: true, cancelable: true });
|
|
Object.defineProperty(event, "clipboardData", { value: clipboardData });
|
|
target.dispatchEvent(event);
|
|
});
|
|
await expect(page.getByRole("button", { name: "Remove mixed.png" })).toBeVisible();
|
|
await expect(composer).toHaveValue("caption text");
|
|
});
|