refactor: restructure test utilities and enhance context view tests

- Refactored test utilities by consolidating and organizing helper functions into dedicated modules for better maintainability and clarity.
- Introduced new utility functions for interactions, waiting, and element retrieval, improving the readability of test cases.
- Updated context view tests to utilize the new utility functions, enhancing test reliability and reducing code duplication.
- Removed deprecated utility functions and ensured all tests are aligned with the new structure.
This commit is contained in:
Kacper
2025-12-15 02:40:09 +01:00
parent a412f5d0fb
commit 0b1123e3ce
29 changed files with 3478 additions and 3191 deletions

View File

@@ -0,0 +1,38 @@
import { Page } from "@playwright/test";
/**
* Simulate drag and drop of a file onto an element
*/
export async function simulateFileDrop(
page: Page,
targetSelector: string,
fileName: string,
fileContent: string,
mimeType: string = "text/plain"
): Promise<void> {
await page.evaluate(
({ selector, content, name, mime }) => {
const target = document.querySelector(selector);
if (!target) throw new Error(`Element not found: ${selector}`);
const file = new File([content], name, { type: mime });
const dataTransfer = new DataTransfer();
dataTransfer.items.add(file);
// Dispatch drag events
target.dispatchEvent(
new DragEvent("dragover", {
dataTransfer,
bubbles: true,
})
);
target.dispatchEvent(
new DragEvent("drop", {
dataTransfer,
bubbles: true,
})
);
},
{ selector: targetSelector, content: fileContent, name: fileName, mime: mimeType }
);
}