Make WordPress Core

Opened 7 months ago

Closed 6 months ago

Last modified 6 months ago

#61240 closed enhancement (fixed)

Add e2e test for maintenance mode and other edge cases

Reported by: swissspidy's profile swissspidy Owned by: swissspidy's profile swissspidy
Milestone: 6.6 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

In https://core.trac.wordpress.org/ticket/61182#comment:9 I just reported a fatal error that is hard to discover in regular development, as it only happens in maintenance mode.

Maintenance mode also loads translations using wp_load_translations_early(), which is also tricky to test and had some bugs in the past too.

Similar situations exist in the fatal error handler class, or in wpdb when there is a connection issue.

It should be possible to write e2e tests for such scenarios, for example by placing a .maintenance file in the root or by temporarily changing the database credentials and things like that.

Change History (5)

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


7 months ago
#1

  • Keywords has-patch has-unit-tests added; needs-patch removed

To-do:

  • [x] A test for the fatal error handler
  • [x] A test for maintenance mode
  • [ ] Recovery mode flow
    • Requires sending an email or another way of getting the recovery mode link

Trac ticket: https://core.trac.wordpress.org/ticket/61240

@swissspidy commented on PR #6624:


6 months ago
#2

The fatal error handler doesn't seem to be working with the local Docker environment. It works when using something like localwp.com though, so not sure what's going on.

@desrosj This is a long shot, but perhaps you have an idea since you're familiar with the Docker env?

#3 @swissspidy
6 months ago

  • Owner set to swissspidy
  • Resolution set to fixed
  • Status changed from assigned to closed

In 58430:

Build/Test Tools: add new end-to-end tests for edge cases such as maintenance mode.

Sometimes errors only occur in unusual code paths such as the maintenance mode or installation screens. Due to lack of tests for these scenarios in core, such errors are usually only noticed very late. This change adds new end-to-end (e2e) tests to prevent regressions in the following areas:

  • Maintenance mode (presence of a .maintenance file)
  • Fatal error handler (simulated with an mu-plugin that causes an error)
  • Installation screen (verifying full installation flow & that there are no database errors)

Thanks to these tests, an issue was already found and addressed in the default wp_die handler, as wp_robots_noindex_embeds and wp_robots_noindex_search used to cause PHP warnings due to $wp_query not existing.

In the future, these tests can be extended to also test scenarios like localized error pages via wp_load_translations_early().

Fixes #61240.

#5 @swissspidy
6 months ago

In 58431:

Build/Test Tools: install additional languages in end-to-end tests.

As a follow-up to [58430], this makes another locale available during the e2e tests, allowing testing of scenarios that require loading translations in the future.

See #61240.

Note: See TracTickets for help on using tickets.