Make WordPress Core

Opened 5 weeks ago

Last modified 4 weeks ago

#65772 new enhancement

Add an end-to-end test for scheduled post publishing (future to publish via WP-Cron)

Reported by: csmcneill Owned by:
Priority: normal Milestone: Future Release
Component: Build/Test Tools Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

No end-to-end test exercises the actual future-to-publish transition through WP-Cron — existing coverage stops at "the post is scheduled".

A spec covering the real transition is open as a PR: https://github.com/WordPress/wordpress-develop/pull/12668

It schedules a post by the server's own clock, waits out the scheduled time, then drives wp-cron.php explicitly and asserts the status flip; a second test covers the Scheduled view of the posts list. Comments in the spec document the cron-lock and loopback behaviors that make the explicit drive deterministic in containerized environments, including this repository's own Docker environment. Green across the full CI matrix.

Part of a series adding e2e coverage for classic admin surfaces — see #52895.

Change History (2)

This ticket was mentioned in PR #12668 on WordPress/wordpress-develop by @csmcneill.


4 weeks ago
#1

  • Keywords has-unit-tests added

Adds end-to-end coverage for scheduled post publishing: a true future-to-publish transition through WP-Cron, plus the Scheduled view of the posts list.

As far as I can tell, no e2e test currently exercises the actual cron transition — existing coverage stops at "the post is scheduled". The transition test schedules a post 60 seconds out by the server's own clock (read from an HTTP Date header, so host/container clock skew doesn't matter), lets the scheduled time pass, then drives wp-cron.php explicitly and asserts the status flip.

Two environment realities shaped the design and are documented in the spec:

  • The scheduled wait issues no requests to the site. An ordinary request that observes a due event calls spawn_cron(), which takes the doing_cron lock and fires a non-blocking loopback request — and in this repository's Docker environment (and any environment that can't loop back to itself), that spawned request never executes, so the lock only shuts out wp-cron.php for the next minute. A quiet wait means the lock is free the moment the event is due.
  • Driving wp-cron.php directly runs due events synchronously inside that request, making the transition deterministic instead of depending on loopback self-spawning.

Trac ticket: https://core.trac.wordpress.org/ticket/65772
Trac ticket: https://core.trac.wordpress.org/ticket/52895

## Verification

  • Passes in this repository's local Docker environment against trunk (4 consecutive solo runs plus 3 consecutive runs composed with another spec).
  • Also verified against WordPress 7.0.2 and 7.1-beta3 installs (wp-env) as part of a legacy-surface regression-testing effort for 7.1.

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude (Claude Code via Craft Agents)
Agent(s): Fable 5
Used for: Test authoring and cross-environment verification, with human review; reviewed and submitted by the author.

#2 @westonruter
4 weeks ago

  • Milestone Awaiting ReviewFuture Release
Note: See TracTickets for help on using tickets.