Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 27 additions & 34 deletions tests/end-to-end/official-site.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLSelectElement>(
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;
Expand All @@ -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) => ({
Expand All @@ -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) => ({
Expand Down
Loading