Skip to content

test(e2e): derive the grid layout key, make missing fixtures skip honestly (#2199) - #2221

Merged
vybe merged 6 commits into
devfrom
trinity-ability/issue-2199
Aug 16, 2026
Merged

vybe merged 6 commits into
devfrom
trinity-ability/issue-2199

Conversation

@trinity-ability

Copy link
Copy Markdown
Contributor

Fixes #2199

Summary

6 failing tests fixed across 11 files.

  • Grid layout key derived, not hand-copied: the layout localStorage key is now imported from a new zero-dependency src/utils/gridStorageKeys.js — the store imports it via the @ alias, the Playwright specs via a plain relative path (Playwright resolves neither vite.config.js nor a tsconfig paths map, hence zero imports by documented design). A vitest source guard (tests/unit/gridStorageKeys.spec.js, 5 tests) pins store-imports, values, and the zero-import property so the next key bump propagates instead of silently desyncing the specs again (feat(grid): widget chassis — InfoTile, GRID_WIDGETS registry, layout v2, Tiles menu (ent#325) #2042's v1→v2 bump is how this broke).
  • Missing fixture agents skip honestly via ONE shared authenticated probe (e2e/helpers/agent-probe.js) with a two-sided contract: a definitive 404 → skip with an honest reason; 401/403/5xx/transport → THROW with the real diagnosis. The anti-pattern this PR eradicates — an unauthenticated probe whose 401 read as "agent not found" — produced silent skips with false reasons on every run.

Scope corrections vs the issue

  • system-install was NOT already fixed upstream — 0f36de8f (feat(library): tabbed Library + per-skill "assigned to" agent list (trinity-enterprise#384) #2125) was necessary but insufficient once ent#384 wrapped the Library in tab <section>s. Fixed here with an ancestor::section[1] anchor (positional .last() rejected — it's how this broke twice), with red-before/green-after AND a non-vacuity probe.
  • Also included: the 5th testfix consumer the issue missed (portal-agent-page-overview — didn't exist at the sweep's commit) and the 6th stale v1-key holder (grid-org-overlay cleanup — silently cleared nothing).

Found in passing, fixed

A 3rd instance of the unauthenticated-probe anti-pattern in honest-failed-states: 401 → [] → skip claiming "has no schedules" — a false diagnosis.

Evidence

Full-suite: 95 → 97 passed / 8 failed / 19 skipped. All 8 residual failures map 1:1 to open issues:

Five-run verification protocol, including proof the skip guards aren't permanently skipping: 9 passed / 0 skipped with *_TEST_AGENT=acme-sage.

Note for #2197's owner

dashboard-stats-overflow.spec.js:4,:100 cites the CLOSED #1830 — anyone tracing the failure lands on a closed issue; the one-line citation fix belongs in #2197.

Cross-refs

CI honesty note

None of the 6 fixed tests are @smoke; frontend-e2e is smoke-only + advisory (#1526) with retries: 2 — the evidence above is local full-suite runs on a branch-serving dev server, not CI.

Follow-ups (listed, NOT filed)

🤖 Generated with Claude Code

trinity-ability and others added 6 commits August 15, 2026 20:12
#2042 (ent#325) bumped the Grid layout key v1 -> v2 in stores/fleetGrid.js,
but dashboard-grid-view.spec.js and grid-org-overlay.spec.js each carried
their own hand-copied 'trinity-grid-layout-v1'. Nothing failed loudly: the
read-backs resolved null (2 tests red for what looked like a product bug)
and grid-org-overlay's removeItem cleanup silently stopped clearing
anything at all.

New zero-import src/utils/gridStorageKeys.js is the single source of truth,
imported by the store via the Vite alias and by the specs via a relative
path. It must stay import-free: Playwright reads neither vite.config.js nor
a tsconfig paths map, so one aliased import would break every grid spec.
utils/gridLayout.js is the established zero-import precedent.

Three details that are easy to get wrong:

- The cleanup clears ALL_LAYOUT_KEYS, not just LAYOUT_KEY. _loadSavedRaw
  migrates a v1 blob into v2 when v2 is absent, so clearing only the current
  key lets a stale layout be migrated straight back in.
- The addInitScript argument is SPREAD into one flat array and the callback
  iterates it. Nesting it would call removeItem() with an Array and clear
  nothing — a silent no-op behind green-looking code. Verified both ways
  with a throwaway spec before landing.
- 'tidy up compacts and reset' asserted p.r >= 0 across the whole map, a
  stale v1-era assumption from when the blob held agent keys only. Layout v2
  also holds widget:* keys, which seedWidgetCells places in the band ABOVE
  the fleet (rows -3..-1, "spill upward, never into the agents"). The
  assertion now branches on isWidgetKey — imported, not a hand-copied
  'widget:' literal, for the same reason as the layout key.

fleetGrid.js is a pure move: three consts and their rationale comments out,
one import in. The v1/v2 pair and its one-time COPY migration are deliberate
and untouched.

tests/unit/gridStorageKeys.spec.js is the ratchet on top: the module fixes
today's desync but cannot stop a NEW spec from hand-copying the literal
again. It is also the only automatically-enforced part of this change —
frontend-build.yml runs npm run test:unit on every src/frontend/** PR, while
frontend-e2e is advisory and smoke-only (#1526) and none of these tests are
@smoke. Negative-tested: it fails and names the offending file.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Five specs default their fixture agent to "testfix", which exists on no
typical instance, and none of them checked. loops-panel (x2),
continue-as-chat (x1) and workspace-absorbs-session (x1) failed outright;
portal-agent-page-overview's 5 tests each hung ~20s on a heading that never
renders and then failed. All of it read as product breakage.

The probe lives in ONE place, e2e/helpers/agent-probe.js, and is
AUTHENTICATED. That is the whole point: GET /api/agents/{name} is behind
AuthorizedAgent and Trinity's JWT lives in localStorage, not a cookie, so a
bare request.newContext({ baseURL }) 401s and test.skip() then fires on every
run — the test reads as "skipped" forever and nobody notices it stopped
covering anything. Four independent copies of that probe is exactly how the
anti-pattern spread; one commented helper makes it unrepeatable.

Shapes differ per spec, deliberately:

- loops-panel / continue-as-chat: beforeAll sets agentReady + skipReason, a
  beforeEach calls test.skip (the verified in-repo pattern; test.skip does
  not apply to tests when called from beforeAll).
- continue-as-chat probes BEFORE mutating session_tab_enabled and RETURNS on
  failure. Setting a flag does not abort beforeAll: without the return it
  fell through and flipped a fleet-wide platform setting for a run
  guaranteed to skip. A new flagTouched guard also stops afterAll PUTting
  {value: undefined} on the login-failure path, where priorFlag is undefined
  and the old `=== null` test was false.
- workspace-absorbs-session guards INSIDE its @Interactive test only. A
  describe-level beforeEach would also skip its two @smoke tests, which are
  deliberately fixture-free and are the tier CI runs.
- portal-agent-page-overview takes a describe-level guard; all 5 need the agent.

Only the two beforeAll "Admin login failed" throws become skips (an
environment gap, not a product failure). createResumableExecution's two
throws stay throws — once the agent provably exists those are genuine
failures. This converts fixture-ABSENCE into a skip, not failures into skips.

honest-failed-states carried the same defect twice: an unauthenticated agent
probe, and an unauthenticated /schedules fetch whose 401 yielded [] and
skipped claiming "has no schedules to toggle" — a false diagnosis of an auth
failure. Both now authenticated; its previously-dark task-history test runs
and passes. The remaining skip is honest and verified (trinity-system really
has 0 schedules).

Skip messages name the override env var, so the run output says exactly how
to make the test run.

Scope note: circuit-breaker-badge.spec.js has the identical unauthenticated
probe and is deliberately NOT converted here. With an authenticated probe its
@smoke test fails — circuit-open-badge never appears, though the data-testid
is still present in AgentHeader.vue — which needs its own issue. Un-skipping
a failing @smoke test would turn the nightly signal red for a cause this
change does not own.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ontract (#2199)

The CI section claimed "CI runs e2e only on PRs labeled `ui`". #1526 changed
that precisely because the suite rotted silently and sat red on dev for
weeks: it now runs nightly on dev, auto-runs on any PR touching
src/frontend/**, and the `ui` label is a manual opt-in for non-frontend PRs.
The old text actively misleads anyone debugging this suite.

Two consequences are now stated, because both change how a coverage claim
should be read: CI runs test:e2e:smoke only (so @visual/@Interactive results
are never in it), and the workflow is advisory rather than a required merge
gate. A full-suite claim therefore has to be evidenced by a local run.

Adds a Fixture agents section: the env var per spec, what each needs, and the
contract this change establishes — a missing fixture reads as SKIPPED, never
broken, and the probe MUST be authenticated. Records the known gap on
circuit-breaker-badge rather than leaving it to be rediscovered.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…on (#2199)

AC bullet 2. This was originally scoped OUT of #2199 as "already fixed
upstream by 0f36de8 (#2125)". It is not: reading the scoping code and
concluding the test passed conflated presence of a fix with efficacy of one.
Run at a correct origin, it still fails with the exact strict-mode violation
the AC describes:

  strict mode violation: ...getByText('e2e-preview-only-alpha')
  resolved to 4 elements

0f36de8 was necessary but not sufficient. `page.locator('section')
.filter({ has: heading })` matches EVERY section containing that heading, not
the innermost one. ent#384 later wrapped this surface in the Library's own
tabbed `<section id="systems">` (views/Library.vue:323), so the outer wrapper
matched too — and it contains all four renders (agents table, both topology
columns, schedules table), reproducing the original violation.

Anchoring upward from the heading to `ancestor::section[1]` selects the
nearest enclosing section by construction, so it survives any number of
further wrappers. `.last()` would pass today but is positional, and an added
wrapper is precisely how this broke twice.

The existing rationale for preferring a tighter container over `.first()` is
unchanged and kept — `.first()` would still pass on whichever element merely
came first, rather than asserting the name is in the AGENTS table.

Verified at an origin serving this worktree (Vite dev server; the docker
frontend bind-mounts the main checkout and cannot see local changes):
red before (1 failed / 12 passed), green after (13 passed / 1 skipped).
Non-vacuity checked too — a probe asserting 'nightly' (schedules-table text,
outside the agents section) fails under the new locator, proving the scope is
genuinely the inner section and not the outer wrapper.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ot found" (#2199)

Review finding (Wave 3). agentExists collapsed every non-ok outcome into
false: a 401 (setup never wrote e2e/.auth/admin.json, or the JWT died with a
mid-run backend restart), a 403, a 5xx, and a transport error all read
exactly like a missing fixture, so every consumer skipped under
missingAgentReason() — a FALSE diagnosis. That is the circuit-breaker-badge
defect wearing a new hat: the probe was authenticated now, but a probe whose
auth breaks still degraded to a silent skip, this time with a reason string
actively pointing at the wrong cause. Reproduced before the fix: corrupting
the storageState token and running portal-agent-page-overview --no-deps
yielded "5 skipped: agent 'testfix' not found".

The contract is now two-sided, matching the helper's own docstring: only a
definitive 404 — the platform's uniform Invariant #8 "no such agent" answer —
reads as fixture-absent (return false, caller skips). Everything else throws,
failing the test with the real diagnosis. Verified live both ways against a
Vite dev server on this worktree:

- valid auth + bogus agent  -> honest skips (workspace-absorbs-session:
  2 @smoke passed + 1 skipped; portal-agent-page-overview: 5 skipped)
- corrupted token, --no-deps -> 5 FAILED loudly with "agent probe for
  'testfix' broke: HTTP 401 ... refusing to skip", 0 skips

honest-failed-states' schedule probe carried the same collapse one hop away
(non-ok -> [] -> skip "has no schedules to toggle"): now a 404 skips with
missingAgentReason, any other non-ok throws, and only a genuinely empty list
skips as "no schedules". Re-run: 5 passed, 1 honest skip (trinity-system
really has 0 schedules).

README contract sentence and helper docstring updated to state the inverse
rule; the docstring also stops naming honest-failed-states as a live carrier
of the defect (this branch fixed it — circuit-breaker-badge remains the
documented known gap).

Co-Authored-By: Claude Fable 5 <[email protected]>
The known-gap note shipped with a #NNNN placeholder because the issue did
not exist yet. #2210 is now filed — and as a TEST defect (the spec mocks
the standalone /circuit-breaker endpoint the agent page never calls; the
badge reads the circuit_breaker block embedded in the agent response), so
the note's "looks like a product defect" hedge is replaced with the
confirmed diagnosis.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions

Copy link
Copy Markdown

⚠️ Nightly unit-suite check skipped — merge conflict against dev.

Resolve by running git merge dev locally and pushing the result. The next nightly run will re-test once the conflict is gone.

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated via /validate-pr: security scans clean, all CI green (3 head seeds + regression diff), Fixes #2199 closing keyword present. Test-only + a new zero-dependency gridStorageKeys.js constant module with a vitest source guard pinning the store-import and zero-import properties — the right shape to stop the #2042 key-bump desync recurring. Merges clean against dev; six-PR sequence simulated locally (470 tests green on the merged tree).

@vybe
vybe merged commit 5aff56e into dev Aug 16, 2026
22 checks passed
@vybe
vybe deleted the trinity-ability/issue-2199 branch August 16, 2026 10:36
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.

2 participants