WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#40734 closed defect (bug) (fixed)

REST API: Tests: Prohibit errors when generating wp-api.js fixtures

Reported by: jnylen0 Owned by: jnylen0
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: rest-api Cc:
PR Number:

Description

In #39264 we added tests for wp-api.js to core, including a wp-api-generated.js fixture file that is automatically generated from API requests during test suite runs.

While reviewing #40450 I found that some of these requests are erroring, so we are storing error responses in the fixture data. For example:

I fixed this by requiring a 200 status code for these requests (they are all GET requests) and updating everything to send the right kind of data. I also needed to update the $fixture_replacements array which replaces dynamic data with static values - instructions for doing so are at comment:29:ticket:39264.

Note, the patch attached to this ticket needs to be applied after #40450.

Attachments (1)

40734.diff (13.4 KB) - added by jnylen0 3 years ago.

Download all attachments as: .zip

Change History (3)

@jnylen0
3 years ago

#1 @jnylen0
3 years ago

  • Milestone changed from Future Release to 4.8
  • Owner set to jnylen0
  • Status changed from new to accepted

#2 @jnylen0
3 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 40629:

REST API: Tests: Remove and prohibit errors when generating wp-api.js fixtures.

During a PHPUnit test suite run, a file named wp-api-generated.js is created which contains some response objects that serve as fixtures for the wp-api.js client unit tests.

Previously, some of these API responses were actually error objects, which isn't what we want for testing. This commit fixes the existing error responses and prevents this situation in the future.

Fixes #40734.

Note: See TracTickets for help on using tickets.