From 0e82cdc6a99b4d99e5036e7bd62a0c40af5034a5 Mon Sep 17 00:00:00 2001 From: Ophir Lojkine Date: Sat, 28 Nov 2026 23:46:30 +0000 Subject: [PATCH] Exercise the visible search field in the remote-select browser test --- tests/end-to-end/official-site.spec.ts | 61 ++++++++++++-------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/tests/end-to-end/official-site.spec.ts b/tests/end-to-end/official-site.spec.ts index d918bd8ac..bcf0d93ef 100644 --- a/tests/end-to-end/official-site.spec.ts +++ b/tests/end-to-end/official-site.spec.ts @@ -797,18 +797,17 @@ test("form select combines initial options with remote search results", async ({ }) => { await page.goto("/component.sql?component=form"); - const select = page - .locator( - 'select[data-options_source="examples/from_component_options_source.sql?category=component"]', - ) - .first(); - await expect(select).toBeAttached(); - await page.waitForFunction( - () => - !!document.querySelector( + const field = page + .locator("label") + .filter({ + has: page.locator( 'select[data-options_source="examples/from_component_options_source.sql?category=component"]', - )?.tomselect, - ); + ), + }) + .first(); + const select = field.locator("select"); + const input = field.locator('input[role="combobox"]'); + await expect(input).toBeAttached(); const initialState = await select.evaluate((element: HTMLSelectElement) => { const tomselect = element.tomselect; @@ -827,18 +826,23 @@ test("form select combines initial options with remote search results", async ({ labels: { form: "Form" }, }); - await select.evaluate((element: HTMLSelectElement) => - element.tomselect?.focus(), - ); - const formResponse = page.waitForResponse((response) => - response - .url() - .includes( - "examples/from_component_options_source.sql?category=component&search=form", + await field + .getByText("Form", { exact: true }) + .filter({ visible: true }) + .click(); + async function search(query: string) { + await Promise.all([ + page.waitForResponse((response) => + response + .url() + .includes( + `examples/from_component_options_source.sql?category=component&search=${query}`, + ), ), - ); - await page.keyboard.type("form"); - await formResponse; + input.fill(query), + ]); + } + await search("form"); await expect .poll(async () => select.evaluate((element: HTMLSelectElement) => ({ @@ -851,18 +855,7 @@ test("form select combines initial options with remote search results", async ({ formLabel: "form", }); - await select.evaluate((element: HTMLSelectElement) => - element.tomselect?.setTextboxValue(""), - ); - const mapResponse = page.waitForResponse((response) => - response - .url() - .includes( - "examples/from_component_options_source.sql?category=component&search=map", - ), - ); - await page.keyboard.type("map"); - await mapResponse; + await search("map"); await expect .poll(async () => select.evaluate((element: HTMLSelectElement) => ({