Skip to content

Documentation

Redirect Manager Tests — Control Map

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

7/19/2026
2 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, confirm delete
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
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
  • 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/run-e2e-ci.ts --no-build --project=chromium "--grep=redirects"
testinge2eredirects
Was this page helpful?