You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(scheduled-orders): stabilize future wall-clock test helper across DST transitions - #1420
Stabilize the futureWallClockInZone test helper in tests/issue-360-scheduled-orders.test.ts and tests/multi-counter-ordering.test.ts.
Root Cause
During daylight saving time fall-back transitions (such as November 1, 2026 in North America / America/New_York), clocks fall back 1 hour from 2:00 AM EDT to 1:00 AM EST, causing all wall-clock times between 01:00 and 01:59 to occur twice. FloCafe's production scheduled order validation in parseScheduledForInput (shared/scheduled-time.ts) correctly catches this and rejects ambiguous wall clocks with HTTP 400 (DST_AMBIGUOUS_TIME).
When tests running near this boundary calculated Date.now() + offsetMinutes * 60 * 1000 (e.g. +120m or +180m), the formatted wall clock landed in this ambiguous hour and returned HTTP 400 instead of 201 during order creation tests (such as pagination).
Fix
Update futureWallClockInZone in both test suites to verify that the generated wall-clock string is valid and unambiguous using parseScheduledForInput. If the calculated wall-clock falls into a DST transition window, it cleanly advances in 24-hour steps to find the corresponding valid, unambiguous time on a non-transition calendar date, strictly preserving relative ordering and monotonicity.
Verification
npm run test:scheduled-orders (364/364 passed)
npm run test:multi-counter-ordering (271/271 passed)
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
Stabilize scheduled-order test times across DST transitions
🧪 Tests🐞 Bug fix🕐 10-20 Minutes
AI Description
• Validate generated test times against the production scheduled-time parser to avoid DST-related
order failures.
• Try later days when a generated wall clock is ambiguous or otherwise invalid.
• Reported verification: both test suites, lint, and build pass.
Diagram
graph TD
A["Test suites"] --> B["Future instant"] --> C["Local wall clock"] --> D{"Parser accepts?"}
D -->|yes| E["Schedule order"]
D -->|no| F["Advance one day"] --> C
Loading
High-Level Assessment
Using the production parser is the right choice: it keeps test inputs aligned with order validation without changing production DST rules. A separate date-validation implementation would risk diverging from that behavior.
Files changed (2) +45 / -28
Tests (2) +45 / -28
issue-360-scheduled-orders.test.tsValidate future scheduled-order test times+22/-14
Validate future scheduled-order test times
• The wall-clock helper now checks each generated time with parseScheduledForInput. It tries later days when validation fails and throws if none of seven candidates is accepted.
multi-counter-ordering.test.tsAvoid invalid scheduled times in multi-counter tests+23/-14
Avoid invalid scheduled times in multi-counter tests
• Imports parseScheduledForInput and applies the same bounded retry to the multi-counter suite’s wall-clock helper, preventing DST-ambiguous inputs from breaking order-creation assertions.
1. Fall-back sweeps release an extra order✓ Resolved
Description
futureWallClockInZone moves an ambiguous candidate a full 24 hours forward, while the
scheduled-orders test assumes its 120-minute order becomes due before a separately created
180-minute order. At 00:30 in New York on fall-back day, those orders land at 01:30 the next day and
02:30 the same day respectively, so the test's sweep releases both and fails its single-order stock
and print assertions.
ⓘ Recommendations generated based on similar findings in past PRs
Evidence
The parser rejects repeated wall clocks, so the new 24-hour retry moves the 120-minute order to the
following day. The test creates a separate 180-minute order, then sweeps at five seconds after the
first order's stored instant; the sweeper selects every scheduled order due by that instant. Its
subsequent stock and print assertions expect only the first order to have been released.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The 24-hour retry can schedule the first test order after the second, causing the simulated due sweep to release both orders and fail assertions during fall-back.
## Fix Focus Areas
- tests/issue-360-scheduled-orders.test.ts[133-155]
- tests/multi-counter-ordering.test.ts[164-186]
## Recommended Fix
When a candidate is ambiguous, advance to a nearby unambiguous future instant rather than jumping a whole day. Keep the two helpers consistent and verify the scheduled-orders sweep case with a fixed clock during the fall-back transition.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
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
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.
Summary
Stabilize the
futureWallClockInZonetest helper intests/issue-360-scheduled-orders.test.tsandtests/multi-counter-ordering.test.ts.Root Cause
During daylight saving time fall-back transitions (such as November 1, 2026 in North America /
America/New_York), clocks fall back 1 hour from 2:00 AM EDT to 1:00 AM EST, causing all wall-clock times between 01:00 and 01:59 to occur twice. FloCafe's production scheduled order validation inparseScheduledForInput(shared/scheduled-time.ts) correctly catches this and rejects ambiguous wall clocks with HTTP 400 (DST_AMBIGUOUS_TIME).When tests running near this boundary calculated
Date.now() + offsetMinutes * 60 * 1000(e.g. +120m or +180m), the formatted wall clock landed in this ambiguous hour and returned HTTP 400 instead of 201 during order creation tests (such as pagination).Fix
Update
futureWallClockInZonein both test suites to verify that the generated wall-clock string is valid and unambiguous usingparseScheduledForInput. If the calculated wall-clock falls into a DST transition window, it cleanly advances in 24-hour steps to find the corresponding valid, unambiguous time on a non-transition calendar date, strictly preserving relative ordering and monotonicity.Verification
npm run test:scheduled-orders(364/364 passed)npm run test:multi-counter-ordering(271/271 passed)npm run lint(0 errors)npm run build(success)