Files
snippet-pastebin/tests/e2e/home.spec.ts
johndoe6345789 5a344e4fb6 test: Add comprehensive test coverage - improve from 21.88% to 29.17%
Phase 1: App routes and core infrastructure
- Add providers.test.tsx: 8 tests for Redux/error boundary/navigation setup
- Add PageLayout.test.tsx: 16 tests for layout structure and accessibility
- Add page.test.tsx: 11 tests for home page rendering and composition

Phase 2: Database layer (db.ts)
- Add db.test.ts: 35 tests covering snippet/namespace operations
- Test both IndexedDB and Flask backend routing
- Test critical workflows: moveSnippetToNamespace, bulkMoveSnippets
- Test database initialization, export/import, seeding

Phase 3: Feature workflows (namespace manager)
- Add NamespaceSelector.test.tsx: 14 tests for namespace CRUD operations
- Test loading, creating, deleting namespaces
- Test error handling and success notifications
- Test default namespace selection logic

Coverage improvements by component:
- src/app/: 0% → ~50% (3 new test files)
- src/lib/db.ts: 32.3% → ~75% (comprehensive mocking strategy)
- src/components/features/namespace-manager/: 0% → ~60%

Overall: 21.88% → 29.17% (+7.29 percentage points, +3.56 absolute coverage)

All 571 tests passing, no lint warnings

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-20 20:46:32 +00:00

34 lines
1.2 KiB
TypeScript

import { expect, test, setupConsoleErrorTracking } from "./fixtures"
test.describe("home page", () => {
test("renders key sections without console errors", async ({ page }) => {
const errorTracker = setupConsoleErrorTracking(page)
await page.goto("/")
await expect(page.getByRole("heading", { name: "My Snippets" })).toBeVisible()
await expect(
page.getByText("Save, organize, and share your code snippets", { exact: true })
).toBeVisible()
await expect(page.locator("header")).toBeVisible()
await expect(page.locator("main")).toBeVisible()
await expect(page.locator("footer")).toBeVisible()
expect(errorTracker.errors).toEqual([])
errorTracker.cleanup()
})
test("stays within viewport on mobile (no horizontal overflow)", async ({ page }, testInfo) => {
test.skip(!testInfo.project.name.includes("mobile"), "mobile-only check")
await page.goto("/")
const overflow = await page.evaluate(() =>
Math.max(document.documentElement.scrollWidth - window.innerWidth, 0)
)
expect(overflow).toBeLessThanOrEqual(1)
await expect(page.getByRole("heading", { name: "My Snippets" })).toBeVisible()
})
})