test(timeline): add regression tests for cursor-anchored zoom (#847)#866
test(timeline): add regression tests for cursor-anchored zoom (#847)#866TimeToBuildBob wants to merge 2 commits into
Conversation
…tyWatch#847) PR ActivityWatch#860 fixed timeline zoom drifting from the cursor position but did not include automated tests. These eight unit tests guard against regressions: - preferZoom: true is present in VisTimeline's vis-timeline options - onHorizontalWheel returns early when timeline is uninitialised - onHorizontalWheel returns early when vertical scroll dominates (deltaY >= deltaX) - onHorizontalWheel pans the window correctly when deltaX > deltaY - preventDefault and stopImmediatePropagation are called on a handled event - DOM_DELTA_LINE and DOM_DELTA_PAGE scaling factors (40 px/line, 800 px/page) Tests call component methods directly via VisTimeline.methods without mounting the full vis-timeline widget (which requires a real browser layout context).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #866 +/- ##
==========================================
+ Coverage 35.50% 35.59% +0.09%
==========================================
Files 36 36
Lines 2152 2152
Branches 417 398 -19
==========================================
+ Hits 764 766 +2
- Misses 1309 1365 +56
+ Partials 79 21 -58 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryAdds 8 regression tests for the cursor-anchored zoom fix (PR #860 / issue #847), covering the
Confidence Score: 5/5Test-only change with no production code modified; the new tests correctly model the existing implementation and run in the established jsdom project. All changes are in a new test file. The test math was verified against the actual onHorizontalWheel implementation — window offsets, delta-mode scale factors, and early-exit conditions all match. The vis-timeline mock is minimal and correct. No production paths are affected. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[wheel event fired] --> B{this.timeline null?}
B -- yes --> Z[return early]
B -- no --> C{abs deltaY >= abs deltaX?}
C -- yes --> Z
C -- no --> D{deltaMode?}
D -- DOM_DELTA_LINE --> E[deltaX x= 40]
D -- DOM_DELTA_PAGE --> F[deltaX x= 800]
D -- DOM_DELTA_PIXEL --> G[no scaling]
E --> H[diff = deltaX/120 * windowMs/20]
F --> H
G --> H
H --> I[setWindow start+diff end+diff]
I --> J[preventDefault + stopImmediatePropagation]
Reviews (2): Last reviewed commit: "test(timeline): address Greptile review ..." | Re-trigger Greptile |
|
@greptileai review |
|
CI is green and the PR is mergeable. I tried to squash-merge it from the monitoring lane, but the |
|
Bumping — this has been idle 5 days. CI is green, ready for review/merge. |
Summary
PR #860 fixed timeline zoom drifting away from the cursor position (issue #847) but included no automated tests. This PR adds 8 unit tests to guard against that regression being reintroduced.
What the tests cover
preferZoom: trueis present in the vis-timeline options (prevents the pan-after-zoom drift)onHorizontalWheelreturns early whenthis.timelineis not yet initialisedonHorizontalWheelreturns early when vertical scroll dominates (deltaY >= deltaX)onHorizontalWheelpans the window by the correct amount when horizontal scroll dominatespreventDefaultandstopImmediatePropagationare called on every handled eventDOM_DELTA_LINEmode scalesdeltaXby 40 px/lineDOM_DELTA_PAGEmode scalesdeltaXby 800 px/pageApproach
The tests call component methods directly on a mock
vmobject (VisTimeline.methods.onHorizontalWheel.call(vm, event)) and stubvis-timeline/esnextso they run in jsdom without a real browser layout or resize-observer stack. All 8 tests pass (npm test -- --testPathPattern VisTimeline).Test plan
npm run test:unit -- --testPathPattern VisTimeline— all 8 tests passnpm test) remains green