2026-03-25 09:27:12 +08:00
|
|
|
import { expect, test, uploadTestImage } from "./helpers";
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
test.describe("Home Page", () => {
|
2026-06-10 22:01:13 +08:00
|
|
|
test("shows branding and dropzone prompt", async ({ loggedInPage: page }) => {
|
|
|
|
|
// The wordmark renders as a logo image, not text; the document title is
|
|
|
|
|
// the stable brand assertion.
|
|
|
|
|
await expect(page).toHaveTitle(/SnapOtter/i);
|
|
|
|
|
await expect(page.getByText("Drop your images here")).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("dropzone shows upload button", async ({ loggedInPage: page }) => {
|
|
|
|
|
await expect(page.getByText("Upload from computer")).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
test("tool panel is visible on home page", async ({ loggedInPage: page }) => {
|
2026-03-22 19:28:57 +08:00
|
|
|
// Search bar should be visible in tool panel
|
|
|
|
|
await expect(page.getByPlaceholder(/search/i).first()).toBeVisible();
|
|
|
|
|
|
|
|
|
|
// Tool categories should be visible
|
|
|
|
|
await expect(page.getByText("Essentials").first()).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("tool panel search filters tools", async ({ loggedInPage: page }) => {
|
|
|
|
|
const searchInput = page.getByPlaceholder(/search/i).first();
|
|
|
|
|
await searchInput.fill("compress");
|
|
|
|
|
|
|
|
|
|
// Should show Compress tool
|
|
|
|
|
await expect(page.getByText("Compress").first()).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
test("clicking a tool in panel navigates to tool page", async ({ loggedInPage: page }) => {
|
2026-03-22 19:28:57 +08:00
|
|
|
// Find and click a tool link
|
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
|
|
|
|
|
|
|
|
await expect(page).toHaveURL("/resize");
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
test("after upload shows quick actions and tool selector", async ({ loggedInPage: page }) => {
|
2026-03-22 19:28:57 +08:00
|
|
|
await uploadTestImage(page);
|
|
|
|
|
|
|
|
|
|
// Should show quick actions
|
|
|
|
|
await expect(page.getByText("Quick Actions").first()).toBeVisible();
|
|
|
|
|
|
|
|
|
|
// Should show quick action tools
|
2026-03-25 09:27:12 +08:00
|
|
|
await expect(page.getByRole("button", { name: /resize/i }).first()).toBeVisible();
|
|
|
|
|
await expect(page.getByRole("button", { name: /compress/i }).first()).toBeVisible();
|
2026-03-22 19:28:57 +08:00
|
|
|
|
|
|
|
|
// Should show all tools section
|
|
|
|
|
await expect(page.getByText("All Tools").first()).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
test("after upload shows image preview", async ({ loggedInPage: page }) => {
|
2026-03-22 19:28:57 +08:00
|
|
|
await uploadTestImage(page);
|
|
|
|
|
|
|
|
|
|
// Should show the image preview (file info)
|
|
|
|
|
await expect(page.getByText(/test-image/i).first()).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
test("change file button resets upload", async ({ loggedInPage: page }) => {
|
2026-03-22 19:28:57 +08:00
|
|
|
await uploadTestImage(page);
|
|
|
|
|
|
|
|
|
|
// Click change file
|
|
|
|
|
await page.getByText("Change file").click();
|
|
|
|
|
|
|
|
|
|
// Should go back to dropzone
|
|
|
|
|
await expect(page.getByText("Upload from computer")).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-25 09:27:12 +08:00
|
|
|
test("clicking quick action tool navigates with file", async ({ loggedInPage: page }) => {
|
2026-03-22 19:28:57 +08:00
|
|
|
await uploadTestImage(page);
|
|
|
|
|
|
|
|
|
|
// Click resize quick action
|
|
|
|
|
await page
|
|
|
|
|
.getByRole("button", { name: /resize/i })
|
|
|
|
|
.first()
|
|
|
|
|
.click();
|
|
|
|
|
|
|
|
|
|
await expect(page).toHaveURL("/resize");
|
|
|
|
|
|
|
|
|
|
// File should still be loaded (no dropzone)
|
|
|
|
|
await expect(page.getByText("Upload from computer")).not.toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("footer has theme toggle", async ({ loggedInPage: page }) => {
|
|
|
|
|
// Footer should have theme toggle
|
|
|
|
|
const footer = page.locator("[class*='fixed'][class*='bottom']").last();
|
|
|
|
|
await expect(footer).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
});
|