fix(canvas/test): mockReset before rejection in ApprovalBanner POST error tests #465

Closed
core-uiux wants to merge 1 commits from fix/canvas-approvalbanner-mockreset into main

1 Commits

Author SHA1 Message Date
acacf6fdc6 fix(canvas/test): mockReset before rejection in ApprovalBanner POST error tests
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 13s
Harness Replays / detect-changes (pull_request) Successful in 14s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 14s
CI / Detect changes (pull_request) Successful in 45s
sop-tier-check / tier-check (pull_request) Successful in 14s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 46s
E2E API Smoke Test / detect-changes (pull_request) Successful in 53s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 48s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 53s
audit-force-merge / audit (pull_request) Has been skipped
Harness Replays / Harness Replays (pull_request) Successful in 5s
CI / Platform (Go) (pull_request) Successful in 9s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 5s
CI / Python Lint & Test (pull_request) Successful in 8s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 6s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 9s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 7s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 7m40s
CI / Canvas (Next.js) (pull_request) Failing after 9m26s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
Fixes cross-test mock pollution from ActivityTab.test.tsx which uses
vi.hoisted() to mock api.post. In the jsdom shared environment,
vi.spyOn(api, "post") in ApprovalBanner wraps that bare spy.
Calling mockRejectedValueOnce() queues the rejection AFTER
ActivityTab's mockResolvedValue({}) — reliable in isolation, order-
dependent in the full suite.

The fix: add a module-level mockPost reference, assign the spy to it
in beforeEach, and use mockPost.mockReset().mockRejectedValue() in the
two error-path tests. mockReset() atomically clears the spy
implementation before setting a permanent rejection, bypassing the
mock queue entirely.

Fixes: shows an error toast when POST fails
Fixes: keeps the card visible when the POST fails

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 11:40:50 +00:00