Set up Mangalord with a Rust/axum backend, SvelteKit frontend, Postgres, and Docker Compose deployment. Establishes the architecture and TDD patterns the project will extend: - Hexagonal-ish backend layering (domain / repo / storage / api) with a pluggable Storage trait (LocalStorage today, S3 as a future impl). - Initial migration: users, mangas, chapters, bookmarks. - Vertical slice for mangas (list, search, create, get) with #[sqlx::test] integration coverage and storage unit tests. - SvelteKit frontend using Svelte 5 runes, typed API client, Vitest unit tests and Playwright e2e with route mocking. - CLAUDE.md documenting layering, TDD/git/SemVer workflow rules, and extension points (tags, fulltext search, OCR, S3, auth). - Project-scoped .claude/settings.json with permission allowlist for the toolchain (git, cargo, npm/vite, docker, psql, gh, doc fetches). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
// These E2E tests run against the dev server (vite on :5173) which proxies
|
|
// /api to the backend. Set E2E_BASE_URL to point at a different deployment.
|
|
//
|
|
// A live backend (and Postgres) must be reachable. Routes mock the network
|
|
// where possible to keep journeys deterministic.
|
|
|
|
test('home page renders the Mangalord heading and search input', async ({ page }) => {
|
|
// Mock the list endpoint so the test doesn't depend on DB state.
|
|
await page.route('**/api/mangas*', async (route) => {
|
|
await route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify([])
|
|
});
|
|
});
|
|
|
|
await page.goto('/');
|
|
await expect(page.getByRole('link', { name: 'Mangalord' })).toBeVisible();
|
|
await expect(page.getByTestId('search-input')).toBeVisible();
|
|
await expect(page.getByTestId('empty')).toContainText('No mangas yet');
|
|
});
|
|
|
|
test('search updates the manga list', async ({ page }) => {
|
|
let lastSearch: string | null = null;
|
|
await page.route('**/api/mangas*', async (route) => {
|
|
const url = new URL(route.request().url());
|
|
lastSearch = url.searchParams.get('search');
|
|
const body =
|
|
lastSearch === 'berserk'
|
|
? [
|
|
{
|
|
id: 'b1',
|
|
title: 'Berserk',
|
|
author: 'Kentaro Miura',
|
|
description: null,
|
|
cover_image_path: null,
|
|
created_at: '2026-01-01T00:00:00Z',
|
|
updated_at: '2026-01-01T00:00:00Z'
|
|
}
|
|
]
|
|
: [];
|
|
await route.fulfill({
|
|
status: 200,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify(body)
|
|
});
|
|
});
|
|
|
|
await page.goto('/');
|
|
await page.getByTestId('search-input').fill('berserk');
|
|
await page.getByRole('button', { name: 'Search' }).click();
|
|
|
|
await expect(page.getByTestId('manga-list')).toContainText('Berserk');
|
|
expect(lastSearch).toBe('berserk');
|
|
});
|