diff --git a/e2e/components/system/Search.spec.ts b/e2e/components/system/Search.spec.ts index ed1b5c73..cd45c22a 100644 --- a/e2e/components/system/Search.spec.ts +++ b/e2e/components/system/Search.spec.ts @@ -1,10 +1,13 @@ import { test } from "@playwright/test"; +import { TEST_SEARCH, TEST_SEARCH_RESULT_TITLE } from "e2e/constants"; import { clickSearchButton, disableWallpaper, loadApp, searchMenuIsHidden, searchMenuIsVisible, + searchResultEntryIsVisible, + typeInTaskbarSearchBar, } from "e2e/functions"; test.beforeEach(disableWallpaper); @@ -18,3 +21,10 @@ test.describe("can close", () => { await searchMenuIsHidden({ page }); }); }); + +test.describe("can search", () => { + test("via 'All' tab", async ({ page }) => { + await typeInTaskbarSearchBar(TEST_SEARCH, { page }); + await searchResultEntryIsVisible(TEST_SEARCH_RESULT_TITLE, { page }); + }); +}); diff --git a/e2e/constants.ts b/e2e/constants.ts index f1dc07fa..5ce8069f 100644 --- a/e2e/constants.ts +++ b/e2e/constants.ts @@ -79,6 +79,8 @@ export const TASKBAR_ENTRY_SELECTOR = `${TASKBAR_ENTRIES_SELECTOR}>li`; export const TASKBAR_ENTRY_PEEK_SELECTOR = `${TASKBAR_ENTRY_SELECTOR}>div:not([title])`; export const TASKBAR_ENTRY_PEEK_IMAGE_SELECTOR = `${TASKBAR_ENTRY_PEEK_SELECTOR}>img`; export const SEARCH_MENU_SELECTOR = `${DESKTOP_SELECTOR}>nav[style]:not(:has(>ol))`; +export const SEARCH_MENU_INPUT_SELECTOR = `${SEARCH_MENU_SELECTOR} input[placeholder='Type here to search']`; +export const SEARCH_MENU_RESULTS_SELECTOR = `${SEARCH_MENU_SELECTOR}>div>.content>div>.list>figure>ol`; export const SEARCH_BUTTON_SELECTOR = `${TASKBAR_SELECTOR}>[title='Type here to search']`; export const START_BUTTON_SELECTOR = `${TASKBAR_SELECTOR}>[title=Start]`; export const START_MENU_SELECTOR = `${DESKTOP_SELECTOR}>nav[style]:has(>ol)`; @@ -226,6 +228,7 @@ export const TEST_ROOT_FILE_TOOLTIP = export const TEST_SEARCH = "CREDITS"; export const TEST_SEARCH_RESULT = /^CREDITS.md$/; +export const TEST_SEARCH_RESULT_TITLE = /^\/CREDITS.md/; export const NEW_FOLDER_LABEL = /^New folder$/; export const NEW_FILE_LABEL = /^New Text Document.txt$/; diff --git a/e2e/functions.ts b/e2e/functions.ts index 30dc26e2..9e3b91a1 100644 --- a/e2e/functions.ts +++ b/e2e/functions.ts @@ -47,6 +47,8 @@ import { WINDOW_SELECTOR, WINDOW_TITLEBAR_ICON_SELECTOR, WINDOW_TITLEBAR_SELECTOR, + SEARCH_MENU_INPUT_SELECTOR, + SEARCH_MENU_RESULTS_SELECTOR, } from "e2e/constants"; type TestProps = { @@ -387,6 +389,14 @@ export const typeInFileExplorerSearchBox = async ( .getByLabel(FILE_EXPLORER_SEARCH_BOX_LABEL) .pressSequentially(text, { delay: TYPE_DELAY }); +export const typeInTaskbarSearchBar = async ( + text: string, + { page }: TestProps +): Promise => + page + .locator(SEARCH_MENU_INPUT_SELECTOR) + .pressSequentially(text, { delay: TYPE_DELAY }); + // expect->toHave export const pageHasTitle = async ( title: string, @@ -601,6 +611,14 @@ export const fileExplorerNavButtonIsVisible = async ( page.locator(FILE_EXPLORER_NAV_SELECTOR).getByLabel(label, EXACT) ).toBeVisible(); +export const searchResultEntryIsVisible = async ( + label: RegExp | string, + { page }: TestProps +): Promise => + expect( + page.locator(SEARCH_MENU_RESULTS_SELECTOR).getByTitle(label) + ).toBeVisible(); + export const taskbarEntryIsHidden = async ( label: RegExp | string, { page }: TestProps