mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Test tweaks
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
fileExplorerEntriesAreVisible,
|
||||
fileExplorerEntryHasTooltip,
|
||||
fileExplorerEntryIsHidden,
|
||||
fileExplorerSearchBoxIsVisible,
|
||||
focusOnWindow,
|
||||
pageHasIcon,
|
||||
pageHasTitle,
|
||||
@@ -49,6 +50,7 @@ test("has address bar", async ({ page }) => {
|
||||
});
|
||||
|
||||
test("has search box", async ({ page }) => {
|
||||
await fileExplorerSearchBoxIsVisible({ page });
|
||||
await typeInFileExplorerSearchBox(TEST_SEARCH, { page });
|
||||
await contextMenuIsVisible({ page });
|
||||
await contextMenuEntryIsVisible(TEST_SEARCH_RESULT, { page });
|
||||
|
||||
@@ -10,8 +10,8 @@ type LocatorWaitForProps = Parameters<Locator["waitFor"]>[0];
|
||||
export const EXACT = { exact: true };
|
||||
export const FORCE = { force: true };
|
||||
export const POLLING_OPTIONS = {
|
||||
intervals: [250, 750, 1000, 2000],
|
||||
timeout: 10000,
|
||||
intervals: [250, 500, 1000],
|
||||
timeout: 15000,
|
||||
};
|
||||
export const RIGHT_CLICK = { button: "right" } as LocatorClickProps;
|
||||
export const VISIBLE = { state: "visible" } as LocatorWaitForProps;
|
||||
|
||||
@@ -161,7 +161,7 @@ export const typeInFileExplorerSearchBox = async (
|
||||
{ page }: TestProps
|
||||
): Promise<void> =>
|
||||
page
|
||||
.locator(WINDOW_SELECTOR)
|
||||
.locator(FILE_EXPLORER_NAV_SELECTOR)
|
||||
.getByLabel(FILE_EXPLORER_SEARCH_BOX_LABEL)
|
||||
.type(text, { delay: 50 });
|
||||
|
||||
@@ -178,32 +178,36 @@ export const pageHasIcon = async (
|
||||
): Promise<void> =>
|
||||
expect(page.locator(FAVICON_SELECTOR)).toHaveAttribute("href", icon);
|
||||
|
||||
// expect->waitForFunction (Q: Could these be a poll/eval?)
|
||||
// expect->evaluate
|
||||
export const backgroundIsUrl = async ({ page }: TestProps): Promise<void> =>
|
||||
expect(
|
||||
await page.waitForFunction(() =>
|
||||
window
|
||||
.getComputedStyle(document.documentElement)
|
||||
.getPropertyValue("background-image")
|
||||
.match(/^url\(.*?\)$/)
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(async () =>
|
||||
expect(
|
||||
await page.evaluate(() =>
|
||||
window
|
||||
.getComputedStyle(document.documentElement)
|
||||
.getPropertyValue("background-image")
|
||||
.match(/^url\(.*?\)$/)
|
||||
)
|
||||
).toBeTruthy()
|
||||
).toPass(POLLING_OPTIONS);
|
||||
|
||||
// TODO: Fails on CI?
|
||||
export const windowIsMaximized = async ({ page }: TestProps): Promise<void> =>
|
||||
expect(
|
||||
await page.waitForFunction(
|
||||
([windowSelector, taskbarSelector]: string[]) =>
|
||||
window.innerWidth ===
|
||||
(document.querySelector(windowSelector) as HTMLElement)
|
||||
?.clientWidth &&
|
||||
window.innerHeight -
|
||||
((document.querySelector(taskbarSelector) as HTMLElement)
|
||||
?.clientHeight || 0) ===
|
||||
(document.querySelector(windowSelector) as HTMLElement)?.clientHeight,
|
||||
[WINDOW_SELECTOR, TASKBAR_SELECTOR]
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(async () =>
|
||||
expect(
|
||||
await page.evaluate(
|
||||
([windowSelector, taskbarSelector]) =>
|
||||
window.innerWidth ===
|
||||
(document.querySelector(windowSelector) as HTMLElement)
|
||||
?.clientWidth &&
|
||||
window.innerHeight -
|
||||
((document.querySelector(taskbarSelector) as HTMLElement)
|
||||
?.clientHeight || 0) ===
|
||||
(document.querySelector(windowSelector) as HTMLElement)
|
||||
?.clientHeight,
|
||||
[WINDOW_SELECTOR, TASKBAR_SELECTOR]
|
||||
)
|
||||
).toBeTruthy()
|
||||
).toPass(POLLING_OPTIONS);
|
||||
|
||||
// expect->locator
|
||||
export const canvasBackgroundIsHidden = async ({
|
||||
@@ -312,6 +316,15 @@ export const fileExplorerEntryIsHidden = async (
|
||||
page.locator(FILE_EXPLORER_ENTRIES_SELECTOR).getByLabel(label)
|
||||
).toBeHidden();
|
||||
|
||||
export const fileExplorerSearchBoxIsVisible = async ({
|
||||
page,
|
||||
}: TestProps): Promise<void> =>
|
||||
expect(
|
||||
page
|
||||
.locator(FILE_EXPLORER_NAV_SELECTOR)
|
||||
.getByLabel(FILE_EXPLORER_SEARCH_BOX_LABEL)
|
||||
).toBeVisible();
|
||||
|
||||
export const fileExplorerEntryHasTooltip = async (
|
||||
label: RegExp,
|
||||
title: RegExp,
|
||||
|
||||
Reference in New Issue
Block a user