mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Fixed paste handler and add tests
This commit is contained in:
@@ -108,7 +108,7 @@ const useFileKeyboardShortcuts = (
|
||||
moveEntries(focusedEntries.map((entry) => join(url, entry)));
|
||||
break;
|
||||
case "v":
|
||||
haltEvent(event);
|
||||
event.stopPropagation();
|
||||
if (target instanceof HTMLOListElement) {
|
||||
pasteToFolder();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { expect, test } from "@playwright/test";
|
||||
import {
|
||||
BASE_APP_FAVICON,
|
||||
BASE_APP_TITLE,
|
||||
CLIPBOARD_WRITE_HEADLESS_NOT_SUPPORTED_BROWSERS,
|
||||
DESKTOP_SELECTOR,
|
||||
DRAG_HEADLESS_NOT_SUPPORTED_BROWSERS,
|
||||
FILE_EXPLORER_COLUMN_HEIGHT,
|
||||
@@ -18,10 +19,12 @@ import {
|
||||
TEST_APP_TITLE,
|
||||
TEST_APP_TITLE_TEXT,
|
||||
TEST_DESKTOP_FILE,
|
||||
TEST_IMAGE_NAME,
|
||||
TEST_ROOT_ARCHIVE,
|
||||
TEST_ROOT_FILE,
|
||||
TEST_ROOT_FILE_2,
|
||||
TEST_ROOT_FILE_ALT_APP,
|
||||
TEST_ROOT_FILE_COPY,
|
||||
TEST_ROOT_FILE_DEFAULT_APP,
|
||||
TEST_ROOT_FILE_TEXT,
|
||||
TEST_ROOT_FILE_TOOLTIP,
|
||||
@@ -73,6 +76,7 @@ import {
|
||||
windowTitlebarTextIsVisible,
|
||||
windowsAreVisible,
|
||||
} from "e2e/functions";
|
||||
import { UNKNOWN_ICON } from "components/system/Files/FileManager/icons";
|
||||
|
||||
test.beforeEach(captureConsoleLogs);
|
||||
test.beforeEach(disableWallpaper);
|
||||
@@ -232,6 +236,50 @@ test.describe("has files & folders", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("can paste from filesystem", async ({ page }) => {
|
||||
await page.keyboard.press("Control+KeyV");
|
||||
await fileExplorerEntryIsHidden(TEST_ROOT_FILE_COPY, { page });
|
||||
|
||||
await clickFileExplorerEntry(TEST_ROOT_FILE, { page });
|
||||
await page.keyboard.press("Control+KeyC");
|
||||
await fileExplorerEntryIsHidden(TEST_ROOT_FILE_COPY, { page });
|
||||
|
||||
await clickFileExplorer({ page }, false, WINDOW_RESIZE_HANDLE_WIDTH / 2, 0);
|
||||
await page.keyboard.press("Control+KeyV");
|
||||
await fileExplorerEntryIsVisible(TEST_ROOT_FILE_COPY, { page });
|
||||
});
|
||||
|
||||
test("can paste from clipboard", async ({
|
||||
browserName,
|
||||
context,
|
||||
headless,
|
||||
page,
|
||||
}) => {
|
||||
test.skip(
|
||||
headless &&
|
||||
CLIPBOARD_WRITE_HEADLESS_NOT_SUPPORTED_BROWSERS.has(browserName),
|
||||
"no headless drag support"
|
||||
);
|
||||
|
||||
await page.keyboard.press("Control+KeyV");
|
||||
await fileExplorerEntryIsHidden(TEST_IMAGE_NAME, { page });
|
||||
|
||||
await context.grantPermissions(["clipboard-write"]);
|
||||
await page.evaluate(
|
||||
([icon]) =>
|
||||
navigator.clipboard.write([
|
||||
new ClipboardItem({
|
||||
"image/png": atob(icon.replace("data:image/png;base64,", "")),
|
||||
}),
|
||||
]),
|
||||
[UNKNOWN_ICON]
|
||||
);
|
||||
await fileExplorerEntryIsHidden(TEST_IMAGE_NAME, { page });
|
||||
|
||||
await page.keyboard.press("Control+KeyV");
|
||||
await fileExplorerEntryIsVisible(TEST_IMAGE_NAME, { page });
|
||||
});
|
||||
|
||||
test("can rename via F2", async ({ page }) => {
|
||||
await clickFileExplorerEntry(TEST_ROOT_FILE, { page });
|
||||
await pressFileExplorerEntryKeys(TEST_ROOT_FILE, "F2", { page });
|
||||
|
||||
@@ -127,6 +127,10 @@ export const ACCESSIBILITY_EXCEPTION_IDS = [
|
||||
"meta-viewport",
|
||||
];
|
||||
|
||||
export const CLIPBOARD_WRITE_HEADLESS_NOT_SUPPORTED_BROWSERS = new Set([
|
||||
"firefox",
|
||||
"webkit",
|
||||
]);
|
||||
export const DIRECTORY_PICKER_NOT_SUPPORTED_BROWSERS = new Set([
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Window/showDirectoryPicker#browser_compatibility
|
||||
"webkit",
|
||||
@@ -236,9 +240,11 @@ export const TEST_APP_TITLE = /^My PC$/;
|
||||
export const TEST_APP_TITLE_TEXT = "My PC";
|
||||
export const TEST_APP_ICON = /\/pc\.(webp|png)$/;
|
||||
|
||||
export const TEST_IMAGE_NAME = "image.png";
|
||||
export const TEST_DESKTOP_FILE = /^Public$/;
|
||||
export const TEST_ROOT_ARCHIVE = /^archive.zip$/;
|
||||
export const TEST_ROOT_FILE = /^CREDITS.md$/;
|
||||
export const TEST_ROOT_FILE_COPY = /^CREDITS \(1\).md$/;
|
||||
export const TEST_ROOT_FILE_2 = /^favicon.ico$/;
|
||||
export const TEST_ROOT_FILE_TEXT = "CREDITS.md";
|
||||
export const TEST_ROOT_FILE_DEFAULT_APP = "Marked";
|
||||
|
||||
Reference in New Issue
Block a user