Fix test loading

This commit is contained in:
Dustin Brett
2025-05-01 19:10:29 -07:00
parent c5ae9d4fd3
commit bd6223eea3
12 changed files with 27 additions and 24 deletions

View File

@@ -80,7 +80,7 @@ import { UNKNOWN_ICON } from "components/system/Files/FileManager/icons";
test.beforeEach(captureConsoleLogs());
test.beforeEach(disableWallpaper);
test.beforeEach(async ({ page }) => loadApp({ page }, { app: "FileExplorer" }));
test.beforeEach(async ({ page }) => loadApp({ app: "FileExplorer" })({ page }));
test.beforeEach(windowsAreVisible);
test.beforeEach(fileExplorerEntriesAreVisible);

View File

@@ -21,7 +21,7 @@ import {
test.beforeEach(captureConsoleLogs());
test.beforeEach(disableWallpaper);
test.beforeEach(async ({ page }) => loadApp({ page }, { app: "Terminal" }));
test.beforeEach(async ({ page }) => loadApp({ app: "Terminal" })({ page }));
test.beforeEach(windowsAreVisible);
test.beforeEach(terminalHasRows);

View File

@@ -31,7 +31,7 @@ test.describe("can open app", () => {
if (url) queryParams.url = url;
await loadApp({ page }, queryParams);
await loadApp(queryParams)({ page });
// NOTE: Some apps fully load AFTER the window has transitioned
// eslint-disable-next-line playwright/no-wait-for-timeout

View File

@@ -28,7 +28,7 @@ import {
test.beforeEach(captureConsoleLogs());
test.beforeEach(disableWallpaper);
test.beforeEach(loadApp);
test.beforeEach(loadApp());
test.beforeEach(desktopIsVisible);
test("has file entry", desktopEntriesAreVisible);

View File

@@ -4,7 +4,7 @@ import desktopIcons from "public/.index/desktopIcons.json";
import { OG_TAGS } from "e2e/constants";
import { loadApp } from "e2e/functions";
test.beforeEach(loadApp);
test.beforeEach(loadApp());
test.describe("has correct tags", () => {
test("has link preloads", async ({ page }) => {

View File

@@ -13,7 +13,7 @@ import {
test.beforeEach(captureConsoleLogs());
test.beforeEach(disableWallpaper);
test.beforeEach(loadApp);
test.beforeEach(loadApp());
test.beforeEach(async ({ page }) => clickSearchButton({ page }));
test.beforeEach(searchMenuIsVisible);

View File

@@ -27,7 +27,7 @@ import {
test.beforeEach(captureConsoleLogs());
test.beforeEach(disableWallpaper);
test.beforeEach(loadApp);
test.beforeEach(loadApp());
test.beforeEach(async ({ page }) => clickStartButton({ page }));
test.beforeEach(startMenuIsVisible);

View File

@@ -46,7 +46,7 @@ test.beforeEach(captureConsoleLogs());
test.beforeEach(disableWallpaper);
test.describe("elements", () => {
test.beforeEach(loadApp);
test.beforeEach(loadApp());
test.beforeEach(taskbarIsVisible);
test.describe("has start button", () => {

View File

@@ -49,7 +49,7 @@ test("can change background", async ({ headless, browserName, page }) => {
test.describe("can set background", () => {
test.beforeEach(disableWallpaper);
test.beforeEach(async ({ page }) =>
loadApp({ page }, { url: "/System/Icons/48x48" })
loadApp({ url: "/System/Icons/48x48" })({ page })
);
test.beforeEach(windowsAreVisible);
test.beforeEach(fileExplorerEntriesAreVisible);

View File

@@ -32,6 +32,10 @@ export const EXCLUDED_CONSOLE_LOGS = (
"Error while parsing the 'sandbox' attribute: 'allow-presentation' is an invalid sandbox flag.",
'Viewport argument key "interactive-widget" not recognized and ignored.'
);
} else if (browserName === "firefox") {
excludedConsoleLogs.push(
"Found a sectioned h1 element with no specified font-size or margin properties."
);
}
if (process.env.CI) {

View File

@@ -985,33 +985,32 @@ export const selectArea = async ({
};
// loaders
export const loadApp = async (
{ page }: TestProps,
queryParams?: Record<string, string>
): Promise<Response | null> => {
await page.addInitScript((session) => {
window.DEBUG_DEFAULT_SESSION = session;
}, DEFAULT_SESSION);
export const loadApp =
(queryParams?: Record<string, string>) =>
async ({ page }: TestProps): Promise<Response | null> => {
await page.addInitScript((session) => {
window.DEBUG_DEFAULT_SESSION = session;
}, DEFAULT_SESSION);
return page.goto(
queryParams ? `/?${new URLSearchParams(queryParams).toString()}` : "/"
);
};
return page.goto(
queryParams ? `/?${new URLSearchParams(queryParams).toString()}` : "/"
);
};
export const loadTestApp = async ({
page,
}: TestProps): Promise<Response | null> => loadApp({ page }, { app: TEST_APP });
}: TestProps): Promise<Response | null> => loadApp({ app: TEST_APP })({ page });
export const loadContainerTestApp = async ({
page,
}: TestProps): Promise<Response | null> =>
loadApp({ page }, { app: TEST_APP_CONTAINER_APP });
loadApp({ app: TEST_APP_CONTAINER_APP })({ page });
export const loadAppWithCanvas = async ({
headless,
browserName,
page,
}: TestProps): Promise<void> => {
await loadApp({ page });
await loadApp()({ page });
await backgroundCanvasMaybeIsVisible({ browserName, headless, page });
};

View File

@@ -12,7 +12,7 @@ import {
} from "e2e/functions";
test.beforeEach(captureConsoleLogs());
test.beforeEach(loadApp);
test.beforeEach(loadApp());
test.beforeEach(desktopEntriesAreVisible);
test.beforeEach(taskbarIsVisible);
test.beforeEach(startButtonIsVisible);