Redirect Manager Tests — Control Map
Coverage for /config/redirects: admin gate, redirectsMV CRUD, search, confirm delete.
On this page
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) -
redirectsMVprimary (aligned with middleware) — not content-collection-only -
normalizeRedirectRowparses stringdataJSON from legacy collection rows -
showConfirmfor delete;invalidateAllafter mutations - Stable
data-testids + visible action buttons (not zero-size icon-only) - Compound lookup index for cold-path O(log n)
Associated tests
- redirects.spec.ts
- redirects-server.test.ts
- redirects-utils.test.ts (if present)
- redirects-remote-admin.test.ts
Run
bun test tests/unit/routes/redirects-server.test.ts
bun run scripts/run-e2e-ci.ts --no-build --project=chromium "--grep=redirects"
Was this page helpful?