refactor(admin): share one sticky-cache test across the admin loads - #948
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inadmin.js. No_loadSingletonfactory: the load/update pairs have never drifted and read fine as they are.Test plan
admin-store-helpers.test.jspinsisFresh: falsy stamps, the window edges,Infinity, the defaults, anundefinedTTL falling back to the default.<→<=inisFreshfails 14 admin tests.No NEWS line: no behavior change.
🤖 Generated with Claude Code