Repository navigation
Commit 87c0407
test(auth): AuthProvider 401 re-check case waits on the re-check read with an explicit chain budget (#32433)
Fixes #32426
Refs #32420
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:AuthProvider 的「401 后重查会话」测试用例,改为先等重查请求真正发出,再等身份被清掉,等待预算由默认 1000
ms 改为显式的 10 s。
- 为什么改:调度全量跑里该用例在 Test UI 分片负载下耗时 1022 ms 才失败,原因是等待预算过紧,不是产品时序缺陷。
- 风险与回滚:仅改测试,断言一字未动;回滚即还原该文件。
- 先看:`ui/packages/auth/src/__tests__/AuthProvider.test.tsx` 中 `CHAIN_MS`
常量与「the server answers "no session"」用例。
- 两分钟验证:在 `ui/` 下跑 `pnpm exec vitest run
packages/auth/src/__tests__/AuthProvider.test.tsx`,预期 20 个用例全绿。
- 需要你做的:无,席位落地。
## What changes
`ui/packages/auth/src/__tests__/AuthProvider.test.tsx`, test-only
(`skip-changeset`):
- The "the server answers no session" case now first waits on the event
it asserts on (the re-check `get-session` read reaching the fetch seam),
then waits for identity to clear. Both assertions are unchanged; the
trailing read-count `expect` is kept.
- The `waitFor` calls in the 401 describe (`signedIn`, the three
re-check cases) carry an explicit `CHAIN_MS = 10_000` budget with the
reasoning in a comment. A passing run returns as soon as the DOM says
so; the budget bounds only a failure's wait.
- No skip, retry wrapper or quarantine; no assertion weakened.
## Tests
Premise check (not a product race): in `AuthProvider.tsx` the 401
subscription is registered by an effect keyed on `holdsSession`, and
`loadSession` clears `sessionLoadInFlight` in the same continuation that
sets the user, so by the time `signedIn()` sees "Alice" the subscription
is live and the in-flight flag is down. The chain 401 ->
`sessionEndEvents` -> `client.getSession()` -> `setUser(null)` has no
timer or debounce; the red was only the 1000 ms default budget.
- `pnpm exec vitest run
packages/auth/src/__tests__/AuthProvider.test.tsx` (from `ui/`, under
`os-verify-lock.sh`): 20/20 passed.
- Repeat x50 under shard-like concurrency: 10 batches of 5 simultaneous
`vitest run --maxWorkers=2` processes of this file under the lock:
pass=50 fail=0 (`Tests 20 passed (20)` per run).
- `pnpm --filter @object-ui/auth type-check`: exit 0.
- Ablation: not run (test-only change; no product behaviour changed).
## Acceptance notes
Landing is the expected file; the producer (`AuthProvider.tsx`) needed
no change.
## Verification
Local gates: CI-owned families (Test UI shards, lint) are read from the
PR check-runs; the `--commands` derivation for this diff lists only
checker-health self-tests, none a PR verdict.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_012MmDsRT6hvZsQH9dTzn4CA
Co-authored-by: Claude <noreply@anthropic.com>1 parent 0dc84b0 commit 87c0407
1 file changed
Lines changed: 25 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
442 | 451 | | |
443 | 452 | | |
444 | 453 | | |
| |||
462 | 471 | | |
463 | 472 | | |
464 | 473 | | |
465 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
466 | 477 | | |
467 | 478 | | |
468 | 479 | | |
| |||
489 | 500 | | |
490 | 501 | | |
491 | 502 | | |
492 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
493 | 510 | | |
494 | 511 | | |
495 | 512 | | |
| |||
500 | 517 | | |
501 | 518 | | |
502 | 519 | | |
503 | | - | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
504 | 523 | | |
505 | 524 | | |
506 | 525 | | |
| |||
514 | 533 | | |
515 | 534 | | |
516 | 535 | | |
517 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
518 | 539 | | |
519 | 540 | | |
520 | 541 | | |
| |||
0 commit comments