diff --git a/src/App/Header/Search.svelte b/src/App/Header/Search.svelte index 167abfcbf..6b8d0d04b 100644 --- a/src/App/Header/Search.svelte +++ b/src/App/Header/Search.svelte @@ -5,6 +5,7 @@ import * as Search from "@app/lib/search"; import * as modal from "@app/lib/modal"; import * as router from "@app/lib/router"; + import { searchPlaceholder } from "@app/lib/shared"; import { unreachable } from "@app/lib/utils"; import Icon from "@app/components/Icon.svelte"; @@ -131,7 +132,7 @@ } }} on:submit={search} - placeholder="Search a RID…"> + placeholder={searchPlaceholder}> diff --git a/src/App/Hotkeys.svelte b/src/App/Hotkeys.svelte index 2eeab5bb5..338cf2307 100644 --- a/src/App/Hotkeys.svelte +++ b/src/App/Hotkeys.svelte @@ -3,6 +3,7 @@ import ColorPaletteModal from "@app/App/ColorPaletteModal.svelte"; import HotkeysModal from "@app/App/HotkeysModal.svelte"; + import { searchPlaceholder } from "@app/lib/shared"; const onKeydown = (event: KeyboardEvent) => { if (event.key === "Escape") { @@ -17,7 +18,7 @@ case "/": { event.preventDefault(); const searchInput: HTMLElement | null = document.querySelector( - '*[placeholder="Search a RID…"]', + `*[placeholder="${searchPlaceholder}"]`, ); searchInput?.focus(); break; diff --git a/src/lib/shared.ts b/src/lib/shared.ts new file mode 100644 index 000000000..6ea9ce889 --- /dev/null +++ b/src/lib/shared.ts @@ -0,0 +1,4 @@ +// This file is shared between tests and the UI code. It should only contain +// basic JS primitives, so that it works in both browser and node environments. + +export const searchPlaceholder = "Enter an RID…"; diff --git a/tests/e2e/hotkeys.spec.ts b/tests/e2e/hotkeys.spec.ts index 942f51a4d..68024ba9b 100644 --- a/tests/e2e/hotkeys.spec.ts +++ b/tests/e2e/hotkeys.spec.ts @@ -1,7 +1,6 @@ +import { searchPlaceholder } from "@app/lib/shared"; import { test, expect } from "@tests/support/fixtures.js"; -const searchPlaceholder = "Search a RID…"; - test("global hotkeys", async ({ page }) => { await page.goto("/"); await page.locator("body").press(`/`); diff --git a/tests/e2e/search.spec.ts b/tests/e2e/search.spec.ts index f07981043..b3e05cdeb 100644 --- a/tests/e2e/search.spec.ts +++ b/tests/e2e/search.spec.ts @@ -1,3 +1,4 @@ +import { searchPlaceholder } from "@app/lib/shared"; import { test, expect, @@ -7,7 +8,7 @@ import { test("navigate to existing project", async ({ page }) => { await page.goto("/"); - const searchInput = page.getByPlaceholder("Search a RID…"); + const searchInput = page.getByPlaceholder(searchPlaceholder); await searchInput.click(); await searchInput.fill(`${rid}`); await searchInput.press("Enter"); @@ -18,7 +19,7 @@ test("navigate to existing project", async ({ page }) => { test("navigate to a project that does not exist", async ({ page }) => { await page.goto("/"); - const searchInput = page.getByPlaceholder("Search a RID…"); + const searchInput = page.getByPlaceholder(searchPlaceholder); await searchInput.click(); const nonExistantId = "rad:zAAAAAAAAAAAAAAAAAAAAAAAAAAA";