Repository navigation
test(webui): appearance 跟随系统/覆盖/落盘 三条真浏览器证据 - #31
Merged
Merged
Conversation
The P-zone roadmap row for 跟随系统 dates from a 9-30 screenshot, and the only existing coverage was four unit assertions on resolveThemePreference's input mapping -- nothing ever switched the OS scheme once and watched the page follow. This adds a browser spec that does, three ways: - following: select 跟随系统, emulate dark then light, assert <html> tracks both directions (with a control leg proving the change event fires); - overriding: under 跟随系统 prove the flip moves the page, then pin 深色模式 and flip the OS to light -- the page must stay dark; - persisting: localStorage webui-theme holds the clicked preference string (system under a dark OS, not the resolved dark). All three pass against the current webui HEAD, so the row's evidence is now green; no product change was needed.
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.
Change
Roadmap P 区「跟随系统」一行是 9-30 的截图口径。结构性事实此前已有(
resolveThemePreference的四条单测映射、三个主题按钮在 DOM 里),但没有任何用例真的切一次系统主题、看界面跟不跟着变——这是「结构对 ≠ 能用」的又一个形状,本 PR 补的就是这块证据。新增
test/webui-browser/settings-theme.spec.mjs三条用例(经 harness 的test,带 /health 与 serverId 守卫;经用户菜单 → 设置 真实路径进 Appearance):emulateMedia切 dark →<html>有 dark 无 light;切回 light → 反之。套件全局 pin 在colorScheme: "light"(playwright.config.mjs:30),所以不 emulate 的用例永远是浅色,「默认浅色」不能当「跟随生效」的证据——这条用例就是这个坑的反面。matchMedia为 false,保证 change 事件已派发到监听器。localStorage.webui-theme存的是点击的偏好串——OS 为 dark 时点「跟随系统」存"system"而不是解析后的"dark"(存后者等于把今晚的 OS 状态快照进偏好,明早开机就不再跟随且无任何 UI 迹象);三档各验一次。全部断言走
expect.poll,无 sleep。选中态用行内aria-pressed合同验证点击落地。结果
三条全绿;全量浏览器套件 96 passed(此前 93);
pnpm verify20 门全绿;typecheck 含在 verify 内。无需改产品代码——按证据该行可以从 🟡 改 ✅(roadmap 层由 bot 执行)。一个与任务书认知相反的实证(重要)
任务边界里预期「关掉设置弹窗后系统切主题、界面不再跟」(
if (!open) return null导致没人动<html>)。实测不成立:UserMenu.tsx:918对<SettingsModal>是常挂载 +openprop 形态,return null只影响渲染输出、不卸载 hooks——matchMedia 监听与 class effect 在弹窗关闭后仍然活着。开发期用一次性探针实证过:关闭弹窗 → emulateMedia dark →<html>仍变为 dark(探针已删,未进套件——该行为依赖 UserMenu 的挂载形态这一实现细节,不是主题行该钉死的合同,但 roadmap 侧不必按「关弹窗即失联」的已知缺口降格该行)。Publication
release/public-source.json+1)。scripts/source-inventory.mjs --write已重跑。test/vitest-suites.json,与套件现状一致)。Validation
pnpm build:webuipnpm test:webui-browser:96 passed(含新增 3)pnpm verify:20 gates PASS on darwin(浏览器门在 darwin 上按平台策略跳过,已手动全量跑过)