Skip to content

Documentation

Redirect Manager Tests — Control Map

Coverage for /config/redirects: admin gate, redirectsMV CRUD, search, confirm delete.

7/19/2026
3 min read Edit on GitHub

Surface

Piece Role
+page.server.ts Auth + admin-only gate; load via listRedirects()
+page.svelte Table, search, modal create/edit with first-run explainer + per-field ? tooltips, confirm delete
handle-redirects.ts Exact redirectsMV match first, then cached isRegex rules (findRegexRedirect, bounded)
redirects-utils.ts Path validation, payload normalize, normalizeRedirectRow
redirects.server.ts Primary: redirectsMV insert/update/delete + content mirror
redirects.remote.ts SvelteKit command wrappers
Middleware handle-redirects reads redirectsMV (source / target)

Storage contract (2026-07-19)

Store Role Field names
redirects_mv Source of truth for admin UI + runtime source, target
collection_redirects Best-effort CMS mirror (non-fatal) nested data JSON
UI Always from / to mapped on load

Index: idx_redirects_mv_lookup on (tenantId, source, active) — SQLite / MariaDB / PostgreSQL.


Control → test matrix

Control Unit E2E
Admin gate (403 non-admin) ✅ page.server / requireAdmin —
Validation (from/to paths, type) ✅ redirects-utils + redirects.server —
Create → MV insert + cache invalidate ✅ redirects.server ✅ golden create
List maps source/target → from/to ✅ normalizeRedirectRow + listRedirects ✅ search/list
Delete + confirm (no window.confirm) ✅ server ✅ delete happy path
Regex rule resolution (exact wins) ✅ hooks/redirects + redirects-utils —
Shell + search + empty — ✅

Product hardening

  • Admin-only page load and mutations
  • Pure validation helpers (redirects-utils.ts)
  • redirectsMV primary (aligned with middleware) — not content-collection-only
  • normalizeRedirectRow parses string data JSON from legacy collection rows
  • showConfirm for delete; invalidateAll after mutations
  • Add/Edit modal explains how redirects work and exposes a ? tooltip per field (icon-only triggers, HelpIcon + SystemTooltip)
  • Regex rules are evaluated after an exact-path miss (per-tenant cache, 2048-char path cap, ≤200 rules, save-time ReDoS guard)
  • Stable data-testids + visible action buttons (not zero-size icon-only)
  • Compound lookup index for cold-path O(log n)

Associated tests

Run

bun test tests/unit/routes/redirects-server.test.ts
bun run scripts/runs/run-e2e.ts --no-build --project=chromium "--grep=redirects"
testinge2eredirects
Was this page helpful?