Skip to content

test(dashboard): load credential test modules before timed tests - #4364

Open
ScriptedAlchemy wants to merge 1 commit into
masterfrom
test/4331-credential-transport-determinism
Open

ScriptedAlchemy wants to merge 1 commit into
masterfrom
test/4331-credential-transport-determinism

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Part of #4331; #4334 covers the event-source test.

Why

The credential tests call vi.resetModules() and then import credential.ts and responseBody.ts inside the test body. The first import of a module fetches it from the Vite server in the vitest main process. On a loaded host, that fetch waits for the main process and can exceed the 5 s test timeout. The test has no timers, and the request itself takes about 1 ms.

What changed

  • credential.dom.test.ts imports both modules at the top of the file. Vitest loads them during collection, which has no per-test timeout. The re-import after vi.resetModules() then evaluates cached code and makes no server request.

Scope

  • Changes only the credential test file. The tests keep vi.resetModules() and every assertion.
  • Does not touch the event-source test, dashboard/BUILD.bazel, or MODULE.bazel. test(dashboard): bound Bazel workers and isolate auth streams #4334 owns those.
  • No production code changes. The slow step was test module loading, not a production wait.

Blast Radius

Test-only. The two new imports have no side effects, because neither module runs code at import time.

Verification

  • A local Vite plugin, not committed, kept the vitest main process busy for 200 ms of every 250 ms. Before the change, the transport case took between 1593 and 4596 ms. After it, the case took 1 to 2 ms. The first case dropped from between 1794 and 4208 ms to 11 ms. Each side ran at least 3 times.
  • Mutation check: replace dashboardFetch with fetch in fetchJsonResponse. The transport case fails in 4 ms with expected null to be 'Basic ...'.
  • Full dashboard pnpm test on the committed head passed twice (221 files, 2137 tests). The 1-minute load average went from 15.8 to 41.9 in the first run and from 38.9 to 73.4 in the second, on 12 cores. The transport case took 14 ms.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 10898af

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy
ScriptedAlchemy marked this pull request as ready for review October 19, 2026 07:02

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

The credential tests reset modules and then imported credential.ts and
responseBody.ts inside the test body. The first import of each module
waits on the Vite server in the main process. On a loaded host that wait
exceeded the 5 s test timeout. Static imports now load both modules
during collection, so the re-import after vi.resetModules() uses cached
code.

Part of #4331.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy force-pushed the test/4331-credential-transport-determinism branch from 21e0b49 to 10898af Compare October 20, 2026 09:43

This branch has not been deployed

No deployments
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