Files
kandev/apps/web/e2e/tests/chat/attachment-paste-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

44 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test, expect } from "../../fixtures/test-base";
import { openTaskSession, waitForLatestSessionDone } from "../../helpers/session";
test.describe("browser image paste feedback", () => {
test("warns when copied image content has no readable file", async ({
testPage,
apiClient,
seedData,
}) => {
const task = await apiClient.createTaskWithAgent(
seedData.workspaceId,
"Unreadable pasted image warning",
seedData.agentProfileId,
{
description: "/e2e:simple-message",
workflow_id: seedData.workflowId,
workflow_step_id: seedData.startStepId,
repository_ids: [seedData.repositoryId],
},
);
await waitForLatestSessionDone(apiClient, task.id, 1, "Wait for paste warning task");
const session = await openTaskSession(testPage, task.id);
await session.waitForChatIdle({ timeout: 30_000 });
const editor = session.activeChat().locator(".tiptap.ProseMirror").first();
await expect(editor).toBeEditable();
await editor.evaluate((element) => {
const clipboardData = new DataTransfer();
clipboardData.items.add(
'<img src="https://images.example.test/large-image.png" alt="">',
"text/html",
);
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: "Pasted image couldn’t be attached" });
await expect(warning).toContainText("Save the image, then attach the file instead.");
});
});