test: wait for web form session restore before asserting - #62
Merged
Merged
Conversation
WebFormPage「跨页返回恢复未完成会话」用例在 CI 上偶发失败 (#58 的 Frontend 作业): TestingLibraryElementError: Unable to find an accessible element with the role "button" and name /结束本次填写/ 根因是测试自身的时序竞态,而非 router 7.18.4 的行为变化: - 「结束本次填写」按钮的渲染门控是 `running && (sessionActive || live?.running)` (WebFormPage.tsx),除了 sessionStorage 的会话恢复外,还依赖 getWebFormBrowserStatus 轮询返回的 running —— 它与「填充到页面」按钮 不在同一次状态提交里。 - 原断言在 waitFor「填充到页面」出现后**同步** getByRole「结束本次填写」, 高负载下后者尚未提交即抛错。 - 佐证:router 7.18.3/7.18.4 changelog 无会话恢复相关变更 (7.18.4 仅 RSC redirect 转义与 #15485 避免 startViewTransition 的时序 变化);本地 7.18.4 下单文件 15 连跑 + 全量套件均绿,失败只在 CI 负载下偶发,与 #60 的 useWatch 竞态同类。 修复:两处同步断言改为 findByRole / findByDisplayValue 等待落地, 断言内容(role / name / 值)不变,无放松。 验证:vitest 801/801(123 文件);eslint 0 error / 11 warning(基线); tsc --noEmit、prettier --check 通过。
magicapple123
pushed a commit
that referenced
this pull request
Oct 2, 2026
Patch bump. This PR's Frontend check is red due to the WebFormPage session-restore race that #62 already fixed on main (the PR branch predates that fix; dependabot rebase did not land in time). The combined state (router 7.18.4 + test fix) was validated locally with 15 consecutive green full-suite runs before #62 merged; main CI on this merge is the authoritative gate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
#58(react-router-dom 7.18.2 → 7.18.4)的唯一失败作业 Frontend (Node 20) 死在:
判定:测试自身的时序竞态(非 7.18.4 行为变化)
1. 渲染门控证据:「结束本次填写」的渲染条件是
running && (sessionActive || live?.running)(WebFormPage.tsx)。除 sessionStorage 会话恢复外,它还依赖getWebFormBrowserStatus轮询返回的running—— 与「填充到页面」按钮不在同一次状态提交。原测试在waitFor「填充到页面」出现后同步getByRole断言「结束本次填写」,CI 高负载下后者尚未提交即抛错。2. router 变更证据:7.18.3(性能/校验)与 7.18.4(RSC redirect 转义 + #15485 避免在初始 hydration /
router.revalidate()时调用document.startViewTransition)均无会话恢复相关行为变更;7.18.4 的 #15485 是纯粹的时序变化,恰好说明它只会移动竞态窗口,而非破坏功能。3. 复现证据:7.18.4 下单用例文件 15 连跑全绿;7.18.4 全量套件(801 用例)本地全绿;失败仅在 CI 负载下偶发 —— 与 #60 的 useWatch 竞态同类。
修复
两处同步断言改为
findByRole/findByDisplayValue等待落地(等正确值渲染后再断言,断言本身零放松),并注明原因。验证