Skip to content

refactor(admin): share one sticky-cache test across the admin loads - #948

Merged
ajslater merged 2 commits into
developfrom
refactor-admin-ttl-gate
Sep 28, 2026
Merged

ajslater merged 2 commits into
developfrom
refactor-admin-ttl-gate

Conversation

@ajslater

Copy link
Copy Markdown
Owner

Summary

Stacked on #947 (the table engine spec). This branch contains that PR's commit too; merge #947 first, or merge this one alone to take both.

The admin store's table loader and its six settings loaders each repeated the same five-line check of a timestamp against the cache window. They now call one exported isFresh(last, ttl = DYNAMIC_TTL_MS, now = Date.now()), so the window's edges (a never-loaded stamp is stale, and so is data exactly one window old) are defined once. Net −32 lines in admin.js. No _loadSingleton factory: the load/update pairs have never drifted and read fine as they are.

Test plan

  • New flat admin-store-helpers.test.js pins isFresh: falsy stamps, the window edges, Infinity, the defaults, an undefined TTL falling back to the default.
  • test(admin): cover the table engine #947's table engine spec and the OIDC and site defaults specs exercise three of the seven gates through the store; the tagging defaults, tag-write errors, email and throttle gates are the same one-line call. Mutation check: < → <= in isFresh fails 14 admin tests.
  • Root and frontend ESLint + Prettier; vitest 84 files, 835 tests.

No NEWS line: no behavior change.

🤖 Generated with Claude Code

ajslater and others added 2 commits September 28, 2026 13:10
The admin store's generic table engine (loadTable, loadTables, the row
writes and pending-delete revival) backs every admin tab, but the only
store specs covered OIDC and the site defaults. This adds a
characterization spec for it, with every TABLES request function mocked
and each table's real stateField kept.

It covers both response shapes loadTable accepts (a bare array and a
cursor page) and what happens to anything else, the 5 s sticky cache
per table, AgeRatingMetron never expiring, force bypassing the cache,
and loadTables filling each table's own field and resolving only when
all have landed.

It also pins which tables reload after a write: create, update and
delete force-reload only their own table, and a revive force-reloads
PendingDelete and Library, with nothing reloaded when the request
fails. The librarian-status diff keeps unchanged rows (and their
watchers) untouched, and non-staff visitors get no request and no
state change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The admin store's table loader and its six settings loaders each
repeated the same five-line check of a timestamp against the cache
window. They now call one isFresh helper, so the window's edges (a
never-loaded stamp is stale, and so is data exactly one window old) are
defined once.

No behavior change. A flat spec pins the helper. The table engine spec
and the OIDC and site defaults specs exercise three of the seven gates
through the store; the tagging defaults, tag-write errors, email and
throttle gates are the same one-line call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ajslater
ajslater merged commit faf4c84 into develop Sep 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant