Files
at-container-registry/test/e2e/cleanup-seeded-crew.mjs
T
Evan JarrettandClaude Opus 5 5aefa85048 test/e2e: cover the admin job wiring ab4a4eb changed
jobs_test.go covers the job framework thoroughly, but nothing covers the
wiring: whether the kickoff handler renders the progress fragment into the
right hx-target, and whether the loop actually outlives the request it was
started from. Both are what ab4a4eb changed, and both are invisible to Go
tests — a typo in an hx-target or a fragment that renders blank passes every
assertion we have.

The load-bearing check drives crew import rather than the tier remap. A
one-member remap completes in under a second, so closing the tab "mid-run"
proves nothing; import does a PDS write plus a network PLC lookup per entry,
which leaves a real window to close the browser and watch the job keep going.
It is caught mid-flight at a progress tick with no admin page open.

Seeded members are created on the local-only dev hold and removed in a
finally block. README records the environment traps found while building
this: 127.0.0.1 vs localhost, in-memory sessions dying on every hold rebuild,
UA/IP pinning that makes curl log you out, and the forward-only appview
migrations that require a per-batch DB reset.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-25 16:34:25 -05:00

28 lines
1.1 KiB
JavaScript

// cleanup-seeded-crew.mjs — remove crew members left behind by a batch check
// that crashed before its finally block ran.
//
// Worth knowing: a re-run of the seeding test will NOT recreate the condition
// it needs, because the import loop reports "already exists" and skips, which
// finishes instantly and quietly turns the detachment check into a no-op.
// Purge first, then re-run.
//
// node test/e2e/cleanup-seeded-crew.mjs [marker] # marker defaults to val00
import { open, adminPage, csrfOf, openCrew, purgeSeeded, BASE } from './lib.mjs';
const MARK = process.argv[2] ?? 'val00';
const ctx = await open();
const page = await adminPage(ctx);
const csrf = await csrfOf(page);
const [deleted, found] = await purgeSeeded(ctx, page, MARK, csrf);
console.log(`found ${found} matching "${MARK}", deleted ${deleted}`);
await openCrew(page);
const left = await page.evaluate(
(m) => (document.body.textContent.match(new RegExp(m, 'g')) || []).length, MARK);
console.log(`remaining references: ${left}`);
console.log(`hold: ${BASE}`);
await ctx.close();
process.exit(left === 0 ? 0 : 1);