forked from akai/readest
13588b4a65
Set up WebDriver-based testing for the Tauri app with two tiers: - Vitest browser-mode tests (*.tauri.test.ts) running inside the Tauri WebView for plugin IPC testing (libsql, smoke tests) - WDIO E2E tests (*.e2e.ts) for UI-level interaction testing Key changes: - Add webdriver Cargo feature gating tauri-plugin-webdriver - Add runtime capability for remote URLs (webdriver builds only) - Add vitest.tauri.config.mts and wdio.conf.ts connecting to embedded WebDriver server on port 4445 - Add shared tauri-invoke helper for IPC from Vitest iframe context - Add testing documentation in docs/testing.md
3.3 KiB
3.3 KiB
Project Overview
Readest is a cross-platform ebook reader built as a Next.js 16 + Tauri v2 hybrid app. It's part of a pnpm monorepo at /apps/readest-app/. The app runs on web (CloudFlare Workers), desktop (macOS/Windows/Linux via Tauri), and mobile (iOS/Android via Tauri).
Common Commands
# Development
pnpm dev-web # Web-only dev server (no Rust compilation needed)
pnpm tauri dev # Desktop dev with Tauri (compiles Rust backend)
# Building
pnpm build # Build Next.js for Tauri
pnpm build-web # Build Next.js for web deployment
# Testing (see [docs/testing.md](docs/testing.md) for full details)
pnpm test # Unit tests (vitest + jsdom)
pnpm test -- src/__tests__/utils/misc.test.ts # Run a single test file
pnpm test -- --watch # Watch mode
pnpm test:browser # Browser tests (Chromium via Playwright)
pnpm tauri:dev:test # Start Tauri app with webdriver
pnpm test:tauri # Run Tauri integration tests
# Linting & Formatting
pnpm lint # ESLint
pnpm format # Prettier (runs from monorepo root)
pnpm format:check # Check formatting without writing
# Rust
pnpm clippy # Lint Rust code (src-tauri)
Source Layout
| Directory | Purpose |
|---|---|
src/app/ |
Next.js App Router pages and API routes |
src/components/ |
React components (reader, settings, library, assistant, etc.) |
src/services/ |
Business logic: TTS, translators, OPDS, sync, AI, metadata |
src/store/ |
Zustand state stores |
src/hooks/ |
Custom React hooks |
src/libs/ |
Document loaders, payment, storage, sync |
src/utils/ |
Pure utility functions |
src/types/ |
TypeScript type definitions |
src/context/ |
React Context providers (Auth, Env, Sync, etc.) |
src/workers/ |
Web Workers for background tasks |
src-tauri/ |
Rust backend: Tauri plugins, platform-specific code |
Path Aliases (tsconfig)
@/*→./src/*@/components/ui/*→./src/components/primitives/*
Rust Backend (src-tauri/)
Platform-specific code lives in src-tauri/src/{macos,windows,android,ios}/. Custom Tauri plugins are in src-tauri/plugins/.
Project Rules
TypeScript
- Never use the
anytype. Useunknown, proper types, or generics instead. - Strict mode is enabled. Target is ES2022.
- Unused vars prefixed with
_are allowed (ESLint configured).
Build Constraints
- No optional chaining (
?.) in build output — verified bycheck:optional-chaining. - No lookbehind regex in build output — verified by
check:lookbehind-regex. - Run
pnpm build-check(builds both targets + runs all checks) before submitting.
Safe Area Insets
See docs/safe-area-insets.md for rules on handling top/bottom insets for UI elements near screen edges.