fix: update drag and drop test (#5048)
* refactor: Improve wait time for modal in drag and drop test * ✨ (dragAndDrop.spec.ts): update file path to read collection.json from the correct location 🐛 (dragAndDrop.spec.ts): increase timeout for waiting for "uploaded successfully" text to prevent test failures * ✨ (dragAndDrop.spec.ts): Add tests for drag and drop functionality to ensure users can drag and drop collections and flows without crashing the application 📝 (simulate-drag-and-drop.ts): Add utility function to simulate drag and drop events in tests for improved test coverage and functionality * add debouncing time on file upload * [autofix.ci] apply automated fixes --------- Co-authored-by: cristhianzl <cristhian.lousa@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
2c56177ef1
commit
12a753d6b6
5 changed files with 1246 additions and 49 deletions
31
src/frontend/tests/utils/simulate-drag-and-drop.ts
Normal file
31
src/frontend/tests/utils/simulate-drag-and-drop.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { Page } from "@playwright/test";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
export async function simulateDragAndDrop(
|
||||
page: Page,
|
||||
filePath: string,
|
||||
dropSelector: string,
|
||||
jsonContent?: string,
|
||||
) {
|
||||
// Read file content
|
||||
let fileContent = await readFileSync(filePath, "utf-8");
|
||||
|
||||
if (jsonContent) {
|
||||
fileContent = jsonContent;
|
||||
}
|
||||
|
||||
// Create DataTransfer object with file
|
||||
const dataTransfer = await page.evaluateHandle(async (content) => {
|
||||
const dt = new DataTransfer();
|
||||
const file = new File([content], "file.json", { type: "application/json" });
|
||||
dt.items.add(file);
|
||||
return dt;
|
||||
}, fileContent);
|
||||
|
||||
const dropzone = page.getByTestId(dropSelector);
|
||||
await dropzone.dispatchEvent("mousedown", { button: 0 });
|
||||
await dropzone.dispatchEvent("mousemove", { buttons: 1 });
|
||||
await dropzone.dispatchEvent("drop", { dataTransfer });
|
||||
|
||||
await dataTransfer.dispose();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue