Skip to content

fix(test): build test dates in local time - #13430

Merged
tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/tz-dependent-tests
Sep 26, 2026
Merged

tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/tz-dependent-tests

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What changes

Three tests pass only when the machine's time zone agrees with UTC on the calendar day. CI runs in UTC, so they pass there; west of UTC (the Americas) or east of UTC+12 they fail. This builds their dates in local time. Test code only.

Mechanism

A Deadline or Scheduled value is a millisecond timestamp, and the code reads its day in the local zone (date-time-util/ms->journal-day goes through t/to-default-time-zone). The date picker writes local midnight (calendar-inner, .setHours d 0 0 0), so the app writes and reads in the same zone.

  • clearing-past-deadline-drops-journal-ref-from-rebuild (logseq.outliner.date-property-test) and clearing-past-deadline-removes-journal-linked-ref-test (frontend.worker.pipeline-test), added in fix: drop stale journal refs when clearing datetime values #13417, build the Deadline with date-time-util/journal-day->ms, which gives midnight UTC. West of UTC that instant is the evening before, so the journal ref goes to the previous day's page and the assertions that expect the past journal fail. They now use (.getTime (date-time-util/int->local-date day)), local midnight, as the picker does.
  • journal-tag-template-applied-on-repeating-task-reschedule-test (frontend.worker.pipeline-test) fixes now at (t/date-time 2026 9 20 12 0 0), 12:00 UTC. From UTC+12 eastward that is already the 21st locally, so the next occurrence 6 days later falls on the 27th and the test finds no page for the 26th. It now uses t/local-date-time, local noon, which is the 20th in every zone.

Tests

The 2 namespaces, run with TZ=Etc/GMT+12 and TZ=Pacific/Kiritimati (UTC-12 and UTC+14):

UTC-12 UTC+14
master 6 failures (the 2 deadline tests) 4 failures (the reschedule test)
this branch 0 0

The branch also passes both namespaces in America/Los_Angeles and UTC. The whole unit suite in both zones on this branch: 2476 tests, 12407 assertions, 0 failures, 0 errors in each.

Between them UTC-12 and UTC+14 are on a different calendar day from UTC at every hour, so running the suite once in each catches a test of this kind whenever it runs.

Allow edits from maintainers.


Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Three tests built a date in UTC and the code under test read it back
in the local zone, so they passed only where the two agree on the
calendar day, as in CI (UTC):

- the 2 past-deadline tests set the Deadline to UTC midnight, which
  west of UTC is the previous local day, so the journal ref went to
  the wrong page. The date picker stores local midnight; the tests
  now do the same with int->local-date.
- the reschedule journal-template test fixed now at 12:00 UTC, which
  east of UTC+12 is already the next local day, so the next
  occurrence landed 1 day after the expected page. It now uses
  local noon.

Reproduce with TZ=Etc/GMT+12 and TZ=Pacific/Kiritimati.
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