Page MenuHomePhabricator

Make action API abstraction for API integration tests more flexible.
Open, LowPublic5 Estimated Story Points

Description

Investigate "promise chaining" technique to improve the action API testing utilities.

Status Quo: The actionapi module provides several utility functions for accessing different functionality of the action API, e.g. action, login, list, prop, meta, and edit. Some of them have an optional parameter that causes then to use the POST method instead of GET. For testing for a negative outcome of a request, there is the actionError method.

Problem: actionError is inconvenient to use, we'd need to duplicate several methods, like editError, loginError, etc. With the need to synchronize between requests (see T230211), while preserving the option to not sync and test for race conditions, means we'd again have to duplicate, e.g. actionNoSync, editNoSync, etc.

Solution: use the "promise chaining" technique to configure requests using a "fluent" style interface, like so:

await alice.edit(title, "hello world").error("permission-denied");
await alice.action('block', { user }).post().sync( false );

Note that this task is made a bit more complex by the fact that some of these utility functions need to aquire tokens before the actual request can execute - that is, they have to make themselves follow another promise:

await alice.action('block', { user }).after( () = { token: await alice.token('csrf') } ).post().sync( false );

..or something like this...

Event Timeline

daniel renamed this task from API integration tests to Make action API abstraction for API integration tests more flexible..Sep 2 2019, 3:32 PM
WDoranWMF set the point value for this task to 5.Sep 4 2019, 6:16 PM
WDoranWMF lowered the priority of this task from Medium to Low.Sep 11 2019, 7:22 PM
Anomie subscribed.

This does not seem to have anything to do with MediaWiki-Action-API itself. It appears to be about a client framework used to access the API.

Removing task assignee due to inactivity, as this open task has been assigned for more than two years. See the email sent to the task assignee on February 06th 2022 (and T295729).

Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome.

If this task has been resolved in the meantime, or should not be worked on ("declined"), please update its task status via "Add Action… 🡒 Change Status".

Also see https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator.