SPB Git

Repository Public

TESTING.md 7.7 KB

# Testing

Results of the last full run are recorded in IMPLEMENTATION_STATUS.md. This file explains what each layer covers.

# Commands

bash
pnpm typecheck        # tsc --noEmit, strict + noUncheckedIndexedAccess
pnpm lint             # eslint
pnpm test             # vitest — tests/*.test.ts (the media tests need ffmpeg and say so when they skip)
pnpm build            # production build
pnpm media:test-capsule && pnpm build:preview
pnpm leak-check       # unpublished content: scans both builds, then starts each and crawls it; client bundle scan
pnpm test:e2e         # Playwright, headless: public (8841), dev preview (8842), studio on a throw-away database (8843) + a real worker
pnpm secret-scan
pnpm clean-check      # no ignored/untracked source file; a `git archive HEAD` export type-checks on its own
pnpm audit            # dependencies
pnpm test:all         # everything above except the audit, in order
pnpm screenshots      # public pages → docs/screenshots/ ; studio captures are written by the studio spec to e2e/.tmp/studio/shots/

Playwright starts and stops its three servers; the global setup starts the media worker and the teardown stops it by PID. Nothing opens a window. Media used by the tests are generated by ffmpeg at run time and never committed.

# Unit and integration tests (tests/)

File Covers
publication.test.ts, importer.test.ts, urls.test.ts, quiz.test.ts, progress.test.ts, search.test.ts, diagrams.test.ts, paths.test.ts, brand.test.ts Phases 1–3 (unchanged, except one fixture in publication.test.ts: media permission now follows the files a capsule names)
studio-auth.test.ts migrations from an empty database (idempotent, forward-only, atomic, mismatch refused); roles; enrolment tokens (hashed, single live token, expiry); registration ceremony bound to the browser; sessions (hashing, expiry, idle, rotation, revocation, disabled editor); last-owner protection; challenge replay; lock-out surviving a restart; origin check; rate limiter; log redaction
studio-publication.test.ts seeded studio = same public view as the snapshot; database never created by a public read; workflow and confirmation; drafts and private items unreachable (view, search index, sitemap, structured data); edits invisible until republished; private preview view; scheduling by time, cancellation; history, rollback, withdrawal, archive; media permission before/after publication; publication blockers; slug change → redirect; stale edits; public plan
studio-sync.test.ts import diff (update, conflict, addition, removal), default keeps local, decisions, idempotence, never publishes, new sessions as drafts, tolerance of half-written sessions, solutions and symlinks never read, unreadable source
studio-media.test.ts ladder (never upscales); chunk assembly in any order, per-piece and whole-file checksums, altered or misplaced pieces, on-disk damage, resume, duplicate detection, validation before sending, disguised files, sweep; resource versions; with real ffmpeg: toolchain detection and clear failure when missing, ffprobe validation, upload → queue → worker → HLS + MP4 + poster + thumbnails with the master untouched, silent source, captions, transcript, chapters, re-encode never rewriting published files
studio-archive.test.ts zip and tar.gz forged in the test: traversal names, links and devices, bombs (ratio, sizes, entry count), lying headers, duplicates, encryption, pax long names
studio-captions.test.ts WebVTT validation (12 refusal cases, warnings), language tags, transcript import, file-type detection, safe file names
studio-jobs.test.ts queue state machine, atomic claim, back-off, permanent errors, cancellation, manual retry, recovery of dead workers, heartbeat; worker loop with bounded concurrency, cancel while running, graceful stop
studio-ops.test.ts backup → restore drill into an empty directory (same public view, audit and history), full backup, tamper detection, existing database protected, newer backup refused, retention; export without credentials; health states; storage; link and integrity checker
studio-slides.test.ts deck structure from sources (labels, kinds, notes skipped), page text cleaning, page → slide mapping incl. the « never guess identifiers » fallback; local resume state; with poppler, on hand-made PDFs: build of both themes, determinism, skipped sessions, pack import and tampered packs, slides-only publication (state, counts, search, deep links), refusal to publish more, unpublish, deck replacement; speaker notes absent everywhere; with the real repository when present: S01 has one slide per PDF page, every content frame identified, no note phrase in the deck
markdown.test.ts XSS probes, KaTeX, highlighting, tables, heading offset

# End-to-end (e2e/)

Spec Projects Covers
journey, player, production, features, a11y, mobile chromium, webkit, firefox, mobile Phases 2–3, unchanged except: /admin now redirects to the sign-in page (asserted) and the 404 page is tested on another address
slides.spec.ts chromium, webkit, mobile a fourth server (8844) with decks built by the global setup through the operator commands: honest states and counts; keyboard, « aller à », outline, overview, text version, copy link, presentation mode; deep links and local resume, cleared by « Effacer mes données locales »; theme following the site and toggled, images really rendered in Chromium and WebKit; search hit → slide; leaks (unpublished deck 404 by every address, absent from search and sitemap, no speaker note served); axe in both themes; 375 px: no overflow, 44 px targets, swipe
studio.spec.ts studio (Chromium, virtual WebAuthn authenticator via CDP) 25 serial tests: closed studio; invalid link; enrolment, cookie scope; sign-out, replay of a closed session, sign-in, foreign authenticator refused; dashboard health; import with a conflict, a new session, incomplete sessions, then the same source as an archive (no change); editing (fiche, Markdown with XSS probes, quiz with preview, glossary); upload of a disguised file (refused), of a synthetic video, encode by the worker, duplicate reuse; invalid then valid captions, timing preview, chapters; resource checks and replacement; private preview vs anonymous; publish → anonymous checks (page, video, captions, transcript search hit, sitemap, structured data, no cookie); licence + plan; edit → republish → rollback → withdraw with anonymous checks at each step; scheduling; tools and journal; author role; disabling an editor; negative security (anonymous, foreign origin, CSRF, replay, traversal, altered piece, rate limit); health details; axe on 14 screens + editors + a dialog in both themes; screenshots at 1440 px and 834 px with an overflow check

# What the tests do not prove

  • Real passkeys (Touch ID, iPhone, synced keys), real browsers other than headless Chromium for the studio.
  • The production gateway: TLS, forwarded headers, body limits, caching, resumable uploads over a real unstable link.
  • Real lecture-length or 4K video, encode times, storage and bandwidth figures.
  • Real devices for playback of studio-produced streams (iPhone/iPad Safari).
  • Concurrency of several editors on the same session beyond the revision check; several workers at once (the claim is atomic and unit-tested, never run with two processes).
  • Screen readers (axe is automated rules only); performance; load.
  • A scheduled publication actually reaching its due time on a running server (the time logic is unit-tested with explicit dates; e2e checks invisibility before the date and cancellation).
  • The CI workflow (never executed) and the deployment.
Files main
Menu

Theme