Skip to content

Conversation

@cmraible
Copy link
Collaborator

@cmraible cmraible commented Jan 23, 2026

Test only change that shouldn't impact any user facing behavior.

Summary

Fixed a timezone-related flaky test failure in the publishing browser tests.

The Problem

The scheduling tests in publishing.spec.js were only setting time: '00:00' without specifying a date. The assumption was that midnight today would always be in the past, triggering the auto-correction to "5 seconds in the future."

However, this fails when the UTC date differs from the local date:

  • For Americas (UTC-8 to UTC-5): Tests fail roughly 4 PM to midnight local time
    • Example: At 5 PM Pacific (UTC-8), UTC is already 1 AM the next day
    • If the scheduler uses the UTC date, "00:00" on that date is still in the future
    • No auto-correction happens → test fails expecting "in a few seconds"

The Fix

Explicitly set date: getTodayDateString() along with time: '00:00'. The helper uses DateTime.now() to get the current system date, ensuring that "00:00 today" is always in the past regardless of timezone differences between the test runner and the server.

Changes

  • Added getTodayDateString() helper function
  • Updated 4 test cases to explicitly pass today's date when scheduling posts

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

Adds a getTodayDateString() helper that returns today's date in YYYY-MM-DD format and updates e2e browser publishing tests to pass both date: getTodayDateString() and time: '00:00' when scheduling publishes instead of time-only scheduling. Inline comments were updated to note that using today's date with 00:00 produces a past datetime that the system auto-corrects into the near future. Multiple test flows were adjusted to accommodate the date+time scheduling change.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fixed timezone bug in browser tests' directly and clearly summarizes the main change in the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the timezone issue, the problem it caused, and the fix applied.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

@cmraible cmraible force-pushed the fix-browser-tests-timezone-bug branch from e871715 to 3c48ce9 Compare January 23, 2026 00:06
@cmraible cmraible marked this pull request as ready for review January 23, 2026 00:42
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@ghost/core/test/e2e-browser/admin/publishing.spec.js`:
- Around line 7-13: The getTodayDateString helper uses DateTime.now() which is
timezone-dependent; change it to use DateTime.utc() so the returned YYYY-MM-DD
is based on UTC. Update the getTodayDateString function (the arrow function
named getTodayDateString) to call DateTime.utc().toFormat('yyyy-MM-dd') instead
of DateTime.now().toFormat('yyyy-MM-dd') to ensure consistent scheduling across
test runners.

@cmraible cmraible force-pushed the fix-browser-tests-timezone-bug branch from 3c48ce9 to b976a40 Compare January 27, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants