-
fix(test): await save PUT before reload in egress-policy UI test (#5491)
发布于
2026-08-08 13:13:27 +00:00 | 263 次提交 在此版本后已推送到 mainSection 7 toggles both require-local checkboxes then reloads the page.
The embedding toggle is clicked second, only ~500ms before the reload,
while the LLM toggle has ~1000ms. The change handler fires an async
fetch (PUT /settings/api/); a fixed sleep raced page.reload(),
which aborts in-flight requests. Under CI DB-write latency the
embedding save lost that race and never persisted (emb-persists-reload
flaked: reloaded=false) while the LLM save finished in time.The product code is fully symmetric for both checkboxes (template,
context processor, JS handler, API endpoint, defaults) and SettingsManager
commits before the PUT response returns — so awaiting the response is a
valid persistence barrier. This is a test-reliability fix, not a product
bug (verified: strict scope does not touch these checkboxes; no page-load
hook rewrites embeddings.require_local).Changes:
- Add waitForSettingPut() helper built on page.waitForResponse: matches
the PUT by method + exact pathname and rejects non-2xx responses, so a
rejected save fails loudly instead of producing a confusing
'reloaded=false' after reload. - Section 7: replace fixed sleeps after each toggle click with awaiting
the save PUT; reload can no longer abort an in-flight save. - Section 7 cleanup: restore based on the reloaded (persisted) value vs
initial, so a rejected save doesn't get flipped away from baseline. - Section 13: apply the same waiter to the require-local-llm click
(identical save-then-reload race) for consistency.
selectScope's fixed sleep (policy.egress_scope save) is intentionally
left as-is: it spans 9 sections, uses a separate save-generation queue,
and is not the failing path.下载附件
- Add waitForSettingPut() helper built on page.waitForResponse: matches