Test tweaks

This commit is contained in:
Dustin Brett
2023-07-20 23:19:08 -07:00
parent 680f7d8482
commit cfa9393c82
3 changed files with 41 additions and 26 deletions

View File

@@ -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 });

View File

@@ -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;

View File

@@ -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,