When updating mwbot and running tests again and again locally, there are a test that sometimes fails and recovers and it is the Page_object_pattern/specs/login.js
Expected Behavior
Running the same test over and over should produce the same results
Actual Behavior
Sometimes the test runs like this:
[0-1] RUNNING in chrome - file:///tests/selenium/docs/Page_object_pattern/specs/login.js
[0-1] Error in "User.should be able to log in without page object"
Error: expect(received).toBe(expected) // Object.is equality
Expected: "User-0.42844780476722555-Iñtërnâtiônàlizætiøn"
Received: "User-0.07005629837904026-Iñtërnâtiônàlizætiøn"
at Context.<anonymous> (file:///Users/phedenskog/git/test/core/tests/selenium/docs/Page_object_pattern/specs/login.js:37:28)Looking at the code:
// log in
await browser.url( `${ baseUrl }Special:UserLogin` );
await $( '#wpName1' ).setValue( username );
await $( '#wpPassword1' ).setValue( password );
await $( '#wpLoginAttempt' ).click();
// check
const actualUsername = await browser.execute( () => mw.config.get( 'wgUserName' ) );I think the problem here is that we click on submit and then immediately check using JavaScript if the user been logged in. What's strange though is that we get a name, meaning another user is logged in?
How to reproduce:
This don't happen everytime but if run mediawiki-quickstart locally and then my test setup use .env:
MW_SERVER=http://localhost:8080 MW_SCRIPT_PATH=/w MEDIAWIKI_USER=USER MEDIAWIKI_PASSWORD=PASSWORD
and then run tests using npm run selenium-test it sometimes happens.