Skip to content

Worker tests: two date tests fail when a run crosses midnight UTC (D417, D124) #1342

Description

@guillaumelauzier

S1: Task for slot S11, found while reviewing #1329. Test files only: no decision, no migration.

What is true on main

  • The failure. PR D611: colleague seat invites reach the colleague #1329's test:drift ran from 23:58 to 00:02 UTC and failed two Worker tests that have nothing to do with the PR. A local run of the same merge passes.
  • The cause. cloudflare-worker/test/entity_obligations_d417.test.ts fixes const TODAY = new Date().toISOString().slice(0, 10); once, when the file loads (line 46). The route computes days_left from the clock on every request.
    • So any test that runs after midnight, in a file loaded before it, is off by one day.
    • The two failures were days_left 1 for 2 and 39 for 40 (line 367), and 19 for 20 (line 388).
  • One more file. expiry_gate_datetime_d124.test.ts has the same exposure, in one test.
  • How it was found. The reviewer shifted the clock across a fake midnight for each of the 79 Worker test files that do date arithmetic. Only these two files are sensitive.

The work

  1. D417's test works out "today" from the same clock the route reads, at each assertion: compute it inside each test, or inject a clock. It must stop being a module constant.
  2. D124's test: the same.
  3. No route changes.

Files this task owns

  • cloudflare-worker/test/entity_obligations_d417.test.ts
  • cloudflare-worker/test/expiry_gate_datetime_d124.test.ts

Done when

  • Both files pass with the clock moved across midnight between their tests. Show how you checked, for example with a clock shim run at 23:59:59 UTC.
  • Every assertion they had still fails when the behaviour it pins is broken. Mutation-check one per file both ways.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    slot:S10Work queue of slot S10state:reviewDraft PR open; CI and review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions