see https://integration.wikimedia.org/ci/job/integration-quibble-apache-fullrun/20/console
00:03:29.024 The rollback action 00:03:29.024 ✔ rolls back consecutive edits (541ms) 00:03:29.565 ✔ doesn't roll back edits by another user (439ms) 00:03:30.005 ✔ doesn't allow a regular user to roll back edits (268ms) 00:03:30.273 ✔ should undo the last edit on the page using the pageid parameter (324ms) 00:03:30.598 ✔ should throw an error with code missingparam when neither pageid nor title is provided for a rollback action (299ms) 00:03:30.897 ✔ should throw an error with code notoken when the token parameter is not provided for a rollback action (257ms) 00:03:31.154 ✔ should throw an error with code nouser when a user is not provided for a rollback action (236ms) 00:03:31.391 ✔ should throw an error with code onlyauthor if the page has only one author (146ms) 00:03:31.538 ✔ should throw an error with code mustpostparams when the request to the API is not a post request (184ms) 00:03:31.723 1) should mark the revert as a bot edit ... 0:03:39.831 1 failing 00:03:39.831 00:03:39.831 1) The rollback action 00:03:39.831 should mark the revert as a bot edit: 00:03:39.831 AssertionError: expected undefined to exist 00:03:39.831 at Context.<anonymous> (tests/api-testing/action/Rollback.js:188:10) 00:03:39.831 at runMicrotasks (<anonymous>) 00:03:39.831 at processTicksAndRejections (internal/process/task_queues.js:95:5)
Looking at the test code:
it( 'should mark the revert as a bot edit', async () => { const title = utils.title( 'Rollback_' ); const firstEdit = await alice.edit( title, { text: 'One', summary: 'first' } ); const secondEdit = await bob.edit( title, { text: 'Two', summary: 'second' } ); const result = await mindy.action( 'rollback', { pageid: firstEdit.pageid, user: bob.username, summary: 'revert', markbot: true, token: await mindy.token( 'rollback' ) }, 'POST' ); const recentChanges = await mindy.getChangeEntry( { rctitle: title } ); assert.exists( recentChanges.bot ); assert.sameTitle( result.rollback.title, title ); assert.equal( result.rollback.old_revid, secondEdit.newrevid ); assert.equal( recentChanges.revid, result.rollback.revid ); } );
I suppose what is happening is that we're fetching the recent change entry before the rollback is stored in the database, since we're now processing requests asynchronously – there's no guarantee that the rollback action is fully processed (there's probably code happening in a deferred update) before the getChangeEntry call happens.
In webdriver we have browser.waitUntil which would allow retrying the mindy.getChangeEntry() call until recentChanges.bot is not undefined, but I'm not sure what helpers exist for supertest/mocha.