Page MenuHomePhabricator

[SPIKE] Add response validation check to end-to-end testing on language 'links' in MediaWiki REST API
Closed, ResolvedPublic5 Estimated Story Points

Description

Description

We perform end-to-end testing as part of the CI pipeline process using Mocha. For every endpoint in the MediaWiki REST API, we need to add a check that verifies the returned response matches the public API specifications. This will allow us to automatically detect, capture, and surface instances where the endpoint behavior does not match what is documented in the response body, which increases API stability, improving the MW API developer experience.

Problem statement

The main defense that we have against spec deviation is ensuring that undocumented changes don’t make it into production in the first place. We need to catch variation in the spec vs actual endpoint behavior as part of the release process as a way to ensure documentation accuracy and prevent accidental changes. By introducing spec validation as part of end-to-end testing for every endpoint, we can improve stability for our API.

Conditions of acceptance

  • Investigate the test configuration to see if we can easily add mocha test framework + end to end tests.
  • Update ticket with information about current state, and potential alternatives [if they exist; @daniel may have ideas]
  • Go/No Go decision on implementation.

Implementation details [if time allows/possibly a follow up ticket]

  • Update Mocha tests to utilize the reusable methods for fetching JSON schema response and comparing it against the php response for sub-elements surfaced through page links:
    • GET /page/{title}/links/language
  • Perform updates that force the test to fail; verify that it will trigger a CI error.
  • Verify that the test works across different HTTP responses (eg: 400; 404) for each endpoint.
  • Demonstrate the functionality to the team.

Event Timeline

HCoplin-WMF set the point value for this task to 3.

What I see are php integration tests not mocha. Unless there are actual mocha tests for these 2 links.

Notes from Planning
Recommendation to proceed with setting up Mocha tests.

Potential snag:
When you make a change with the API on a page that contains links, you may not see the changed links, because it is executed as part of a job. You have to clear the job queue then verify results, and/or wait 15s for the job to execute. This is an option for API "edit a page" function within the framework, instead of using the standard invoke.

Another snag:
Languages are cross-wiki links; if no sister projects are defined, then this won't work, and cannot be added/updated via the API. This may need additional configuration in the test environment to set up related projects with different languages. The only way to define a related project is maybe writing to the database.

HCoplin-WMF renamed this task from Add response validation check to end-to-end testing on Page 'link' Sub-elements in MediaWiki REST API to Add response validation check to end-to-end testing on language 'links' in MediaWiki REST API .Jan 28 2025, 3:40 PM
HCoplin-WMF updated the task description. (Show Details)
HCoplin-WMF changed the point value for this task from 3 to 5.Jan 28 2025, 3:45 PM
HCoplin-WMF renamed this task from Add response validation check to end-to-end testing on language 'links' in MediaWiki REST API to [SPIKE] Add response validation check to end-to-end testing on language 'links' in MediaWiki REST API .Jan 28 2025, 3:53 PM
HCoplin-WMF updated the task description. (Show Details)
HCoplin-WMF added a subscriber: daniel.

Change #1114778 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Mocha tests: Support language links to en-x-piglatin

https://gerrit.wikimedia.org/r/1114778

Change #1114778 merged by jenkins-bot:

[mediawiki/core@master] Mocha tests: Support language links to en-x-piglatin

https://gerrit.wikimedia.org/r/1114778

Change #1126565 had a related patch set uploaded (by Atieno; author: Atieno):

[mediawiki/core@master] mocha: Test Page language links endpoint

https://gerrit.wikimedia.org/r/1126565

Change #1126565 merged by jenkins-bot:

[mediawiki/core@master] mocha: Test Page language links endpoint

https://gerrit.wikimedia.org/r/1126565