b082d5e1b9
Delete the two byte-identical local formatBytes copies from the chat-attachment
modules and repoint all call sites at the canonical lib/utils/format-bytes.ts,
which its own doc comment asks new code to use.
The copies had no upper clamp (>= 1 TB rendered "1 undefined") and no NaN or
negative guard (NaN rendered "NaN undefined"). Size labels now carry one
decimal ("10.0 MB" instead of "10 MB") because the canonical helper does not
strip a trailing zero; unit and e2e expectations updated to match.
45 lines
1.7 KiB
TypeScript
45 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.0 MB. The maximum file size is 10.0 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);
|
|
});
|