Fixed flaky scheduled publishing tests near midnight#26794
Conversation
The tests set time to 00:00 expecting auto-correction to 5 seconds from now, but near midnight the default schedule date (now + 10 min) rolls to tomorrow, making 00:00 tomorrow still in the future. Fixed by explicitly passing today's date alongside the time.
WalkthroughAdded a new 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan for PR comments
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. Comment |
🤖 Velo CI Failure AnalysisClassification: 🟠 SOFT FAIL
|
publishPost waits for the schedule summary text to change after setting the date. Using today's date was a no-op (default schedule is already today), causing the assertion to time out.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/test/e2e-browser/admin/publishing.spec.js (1)
7-11: Well-designed fix for the midnight flakiness issue.The approach is sound: using yesterday's date ensures the composed datetime is always in the past, regardless of when tests run. The comment clearly documents both the "what" and "why", including the subtle reason for using yesterday instead of today (avoiding a no-op when
publishPostwaits for the schedule summary to change).Minor readability suggestion: the one-liner is long. Consider breaking it for easier scanning.
🔧 Optional: Multi-line formatting
-const scheduleAsap = (page, options = {}) => publishPost(page, {date: DateTime.now().minus({days: 1}).toFormat('yyyy-MM-dd'), time: '00:00', ...options}); +const scheduleAsap = (page, options = {}) => publishPost(page, { + date: DateTime.now().minus({days: 1}).toFormat('yyyy-MM-dd'), + time: '00:00', + ...options +});🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ghost/core/test/e2e-browser/admin/publishing.spec.js` around lines 7 - 11, The one-line scheduleAsap helper is correct but hard to scan; refactor the arrow function into multiple lines for readability by splitting the date construction and options merge: create a local const scheduledDate = DateTime.now().minus({days: 1}).toFormat('yyyy-MM-dd') and then return publishPost(page, { date: scheduledDate, time: '00:00', ...options }); (update the scheduleAsap declaration accordingly) so the intent in scheduleAsap and the use of publishPost are clearer.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ghost/core/test/e2e-browser/admin/publishing.spec.js`:
- Around line 7-11: The one-line scheduleAsap helper is correct but hard to
scan; refactor the arrow function into multiple lines for readability by
splitting the date construction and options merge: create a local const
scheduledDate = DateTime.now().minus({days: 1}).toFormat('yyyy-MM-dd') and then
return publishPost(page, { date: scheduledDate, time: '00:00', ...options });
(update the scheduleAsap declaration accordingly) so the intent in scheduleAsap
and the use of publishPost are clearer.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4733228a-5f9b-49ed-95f1-c3150137efcd
📒 Files selected for processing (1)
ghost/core/test/e2e-browser/admin/publishing.spec.js
Summary
publishing.spec.jsthat fail daily near midnight UTC00:00— a time that is usually in the past — and the UI autocorrects it to "a few seconds from now." But when running within ~10 minutes of midnight, the default scheduled date (now + 10 min) rolls to tomorrow — making00:00 tomorrowstill in the future, so no auto-correction occurs.time: '00:00', ensuring the resulting datetime is always in the past regardless of when the tests run