2026-06-19 18:15:20 +08:00
|
|
|
import { expect, test } from "./helpers";
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
test.describe("Home Page", () => {
|
2026-06-19 18:15:20 +08:00
|
|
|
test("shows branding and search bar", async ({ loggedInPage: page }) => {
|
2026-06-10 22:01:13 +08:00
|
|
|
// The wordmark renders as a logo image, not text; the document title is
|
|
|
|
|
// the stable brand assertion.
|
|
|
|
|
await expect(page).toHaveTitle(/SnapOtter/i);
|
2026-06-19 18:15:20 +08:00
|
|
|
|
|
|
|
|
// 2.0 home page is a tool grid with a search bar (no dropzone)
|
|
|
|
|
await expect(page.locator("[data-search-input]")).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
});
|
|
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
test("modality tabs are visible", async ({ loggedInPage: page }) => {
|
2026-06-21 02:45:56 +08:00
|
|
|
// 2.0 home page has modality tabs: All, Image, Video, Audio, PDF, Files
|
2026-06-19 18:15:20 +08:00
|
|
|
// Tab buttons render label + a count span, so the accessible name is e.g.
|
|
|
|
|
// "Image5" (no word boundary before the digit) — match on the label prefix.
|
|
|
|
|
await expect(page.getByRole("button", { name: /^All/ }).first()).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("button", { name: /^Image/ }).first()).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("button", { name: /^Video/ }).first()).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("button", { name: /^Audio/ }).first()).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("button", { name: /^PDF/ }).first()).toBeVisible();
|
2026-06-21 02:45:56 +08:00
|
|
|
await expect(page.getByRole("button", { name: /^Files/ }).first()).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
});
|
|
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
test("tool categories are visible on home page", async ({ loggedInPage: page }) => {
|
|
|
|
|
// Search bar should be visible
|
2026-03-22 19:28:57 +08:00
|
|
|
await expect(page.getByPlaceholder(/search/i).first()).toBeVisible();
|
|
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
// Tool categories should be visible under All tab (default)
|
2026-03-22 19:28:57 +08:00
|
|
|
await expect(page.getByText("Essentials").first()).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
test("search filters tools", async ({ loggedInPage: page }) => {
|
2026-03-22 19:28:57 +08:00
|
|
|
const searchInput = page.getByPlaceholder(/search/i).first();
|
|
|
|
|
await searchInput.fill("compress");
|
|
|
|
|
|
|
|
|
|
// Should show Compress tool
|
|
|
|
|
await expect(page.getByText("Compress").first()).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
test("clicking a tool card navigates to tool page", async ({ loggedInPage: page }) => {
|
|
|
|
|
// Find and click a tool link (Resize is in Image > Essentials)
|
2026-03-25 09:27:12 +08:00
|
|
|
await page.locator("a").filter({ hasText: "Resize" }).first().click();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
// 2.0 routes are /{modality}/{toolId}
|
|
|
|
|
await expect(page).toHaveURL("/image/resize");
|
2026-03-22 19:28:57 +08:00
|
|
|
});
|
|
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
test("modality tab filters tools by modality", async ({ loggedInPage: page }) => {
|
|
|
|
|
// Click the Video tab
|
2026-03-22 19:28:57 +08:00
|
|
|
await page
|
2026-06-19 18:15:20 +08:00
|
|
|
.getByRole("button", { name: /^Video/ })
|
2026-03-22 19:28:57 +08:00
|
|
|
.first()
|
|
|
|
|
.click();
|
|
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
// Should show video-specific category headings (Subtitles is unique to video)
|
|
|
|
|
await expect(page.getByText("Subtitles").first()).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
// Image-only categories should not be present
|
|
|
|
|
await expect(page.getByText("Essentials")).not.toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
});
|
|
|
|
|
|
2026-06-19 18:15:20 +08:00
|
|
|
test("search shows no-results message for unknown query", async ({ loggedInPage: page }) => {
|
|
|
|
|
const searchInput = page.getByPlaceholder(/search/i).first();
|
|
|
|
|
await searchInput.fill("xyznonexistent");
|
|
|
|
|
|
|
|
|
|
// Should show no-results message (en.ts: homePage.noToolsMatch)
|
|
|
|
|
await expect(page.getByText(/no tools match/i).first()).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("search can be cleared", async ({ loggedInPage: page }) => {
|
|
|
|
|
const searchInput = page.getByPlaceholder(/search/i).first();
|
|
|
|
|
await searchInput.fill("xyznonexistent");
|
|
|
|
|
|
|
|
|
|
// Should show no-results with a clear button (en.ts: homePage.clearSearch)
|
|
|
|
|
await expect(page.getByText(/no tools match/i).first()).toBeVisible();
|
|
|
|
|
await page.getByText("Clear search").click();
|
|
|
|
|
|
|
|
|
|
// Tool grid should reappear after clearing
|
|
|
|
|
await expect(page.getByText("Essentials").first()).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("top nav has theme toggle", async ({ loggedInPage: page }) => {
|
|
|
|
|
// Theme toggle moved to the top-nav header in 2.0
|
|
|
|
|
await expect(page.getByTitle("Toggle theme")).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
});
|
|
|
|
|
});
|