mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Fix FE icon vs details view tests
This commit is contained in:
@@ -129,7 +129,7 @@ const Navigation = forwardRef<HTMLInputElement, NavigationProps>(
|
||||
} = navRef.current?.getBoundingClientRect() || {};
|
||||
|
||||
onContextMenuCapture(
|
||||
x && y && height
|
||||
(x || y) && height
|
||||
? ({
|
||||
pageX: x,
|
||||
pageY: y + height - CONTEXT_MENU_OFFSET,
|
||||
|
||||
@@ -5,12 +5,15 @@ import {
|
||||
BASE_APP_TITLE,
|
||||
DESKTOP_SELECTOR,
|
||||
DRAG_HEADLESS_NOT_SUPPORTED_BROWSERS,
|
||||
FILE_EXPLORER_COLUMN_HEIGHT,
|
||||
FILE_EXPLORER_ENTRIES_FOCUSED_SELECTOR,
|
||||
FILE_EXPLORER_ENTRIES_SELECTOR,
|
||||
FILE_EXPLORER_SELECTION_SELECTOR,
|
||||
FILE_EXPLORER_SELECTOR,
|
||||
FILE_EXPLORER_STATUS_BAR_SELECTOR,
|
||||
FILE_MENU_ITEMS,
|
||||
FOLDER_MENU_ITEMS,
|
||||
ROOT_FOLDER_VIEW,
|
||||
TEST_APP_ICON,
|
||||
TEST_APP_TITLE,
|
||||
TEST_APP_TITLE_TEXT,
|
||||
@@ -24,6 +27,7 @@ import {
|
||||
TEST_ROOT_FILE_TOOLTIP,
|
||||
TEST_SEARCH,
|
||||
TEST_SEARCH_RESULT,
|
||||
WINDOW_RESIZE_HANDLE_WIDTH,
|
||||
} from "e2e/constants";
|
||||
import {
|
||||
appIsOpen,
|
||||
@@ -317,16 +321,23 @@ test.describe("has files & folders", () => {
|
||||
|
||||
const { x = 0, y = 0 } =
|
||||
(await page.locator(FILE_EXPLORER_SELECTOR).boundingBox()) || {};
|
||||
const { height = 0, width = 0 } =
|
||||
(await page
|
||||
.locator(FILE_EXPLORER_ENTRIES_SELECTOR)
|
||||
.first()
|
||||
.boundingBox()) || {};
|
||||
|
||||
await selectArea({
|
||||
container: FILE_EXPLORER_SELECTION_SELECTOR,
|
||||
page,
|
||||
selection: {
|
||||
height: 70,
|
||||
height: Math.round(height) * 2,
|
||||
up: true,
|
||||
width: 140,
|
||||
x: x + 3,
|
||||
y: y + 3,
|
||||
width: Math.round(width),
|
||||
x: x + WINDOW_RESIZE_HANDLE_WIDTH / 2,
|
||||
y:
|
||||
y +
|
||||
(ROOT_FOLDER_VIEW === "details" ? FILE_EXPLORER_COLUMN_HEIGHT : 0),
|
||||
},
|
||||
});
|
||||
await expect(page.locator(".focus-within")).toHaveCount(2);
|
||||
@@ -370,7 +381,12 @@ test("can change page icon", async ({ page }) => {
|
||||
|
||||
test.describe("has context menu", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await clickFileExplorer({ page }, true);
|
||||
await clickFileExplorer(
|
||||
{ page },
|
||||
true,
|
||||
WINDOW_RESIZE_HANDLE_WIDTH / 2,
|
||||
ROOT_FOLDER_VIEW === "details" ? FILE_EXPLORER_COLUMN_HEIGHT : 0
|
||||
);
|
||||
await contextMenuIsVisible({ page });
|
||||
});
|
||||
|
||||
|
||||
@@ -82,17 +82,19 @@ test("can drag", async ({ page }) => {
|
||||
const windowElement = page.locator(WINDOW_SELECTOR);
|
||||
const initialBoundingBox = await windowElement.boundingBox();
|
||||
|
||||
await dragWindowToDesktop({ page });
|
||||
await expect(async () => {
|
||||
await dragWindowToDesktop({ page });
|
||||
|
||||
const finalBoundingBox = await windowElement.boundingBox();
|
||||
const finalBoundingBox = await windowElement.boundingBox();
|
||||
|
||||
expect(initialBoundingBox?.x).not.toEqual(finalBoundingBox?.x);
|
||||
expect(initialBoundingBox?.y).not.toEqual(finalBoundingBox?.y);
|
||||
expect(initialBoundingBox?.x).not.toEqual(finalBoundingBox?.x);
|
||||
expect(initialBoundingBox?.y).not.toEqual(finalBoundingBox?.y);
|
||||
|
||||
const mainBoundingBox = await page.locator(DESKTOP_SELECTOR).boundingBox();
|
||||
const mainBoundingBox = await page.locator(DESKTOP_SELECTOR).boundingBox();
|
||||
|
||||
expect(finalBoundingBox?.y).toEqual(mainBoundingBox?.y);
|
||||
expect(finalBoundingBox?.x).toEqual(mainBoundingBox?.x);
|
||||
expect(finalBoundingBox?.y).toEqual(mainBoundingBox?.y);
|
||||
expect(finalBoundingBox?.x).toEqual(mainBoundingBox?.x);
|
||||
}).toPass();
|
||||
});
|
||||
|
||||
test("can resize", async ({ page }) => {
|
||||
|
||||
@@ -103,7 +103,7 @@ export const FILE_EXPLORER_NAV_SELECTOR = `${WINDOW_SELECTOR}>${VIEWPORT_SELECTO
|
||||
export const FILE_EXPLORER_SEARCH_BOX_SELECTOR = `${FILE_EXPLORER_NAV_SELECTOR}>div>input[type=search]`;
|
||||
export const FILE_EXPLORER_STATUS_BAR_SELECTOR = `${WINDOW_SELECTOR}>${VIEWPORT_SELECTOR}>${APP_CONTAINER_SELECTOR}>footer`;
|
||||
export const FILE_EXPLORER_SELECTOR = `${WINDOW_SELECTOR}>${VIEWPORT_SELECTOR}>${APP_CONTAINER_SELECTOR}>ol`;
|
||||
export const FILE_EXPLORER_SELECTION_SELECTOR = `${FILE_EXPLORER_SELECTOR}>span`;
|
||||
export const FILE_EXPLORER_SELECTION_SELECTOR = `${FILE_EXPLORER_SELECTOR}>span:last-of-type`;
|
||||
export const FILE_EXPLORER_ENTRIES_SELECTOR = `${FILE_EXPLORER_SELECTOR}>li`;
|
||||
export const FILE_EXPLORER_ENTRIES_FOCUSED_SELECTOR = `${FILE_EXPLORER_SELECTOR}>li${FOCUSED_ENTRY_SELECTOR}`;
|
||||
export const FILE_EXPLORER_ENTRIES_RENAMING_SELECTOR = `${FILE_EXPLORER_ENTRIES_SELECTOR}>button>figure>textarea`;
|
||||
@@ -262,6 +262,12 @@ export const ROOT_PUBLIC_FOLDER = "public";
|
||||
|
||||
export const ROOT_PUBLIC_TEST_FILE = "desktop.ini";
|
||||
|
||||
export const ROOT_FOLDER_VIEW = "details";
|
||||
|
||||
export const CURSOR_SPACE_LENGTH = 1;
|
||||
|
||||
export const TAB_SPACE_LENGTH = 4;
|
||||
|
||||
export const FILE_EXPLORER_COLUMN_HEIGHT = 25;
|
||||
|
||||
export const WINDOW_RESIZE_HANDLE_WIDTH = 6;
|
||||
|
||||
@@ -172,7 +172,7 @@ export const clickDesktop = async (
|
||||
): Promise<void> =>
|
||||
page.locator(DESKTOP_SELECTOR).click({
|
||||
button: right ? "right" : undefined,
|
||||
...(x && y ? { position: { x: x + offset, y: y + offset } } : {}),
|
||||
...(x || y ? { position: { x: x + offset, y: y + offset } } : {}),
|
||||
});
|
||||
|
||||
export const clickSearchButton = async (
|
||||
@@ -361,9 +361,14 @@ export const clickFileExplorerSearchBox = async ({
|
||||
|
||||
export const clickFileExplorer = async (
|
||||
{ page }: TestProps,
|
||||
right = false
|
||||
right = false,
|
||||
x = 0,
|
||||
y = 0
|
||||
): Promise<void> =>
|
||||
page.locator(FILE_EXPLORER_SELECTOR).click(right ? RIGHT_CLICK : undefined);
|
||||
page.locator(FILE_EXPLORER_SELECTOR).click({
|
||||
button: right ? "right" : undefined,
|
||||
...(x || y ? { position: { x, y } } : {}),
|
||||
});
|
||||
|
||||
export const clickFileExplorerEntry = async (
|
||||
label: RegExp | string,
|
||||
|
||||
Reference in New Issue
Block a user