Skip to content

Commit

Permalink
Fix search ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
owi92 committed Dec 5, 2023
1 parent 446415d commit afd1a49
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions frontend/tests/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ test("Search", async ({ page }) => {
await navigateTo("/", page);
await page.waitForSelector("nav");
const searchField = page.getByPlaceholder("Search");
const query = "video";

await test.step("Should be focusable by keyboard shortcut", async () => {
await page.keyboard.press("s");
await expect(searchField).toBeFocused();
});

await test.step("Should allow search queries to be executed", async () => {
const url = "~search?q=Video";
await searchField.fill("Video");
const url = `~search?q=${query}`;
await searchField.fill(query);

await expect(page).toHaveURL(url);
});

await test.step("Should show search results", async () => {
expect(page.getByText("Search results")).toBeVisible();
const results = page
.locator("div")
.filter({ has: page.getByText("Search results for “Video”") })
.nth(4);
await expect(results).toBeVisible();
expect(await results.getByRole("link").count()).toBeGreaterThan(0);
.locator("li")
.filter({ hasText: "video" })
.locator("a");
await results.nth(1).waitFor();
expect(await results.count()).toBeGreaterThan(0);
});
});

0 comments on commit afd1a49

Please sign in to comment.