Skip to content

test(models): pin the off-peak day to the vendor clock, not UTC - #3776

Merged
steebchen merged 2 commits into
theopenco:mainfrom
xyzs996:peak-day-vendor-clock-tests
Aug 23, 2026
Merged

steebchen merged 2 commits into
theopenco:mainfrom
xyzs996:peak-day-vendor-clock-tests

Conversation

@xyzs996

@xyzs996 xyzs996 commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes the first half of #3775.

resolveTimeBasedPricing applies utcOffsetMinutes before getUTCDay(), which is right — but no test in helpers.spec.ts can tell that apart from dropping the offset entirely. Set utcOffsetMilliseconds to 0 and the whole file still passes.

The reason is that both peak windows ([1,4], [6,10]) sit before 16:00Z, and a UTC date and a Beijing date only disagree from 16:00Z onward. With DeepSeek's real windows the two calendars price all 168 hours identically, so no instant taken from them can discriminate. The existing weekend cases are both at 02:00Z, which is the same weekday on either clock.

This adds four cases on a mapping whose window reaches past 16:00Z, which is the only shape that separates them:

instant UTC Beijing expected
2026-08-28T15:00:00Z Fri Fri 23:00 peak
2026-08-28T16:00:00Z Fri Sat 00:00 off-peak
2026-08-30T15:00:00Z Sun Sun 23:00 off-peak
2026-08-30T16:00:00Z Sun Mon 00:00 peak

Test-only; no behaviour change. Dropping the offset in the implementation reddens exactly rows 2 and 4 and leaves the two controls green.

One correction to #3775 while I'm here: the four instants I listed there were all off-peak by the hour, so they return off-peak either way and do not in fact discriminate. The synthetic late window used here is what does. I'll fix that comment on the issue.

The second half of #3775 — no effective-from on offPeakDays, so a pre-2026-08-23 weekend timestamp gets today's discount — is untouched here.

Summary by CodeRabbit

  • Tests
    • Added regression coverage for time-based pricing across timezone boundaries.
    • Verified weekday and weekend pricing behavior in UTC and Beijing time zones.

Every existing case in helpers.spec.ts passes with utcOffsetMilliseconds set
to 0. Both peak windows sit before 16:00Z, and a UTC date and a Beijing date
only disagree from 16:00Z onward, so with DeepSeek's real windows the two
calendars price all 168 hours identically.

The four new cases use a window that reaches past 16:00Z -- the only shape
that separates them. Dropping the offset reddens exactly the two instants
that straddle a Beijing midnight and leaves the two controls green.
@coderabbitai

coderabbitai Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c032440f-971d-4ed9-8bfb-f3f0361785a7

📥 Commits

Reviewing files that changed from the base of the PR and between 6387727 and ceb2d49.

📒 Files selected for processing (1)
  • packages/models/src/helpers.spec.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

Added regression tests for resolveTimeBasedPricing. The tests verify weekday and weekend evaluation across UTC and Beijing date boundaries.

Changes

Timezone pricing regression coverage

Layer / File(s) Summary
Timezone boundary test coverage
packages/models/src/helpers.spec.ts
Added a late-hour pricing window and parameterized tests for vendor-timezone date evaluation across UTC and Beijing calendar boundaries.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ceb2d

This PR adds localized regression coverage without changing production behavior; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: steebchen, vicovaro

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the test coverage for vendor-clock off-peak day calculations instead of UTC boundaries.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@steebchen
steebchen enabled auto-merge (squash) August 23, 2026 18:53
@steebchen
steebchen merged commit 5663935 into theopenco:main Aug 23, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants