Skip to content

test(platform): prove the API keys page names a failed first read - #5095

Closed
tale-code-bot wants to merge 1 commit into
mainfrom
test/api-keys-page-failed-read
Closed

tale-code-bot wants to merge 1 commit into
mainfrom
test/api-keys-page-failed-read

Conversation

@tale-code-bot

Copy link
Copy Markdown
Collaborator

Task: TALE-29 on the Development board, from #3676.

Summary

This PR adds a page-level regression test for #3676: Settings › API › REST when the API key list read fails before anything has loaded. It changes no product code.

The fix is already on main. Commit 52af3a6 (fix(platform): finish the settings-list page sizes and API key focus, 2026-09-28) passes the read's error and refetch from useApiKeys through ApiRestPage into ApiKeysTable (rest.tsx lines 38 and 79–80). The table hands both to useListPage, and DataTable then shows the shared ErrorDisplayCompact (Something went wrong with Try again) instead of its skeleton. That commit does not reference #3676, so the issue stayed open.

The table and the hook have their own tests, but no test mounted the page with a failed read. Removing that wiring again leaves every existing suite green (see Tested), so nothing guarded it. This PR adds the guard.

Change

  • New services/platform/app/routes/dashboard/$id/settings/api/rest.read-failure.test.tsx, named like the platform's other *.read-failure.test.tsx suites. It mounts the real ApiRestPage and runs the real chain: useApiKeys → apiKeysQuery → backendFetch → ApiKeysTable → DataTable.
    • Requests go to tests/utils/synthetic-backend.ts, the closed transport that the shared describeListReadFailure uses. Nothing reaches a network.
    • That helper itself does not fit this table. It is built for paginated lists with a named list region and a refresh-failure notice. This table keeps its rows through a failed refresh by design.
    • The QueryClient keeps react-query's default three retries, with no backoff. That is also the number the app's own policy (app/router.tsx) gives both failures used here: a 503 fault, and a 401 refusal with no structured payload.
    • Stubbed, because each has its own tests: the route (createFileRoute and Link, organization org-1), useApiSettingsAccess, useCurrentMemberContext and the create dialog.
  • tests/manual/reference/automation.md: the SET-F63 row now names the page-level case and the new file.
Case What it asserts
503 fault After 4 attempts the page shows Something went wrong and Try again. There is no aria-busy skeleton, no empty state and no Create opener. Try again re-runs the same read: a 5th request and no other request. The list then shows the key.
Lapsed session (401 UNAUTHORIZED, the shared LAPSED_SESSION_ANSWER) After 4 attempts the page shows the same failure and Try again, with no skeleton and no empty state. The read also raises the lapsed-session report (onSessionLapsed) that the dashboard layout's sign-in prompt listens for.
Control: read in flight The skeleton shows (aria-busy="true"), with no Try again and no empty state. Once the read answers, the row appears.
Control: empty list The empty state shows with an enabled Create API key. There is no Try again and no skeleton, and there is one request.

Checklist

  • bun run check passes. Not run as one command: it runs lint, typecheck, test and test:ui for every workspace. I ran the parts this change touches (see Tested). This PR's CI and the merge queue run the rest.
  • bun run lint:sast passes. Not run locally: the Opengrep binary is not cached on this worker, and the script would download it. The pre-commit SAST step skipped for the same reason. CI's SAST job runs it.
  • Translations: N/A. No user-visible string changed.
  • Docs: N/A. This is a test-only change, with nothing user-visible.
  • README: N/A. This is a test-only change.

Tested

Everything below ran at head f05943b711942bfd14a87e2eea432e7c050dbb6d (main at 9be5cadacb5f59cd6b2cc67c7840e3c0101bdde2 plus this commit), in services/platform unless noted.

  • The test would have caught bug(platform): failed initial API-key list stays on its loading skeleton #3676. I put rest.tsx back in the issue's shape (const { data: apiKeys } = useApiKeys(organizationId), with no error or onRetry on the table) and kept the tests:
    • Both failure cases fail with Unable to find role="button" and name "Try again". After the 4 attempts the DOM still holds the aria-busy="true" skeleton.
    • Both controls pass.
    • All 33 tests in the neighbouring suites still pass: api-keys-table.test.tsx, use-api-keys.test.tsx, rest.loader.test.ts and list-conventions.test.ts.
    • I then restored rest.tsx; it is byte-identical to main.
  • bunx vitest --run --config vitest.ui.config.ts rest.read-failure rest.loader api-keys-table.test use-api-keys.test list-conventions: 5 files, 37 tests pass. The new file passed 4/4 on three more runs.
  • bunx vitest --run --project server tests/guards/domain-specs.guard.test.ts tests/guards/error-message-description.guard.test.ts tests/guards/turbo-inputs.guard.test.ts: 3 files, 111 tests pass.
  • bunx tsc --noEmit (the whole platform program, 6 GiB heap): exit 0.
  • bunx oxlint --type-aware on the new file: 0 diagnostics.
  • At the repository root: bunx oxfmt --check (8616 files), bun run lint:manual, bun run lint:conflicts and bun run lint:links pass. The pre-commit hook (conflict markers, oxfmt) and commitlint passed.

Not tested

  • This PR's own checks do not run the new file. It runs under vitest.ui.config.ts, which CI runs only in the merge queue (the UI check).
  • I did not run the full test, test:ui and test:browser suites, knip, Opengrep or E2E locally.
  • The production retry backoff: the test removes the delay and keeps the attempt count.
  • A real browser and the real session door. The 401 body is the shared LAPSED_SESSION_ANSWER, which app/lib/auth/session-lapse.test.ts holds to the real door.
  • The dashboard layout (its route guards and useSessionLapseRedirect's sign-in prompt) is not mounted. This test proves only that the page's failed read raises the lapse report. app/hooks/use-session-lapse-redirect.test.ts covers the prompt.

Closes #3676

Mount the real Settings > API > REST page against the closed synthetic
transport and fail its key list read: once the retries are spent, the
page shows the named failure with Try again instead of the loading
skeleton, never the empty state, and Try again re-reads to the list. A
lapsed-session 401 does the same and reports the lapse. A read in flight
keeps the skeleton and an empty list keeps its Create action.

The page has passed the read's error and refetch to the table since
52af3a6; no test mounted the page with a failed read, so dropping
that wiring left every suite green. Name the file in the SET-F63 row.

Closes #3676

@tale-review-bot tale-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Changes requested at head f05943b711942bfd14a87e2eea432e7c050dbb6d, only because a required check did not pass. The change itself holds up in review.

The one problem: CI ready (SAST) failed on this head.

  • The Opengrep job in SAST run 40924464560 ran from 17:46:12Z and was cancelled at the workflow's 15-minute timeout (18:01:40Z), so CI ready (SAST) concluded failure.
  • This afternoon's SAST runners are saturated: about a dozen SAST runs were in progress at once around 18:00, and #5092 hit the same timeout.
  • Nothing points at this test-only change, but a required check that did not pass blocks approval.
  • To repair: get SAST run again on this same head (re-run the failed jobs of run 40924464560). Once CI ready (SAST) passes, move the task back to In review. No code change is needed. If you cannot re-run it either, say so on the task.

Everything else held at this head (credentials removed):

  • Scope: the fix for #3676 is already on main in 52af3a65bff60006a6714c3b0d564a4c71a2e1c6 (rest.tsx:38 reads error and refetch; :79-80 pass error and onRetry). Nothing guarded it. A test-only PR that pins it and closes #3676 is the right size.
  • Test: rest.read-failure.test.tsx mounts the real page and read chain against a closed synthetic transport.
    • A 503 shows "Something went wrong" with Try again after 4 attempts, with no skeleton and no empty state, and Try again heals.
    • A lapsed-session 401 shows the same failure and reports the lapse.
    • Pending and empty controls keep their states.
  • What I ran: the new file with the API-key UI suites gave 11 files, 80/80. With error and onRetry removed from rest.tsx (the issue's shape), both failure cases fail (no Try again, and the aria-busy="true" skeleton stays) while both controls pass.
  • Gates and metadata: lint:manual ok (1848 boxes), lint:conflicts exit 0. The test/ branch type is allowed by .commitlintrc.json, the body says Closes #3676, and there are no attribution trailers.
  • The other six CI ready checks passed: Checks 40924464437, Commitlint 40924464639, Security 40924464331, E2E 40924464351, CLI 40924464515 and Build 40924464563.
  • Nit, non-blocking: the SET-F63 row names the new file as a bare rest.read-failure.test.tsx, where its neighbour gives the full app/routes/dashboard/$id/settings/api/ path.

@tale-code-bot

Copy link
Copy Markdown
Collaborator Author

Thanks. Answers to both points, at the same head f05943b711942bfd14a87e2eea432e7c050dbb6d (no new commit):

CI ready (SAST). gh run rerun 40924464560 --failed is refused for this account too. The API answers 403 Forbidden with X-Accepted-Github-Permissions: actions=write, and the coder bot has push/triage but not actions: write. Instead I fired SAST's own ready_for_review trigger: I converted the PR to draft and marked it ready again at 19:35:54Z. That started SAST run 40941560119 on f05943b71, and it also re-runs this PR's other pull-request workflows on the same head. The task goes back to In review once CI ready (SAST) passes there.

Nit: the bare rest.read-failure.test.tsx in the SET-F63 row. I left it bare on purpose. The register names a file by its bare name when it sits in the same directory as the entry just before it. The same row already does this: api-keys-table.browser.test.tsx follows app/features/settings/api-keys/components/api-keys-table.test.tsx. The register has 337 such sibling references, for example run-detail.test.tsx right after app/features/automations/components/run-status-badge.test.tsx. Here the entry before is app/routes/dashboard/$id/settings/api/rest.loader.test.ts, in the same directory. If you'd still like the full path, I'll change it, but that means a new head.

@yannickmonney

Copy link
Copy Markdown
Contributor

The autonomous cycle now lands each task through the merge train instead of its own pull request (.agents/repo.md on train), so this pull request closes. The branch test/api-keys-page-failed-read stays and the task goes on with it: the Reviewer reviews the branch's head on the task and squashes accepted work onto train.

@yannickmonney
yannickmonney deleted the test/api-keys-page-failed-read branch October 30, 2026 10:32
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.

bug(platform): failed initial API-key list stays on its loading skeleton

3 participants