Files
SnapOtter/tests/e2e/navigation.spec.ts
T
Siddharth Kumar Sah 80e536bcf8 chore: remove dead code, add test infrastructure, update docs
- Delete 3 dead files: use-batch-processor.ts, use-i18n.ts, smart-crop.ts (AI package)
- Remove dead getJobProgress function and unused runPythonScript wrapper
- Remove 6 unused imports across API and web apps
- Remove unused shared types (ImageFormat, AppConfig, ApiError, HealthResponse, JobProgress)
  and constants (SUPPORTED_INPUT_FORMATS/OUTPUT_FORMATS, DEFAULT_OUTPUT_FORMAT)
- Remove unused store method (setOriginalBlobUrl) and clean AI package re-exports
- Add test infrastructure: vitest config, unit/integration/e2e tests, fixtures, screenshots
- Add Docker test infrastructure: Dockerfile.test, docker-compose.test.yml
- Add download_models.py for pre-baking AI model weights in Docker
- Add filename sanitization utility (apps/api/src/lib/filename.ts)
- Update .gitignore to exclude coverage/, *.tsbuildinfo, .superpowers/, test artifacts
- Update .dockerignore to exclude test/coverage/IDE artifacts from builds
- Update docs: remove smart crop from AI docs (uses Sharp directly), update bridge docs
2026-03-23 11:46:45 +08:00

98 lines
3.2 KiB
TypeScript

import { test, expect } from "./helpers";
test.describe("Navigation", () => {
test("sidebar Tools link goes to home", async ({ loggedInPage: page }) => {
await page.goto("/automate");
await page.locator("aside").getByText("Tools").click();
await expect(page).toHaveURL("/");
});
test("sidebar Grid link goes to fullscreen view", async ({
loggedInPage: page,
}) => {
// Click the Grid link in the sidebar (links to /fullscreen)
const gridLink = page.locator("aside").getByText("Grid");
// If "Grid" text isn't directly visible (collapsed sidebar), try the link
if (await gridLink.isVisible({ timeout: 3000 }).catch(() => false)) {
await gridLink.click();
} else {
// Fallback: navigate via the href directly
await page.locator('aside a[href="/fullscreen"]').click();
}
await expect(page).toHaveURL("/fullscreen");
});
test("sidebar Automate link goes to automate page", async ({
loggedInPage: page,
}) => {
await page.locator("aside").getByText("Automate").click();
await expect(page).toHaveURL("/automate");
});
test("sidebar Settings button opens settings dialog", async ({
loggedInPage: page,
}) => {
await page.locator("aside").getByText("Settings").click();
// Settings dialog should appear with section headings
await expect(page.getByRole("heading", { name: "General" })).toBeVisible();
await expect(page.getByRole("button", { name: "Security" })).toBeVisible();
});
test("fullscreen grid page renders tool cards", async ({
loggedInPage: page,
}) => {
await page.goto("/fullscreen");
// Should show category headers
await expect(page.getByText("Essentials")).toBeVisible();
await expect(page.getByText("Optimization")).toBeVisible();
await expect(page.getByText("Adjustments")).toBeVisible();
// Should show tools
await expect(page.getByText("Resize")).toBeVisible();
await expect(page.getByText("Compress")).toBeVisible();
await expect(page.getByText("Convert")).toBeVisible();
});
test("fullscreen grid has search functionality", async ({
loggedInPage: page,
}) => {
await page.goto("/fullscreen");
const searchInput = page.getByPlaceholder(/search/i);
await expect(searchInput).toBeVisible();
// Search for a specific tool
await searchInput.fill("resize");
await expect(page.getByText("Resize")).toBeVisible();
});
test("clicking a tool in fullscreen grid navigates to tool page", async ({
loggedInPage: page,
}) => {
await page.goto("/fullscreen");
// Click on Resize tool
await page.getByRole("link", { name: /resize/i }).first().click();
await expect(page).toHaveURL("/resize");
});
test("automate page shows pipeline templates", async ({
loggedInPage: page,
}) => {
await page.goto("/automate");
// Should show pipeline builder
await expect(
page.getByText(/pipeline|automation|workflow/i).first(),
).toBeVisible();
});
test("tool panel shows categories on home page", async ({
loggedInPage: page,
}) => {
// The tool panel should show categorized tools
await expect(page.getByText("Essentials").first()).toBeVisible();
});
});