From 9c5e43a693778c33e1e673bac2cfe39d06f28357 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 9 Jul 2018 18:40:25 +0200 Subject: [PATCH] cleanup --- start.js | 13 +++---------- tests/signup.js | 8 +++----- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/start.js b/start.js index 82b567c566..0cc80f2fde 100644 --- a/start.js +++ b/start.js @@ -26,8 +26,9 @@ global.homeserver = 'http://localhost:8008'; global.browser = null; async function runTests() { - await startSession(); + global.browser = await puppeteer.launch(); const page = await helpers.newPage(); + const username = 'bruno-' + helpers.randomInt(10000); const password = 'testtest'; process.stdout.write(`* signing up as ${username} ... `); @@ -39,15 +40,7 @@ async function runTests() { await join(page, room); process.stdout.write('done\n'); - await endSession(); -} - -async function startSession() { - global.browser = await puppeteer.launch(); -} - -function endSession() { - return browser.close(); + await browser.close(); } function onSuccess() { diff --git a/tests/signup.js b/tests/signup.js index 43fe6a87d4..2a0d6dc9b4 100644 --- a/tests/signup.js +++ b/tests/signup.js @@ -22,8 +22,8 @@ module.exports = async function signup(page, username, password, homeserver) { const xhrLogs = helpers.logXHRRequests(page); await page.goto(helpers.riotUrl('/#/register')); //click 'Custom server' radio button - await page.waitForSelector('#advanced', {visible: true, timeout: 500}); - await page.click('#advanced'); + const advancedRadioButton = await helpers.waitAndQuerySelector(page, '#advanced'); + await advancedRadioButton.click(); //fill out form await page.waitForSelector('.mx_ServerConfig', {visible: true, timeout: 500}); @@ -53,9 +53,7 @@ module.exports = async function signup(page, username, password, homeserver) { await registerButton.click(); //confirm dialog saying you cant log back in without e-mail - await page.waitForSelector('.mx_QuestionDialog', {visible: true, timeout: 500}); - const continueButton = await page.$('.mx_QuestionDialog button.mx_Dialog_primary'); - //await helpers.printElements('continueButton', [continueButton]); + const continueButton = await helpers.waitAndQuerySelector(page, '.mx_QuestionDialog button.mx_Dialog_primary'); await continueButton.click(); //wait for registration to finish so the hash gets set //onhashchange better?