Refactoring test cafe tests
- Using "Roles" to log users - Adding seemingly useless import statement but important for code completion
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { Selector } from 'testcafe';
|
||||
|
||||
/**
|
||||
* Tries to find a given log message in the logs (for 10 seconds)
|
||||
*/
|
||||
export async function assertLogMessage(t: TestController, message: string): Promise<void> {
|
||||
let i = 0;
|
||||
let logs: string[]|undefined;
|
||||
do {
|
||||
const messages = await t.getBrowserConsoleMessages();
|
||||
logs = messages['log'];
|
||||
if (logs.find((str) => str === message)) {
|
||||
break;
|
||||
}
|
||||
await t.wait(1000);
|
||||
i++;
|
||||
} while (i < 10);
|
||||
|
||||
await t.expect(logs).contains(message);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Role } from 'testcafe';
|
||||
|
||||
export const userAlice = Role('http://play.workadventure.localhost/', async t => {
|
||||
await t
|
||||
.typeText('input[name="loginSceneName"]', 'Alice')
|
||||
.click('button.loginSceneFormSubmit')
|
||||
.click('button.selectCharacterButtonRight')
|
||||
.click('button.selectCharacterButtonRight')
|
||||
.click('button.selectCharacterSceneFormSubmit')
|
||||
.click('button.letsgo');
|
||||
});
|
||||
|
||||
export const userBob = Role('http://play.workadventure.localhost/', async t => {
|
||||
await t
|
||||
.typeText('input[name="loginSceneName"]', 'Bob')
|
||||
.click('button.loginSceneFormSubmit')
|
||||
.click('button.selectCharacterButtonRight')
|
||||
.click('button.selectCharacterSceneFormSubmit')
|
||||
.click('button.letsgo');
|
||||
});
|
||||
Reference in New Issue
Block a user