Repository navigation
fix(projects): pin the schedule bar spec clock so clamping stays calendar-independent - #526
waterbro-8 wants to merge 1 commit into
Conversation
…ndar-independent The schedule window starts at the Monday of the current week (ProjectBoard.tsx:95), so the hard-coded fixtures in this spec leave the window as the calendar moves: 2026-09-28 for the partially invalid date task, 2026-10-05 for the inverted task, 2027-01-04 for the window-spanning task. Pin the clock inside the spec with the pattern already used in approval-queue.test.tsx and turn-progress-interaction.test.tsx, and restore real timers in a finally block so a failing assertion cannot leak fake time into the file. Closes #525
waterbro-8
left a comment
There was a problem hiding this comment.
复核结论(head 8a4b983):改动属实、无阻塞意见,但要合还缺第二位 reviewer 的 approve。
1. 根因链路我独立核了一遍,不是只看 PR 描述。 PR #523 的 Node 24 / ubuntu-latest(job 108753296529)日志:Tests 1 failed | 876 passed (877)、Test Files 1 failed | 70 passed (71),唯一失败点就是 renderer/test/project-board.test.tsx:605 → Unable to find an accessible element with the role "button" and name /^Partially invalid date task: /。整个 renderer 套件只有这一个用例红,其余 70 个文件全绿,与 #525 描述的日历锚定问题同源。
2. 本 PR head 的 CI 已绿。 run 36390868774:Node 24 / ubuntu-latest 108826151965(3m36s)、Node 24 / macos-14 108826151761(5m22s)双绿;Layout parity、两条 staging smoke、两条 installer、CodeQL、Dependency review、OpenSSF 全 pass。
3. 改动面: 单文件 apps/desktop/renderer/test/project-board.test.tsx,+60 / −51,生产代码零改动(ProjectBoard.tsx 未被触碰),所有断言字面值保持原样。
4. 固定时钟的写法认可。 toFake: ["Date"] 只伪造 Date,同文件其它用例依赖真实 timer 的 RTL waitFor 不受影响;try { … } finally { vi.useRealTimers(); } 保证断言失败后假时钟不外泄到后面的用例。与 approval-queue.test.tsx:381、turn-progress-interaction.test.tsx:68 的既有写法一致。
5. 同意不在组件里改。 inWindow 过滤是预期行为,放开它会给窗口外的任务画 bar。
两点留档:
- V3 变异测试(移除
ProjectBoard.tsx:743的 clamp 后仍失败)我没有在本机复跑,此处按 PR 描述记录;它是“固定时钟没有削弱断言”的唯一强证据,建议 reviewer 自行复现一次。 - V6 全量套件仍有
App.test.tsx/reports-center.test.tsx/budget-dashboard.test.tsx的 45 条 timeout,属已知本地负载类失败,与本改动无关——本 PR 合入后 main 的 Node 24 腿才谈得上稳定。
本 PR 由协同 waterbro-8 账号开出,作者本人无法自转 approve,仍需第二位 reviewer(HAHR / Bindy)点 approve 才能合。
|
Note for the record: with #523 merged, Suggested disposition: either close this PR as superseded, or — if you want the clock-pinning pattern retained as defense in depth — rebase it onto current |
PeterGuy326
left a comment
There was a problem hiding this comment.
Superseded by main: PR #523 already landed the calendar-independent fix for this same flake, using relative isoFromToday fixtures instead of a pinned clock, so the clamping math no longer depends on the wall-clock week window. Merging this would only re-introduce a second mechanism for the same problem.
Closing as superseded — no code change is lost. Thanks for the quick fix; if you spot the flake again, the isoFromToday contract in project-board.test.tsx is the place to extend.
Closes #525
Tracking record
b3704c4527d532202421733d1772e17433f2e628(currentmain, unchanged while this branch was staged).Summary
One renderer spec —
renderer/test/project-board.test.tsx, case "clamps schedule bar calculations for inverted dates, window-edge spans, and partially invalid dates" — fails on bothNode 24legs for any run whose local date is on or after 2026-09-28, and had two more staged expiry dates after that (2026-10-05,2027-01-04). It is not a content regression: the spec blob (fb329909e318b2c31fd256a1ec19f359285d59a4) and the component blob (c23c08f1c7339c5fc0cb62e54300454a833e8e36) are identical onmainand on every PR head that ran red.The schedule window starts at the Monday of the current week (
ProjectBoard.tsx:95→weekStart(localToday())), while the spec's fixtures are hard-coded dates. When the week rolled to2026-09-28, the partially-invalid-date fixture (dueDate: "2026-09-22") fell outside the 28-day window,inWindowbecame false (ProjectBoard.tsx:745-746), and the bar — the very element the spec queries by accessible name at:605— was never rendered (ProjectBoard.tsx:788).Fix: pin the clock inside that one spec, using the pattern the suite already uses for date-sensitive assertions (
vi.useFakeTimers()+vi.setSystemTime(), seeapproval-queue.test.tsx:381-382andturn-progress-interaction.test.tsx:68-69). Two deliberate details:toFake: ["Date"]— onlyDateis faked, so timers, promises and RTL'swaitForkeep working; the neighbouring tests in this file rely on real timers.try { … } finally { vi.useRealTimers(); }— a failing assertion must not leak fake time into the rest of the file.Pinned instant
2026-09-24T12:00:00.000ZputswindowStartat2026-09-21, which keeps all three fixtures in-window, so the two later expiry dates are covered too. Every literal assertion in the spec — including the label at:613— is untouched.Intentionally out of scope:
inWindowwould draw bars for tasks that are not in view.:342,:530) assert label text, which renders regardless ofinWindow, so they are window-independent today.Acceptance criteria
renderer/test/project-board.test.tsxis green when run on local date 2026-09-28windowStart=2026-09-21independent of the run date; all three fixtures verified in-window for that window (V4). Future-dated runs cannot be executed today — see Reviewer notesNode 24legs are green againmainitself goes green when this mergesValidation ledger
npm run test:renderer -- renderer/test/project-board.test.tsxbefore the fix, local date 2026-09-28:605Tests 1 failed | 19 passed (20),TestingLibraryElementError: Unable to find an accessible element with the role "button" and name /^Partially invalid date task: /Tests 20 passed (20)Math.max(0, …)clamp atProjectBoard.tsx:743, rerun V2expected '-2242.8571428571427%' to be '0%'; component then restored byte-exact and V2 re-confirmed greenwindowStart= 2026-09-21 and all three fixtures in-windowstart < windowStart + 28 && end >= windowStartdayNumber/weekStartformulasnpm run typecheck:renderertsc --noEmit -p apps/desktopnpm run test:renderer(full suite, 72 files)Tests 45 failed | 753 passed (798); every failure is a timeout (63 × 5000 ms, 2 × 10000 ms, 4 × 15000 ms) inApp.test.tsx(41),reports-center.test.tsx(3),budget-dashboard.test.tsx(1) — the known local-load class;project-board.test.tsxis green; the same suite on the same machine before this change was 48 failed / 5 filesNode 24 / ubuntu-latestandNode 24 / macos-14on this branchTests and coverage
renderer/test/project-board.test.tsx:561-620now pins the clock and restores real timers infinally; assertions unchanged.ProjectBoard.tsxis not modified.Change classification
Classified as CI: the shipped app is byte-identical; the sole effect is that the
Node 24legs stop failing on the calendar.Risk and rollback
it()and restored infinally.git revert) or delete the branch —mainreturns to its current (red-on-Node 24) state; no artifact or persisted data is involved.Breaking or security notes
None.
Author checklist
GOVERNANCE.md.→ Not checked, deliberately. fix(ci): project-board schedule bar spec is calendar-anchored and fails both Node 24 legs from 2026-09-28 #525 was filed by the author of this PR and is still
status: reportedwith no maintainer confirmation. It is filed as a bug report (S2 / E2) and this PR is the remediation; a maintainer decision on severity and on whether the pin-clock approach is preferred over dynamic fixtures is requested in Reviewer notes.→ base
b3704c45==mainat publish time; the changeset is exactly 1 file,+60 −51, verified by recursive tree diff (0 added,0 removed,1 modified).→ Applicable scope for a test-only change: the target spec (V2), the full renderer suite (V6) and
typecheck:renderer(V5). The rest ofnpm run check(build, scripts, server, desktop-main,security:check) was not run locally — this change touches one spec file and cannot affect those legs; they are covered by CI.→ Not applicable as written: the defect is the existing spec's calendar dependence, so the regression protection is delivered by making that spec deterministic (V1 red → V2 green, with V3 proving the assertions still bite). No new spec was added.
→ Nothing user-visible or documentational changed. CHANGELOG is reserved for user-facing entries in this repo; a test-only fix is deliberately not logged. Say the word and I'll add a
### Fixedline.→ The diff is 60 added / 51 deleted lines in one test file; no new dependencies, no artifacts, no data.
→ Every ledger row is a command with its output; V1/V2/V3/V6 were run on 2026-09-28 (UTC+8) on a tree whose only delta from
mainis unrelated to this change.Reviewer notes
vi.setSystemTime) vs. deriving fixture dates fromlocalToday(). I chose pinning because it keeps every literal assertion — including the due-date label at:613— and matches the two specs already using this pattern. Deriving dates would make the label assertion dynamic and enlarge the diff. Happy to switch if the maintainers prefer fixtures that track the real calendar.ProjectBoard.tsx:743) failing with-2242.857…% vs 0%is the evidence that it did.inWindowgating is intended: a task outside the visible 28-day window should not draw a bar.windowStartfixed at2026-09-21, all three fixtures satisfyinWindow— computed with the component's own formulas (V4).