Files
kandev/apps/web/e2e/tests/task/create-task-attachment-warning.spec.ts
T
José Almeida 85820e4a43 fix(web): warn when pasted attachments are too large (#1983)
* fix(web): warn when pasted attachment is too large

* test(web): provide toast context to chat input tests

* fix(web): warn when browser image paste lacks file data

* fix(web): warn about oversized new task attachments

* fix(web): keep toasts above modal overlays

* fix(web): handle file-list-only dialog pastes

* fix(web): avoid parsing clipboard HTML

* fix(web): handle attachment paste edge cases

* fix(web): improve attachment limit feedback

* fix(web): show aggregate attachment limit feedback
2026-07-27 17:19:02 +01:00

43 lines
1.7 KiB
TypeScript

import { test, expect } from "../../fixtures/test-base";
import { useRegularMode } from "../../helpers/regular-mode";
import { KanbanPage } from "../../pages/kanban-page";
useRegularMode();
test("warns when a pasted image is too large for a new task", async ({ testPage }) => {
const kanban = new KanbanPage(testPage);
await kanban.goto();
await kanban.createTaskButton.first().click();
const prompt = testPage.getByTestId("task-description-input");
await expect(prompt).toBeEditable();
await prompt.evaluate((element) => {
const image = new File([new Uint8Array(14 * 1024 * 1024)], "copied-image.png", {
type: "image/png",
});
const clipboardData = new DataTransfer();
clipboardData.items.add(image);
const pasteEvent = new Event("paste", { bubbles: true, cancelable: true });
Object.defineProperty(pasteEvent, "clipboardData", { value: clipboardData });
element.dispatchEvent(pasteEvent);
});
const warning = testPage
.getByTestId("toast-message")
.filter({ hasText: "Attachment is too large" });
await expect(warning).toContainText("copied-image.png is 14 MB. The maximum file size is 10 MB.");
const overlay = testPage.locator('[data-slot="dialog-overlay"]:visible');
await expect(overlay).toBeVisible();
const [toastZIndex, overlayZIndex] = await Promise.all([
testPage
.getByTestId("toast-container")
.evaluate((element) => Number.parseInt(getComputedStyle(element).zIndex, 10)),
overlay.evaluate((element) => Number.parseInt(getComputedStyle(element).zIndex, 10)),
]);
expect(
toastZIndex,
"attachment warning should render above the task dialog overlay",
).toBeGreaterThan(overlayZIndex);
});