Skip to content

test: update useToolTest tests to match simplified async tracking hook - #300

Open
wch-08 wants to merge 1 commit into
OpenBMB:mainfrom
wch-08:main
Open

wch-08 wants to merge 1 commit into
OpenBMB:mainfrom
wch-08:main

Conversation

@wch-08

@wch-08 wch-08 commented Oct 28, 2026

Copy link
Copy Markdown

Problem

Commit 34502dd (OSS public release) rewrote useToolTest.ts (143 → 90 lines): it dropped sessionStorage idempotency, crypto.randomUUID fallback and the retryStatus API, and the ToolsPage caller was updated in the same commit. However, the test suite was left behind — it still mocked postWithSignal/getWithSignal and expected the old submit(obj)/retryStatus() contract, which made all 7 tests in useToolTest.test.tsx fail (api.post is not a function).

The broken tests were not caught by CI because the GitHub Actions workflow only runs the Python test suite, not the frontend vitest suite.

Fix

Rewrite the tests against the current hook contract:

  • Mock api.post(path, args) / api.get(url)
  • Cover submit(path, args) signature and busy/status/result/queryError state machine
  • Verify polling via fake timers, no double-submission on rapid clicks and no re-submission after a failed status query

Verification

  • npx vitest run: 59 files / 294 tests all pass (previously 7 failed)
  • npx tsc --noEmit: passes

Note

This is a test-only change (no runtime behavior affected).

The hook was rewritten in 34502dd (OSS public release) to drop
sessionStorage idempotency, crypto.randomUUID fallback and the
retryStatus API, and the ToolsPage caller was updated in the same
commit. The test suite was left behind, still mocking postWithSignal /
getWithSignal and expecting the old submit({})/retryStatus() contract,
which made all 7 tests in this file fail.

Rewrite the tests against the current contract: api.post(path, args) /
api.get(url), submit(path, args), busy/status/result/queryError states,
polling via timers, no double-submission on rapid clicks and no
re-submission after a failed status query.

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