I wanted to create a test beyond the smoke test (echo.js) I had made for the Echo. I thought something interesting to test would be the mentioning system and the alerts that are triggered when a user mentions another user.
Some insights I learned about writing a good test are that the code should reflect the cucumber format. So in this instance:
Given there is a new user who mentions the admin user on their page and the admin user logs in.
When the alert is clicked
Then the alert message notifying that the admin was mentioned is visible
And the mention test I wrote reflects this structure in terms of spacing/blocks.
it( 'checks if admin gets alert when mentioned', function () { var username = Util.getTestString( 'NewUser-' ); var password = Util.getTestString(); browser.call( function () { return Api.createAccount( username, password ).then( function () { return Api.edit( `User:${username}`, `Hello [[User:${browser.options.username}]] ~~~~`, username, password ); } ); } ); UserLoginPage.login( browser.options.username, browser.options.password ); EchoPage.alerts.click(); EchoPage.alertMessage.waitForVisible(); let regexp = /.* mentioned you on User:.*./; assert( regexp.test( EchoPage.alertMessage.getText() ) ); } );