From fd67ace078f86c213d348b22625285ff935c5827 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 23 Aug 2018 00:27:30 +0200 Subject: [PATCH 1/5] increase timeouts so the tests dont timeout on build server --- src/scenario.js | 4 ++-- src/session.js | 6 +++--- src/tests/consent.js | 4 ++-- src/tests/invite.js | 4 ++-- src/tests/receive-message.js | 2 +- src/tests/room-settings.js | 6 +++--- src/tests/server-notices-consent.js | 4 ++-- src/tests/signup.js | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/scenario.js b/src/scenario.js index f7229057a8..d859b74781 100644 --- a/src/scenario.js +++ b/src/scenario.js @@ -67,12 +67,12 @@ async function createE2ERoomAndTalk(alice, bob) { const bobDevice = await getE2EDeviceFromSettings(bob); // wait some time for the encryption warning dialog // to appear after closing the settings - await bob.delay(500); + await bob.delay(1000); await acceptDialog(bob, "encryption"); const aliceDevice = await getE2EDeviceFromSettings(alice); // wait some time for the encryption warning dialog // to appear after closing the settings - await alice.delay(500); + await alice.delay(1000); await acceptDialog(alice, "encryption"); await verifyDeviceForUser(bob, "alice", aliceDevice); await verifyDeviceForUser(alice, "bob", bobDevice); diff --git a/src/session.js b/src/session.js index 570bb4b558..ba0384b91f 100644 --- a/src/session.js +++ b/src/session.js @@ -148,7 +148,7 @@ module.exports = class RiotSession { return this.page.$(selector); } - waitAndQuery(selector, timeout = 500) { + waitAndQuery(selector, timeout = 5000) { return this.page.waitForSelector(selector, {visible: true, timeout}); } @@ -156,12 +156,12 @@ module.exports = class RiotSession { return this.page.$$(selector); } - async waitAndQueryAll(selector, timeout = 500) { + async waitAndQueryAll(selector, timeout = 5000) { await this.waitAndQuery(selector, timeout); return await this.queryAll(selector); } - waitForNewPage(timeout = 500) { + waitForNewPage(timeout = 5000) { return new Promise((resolve, reject) => { const timeoutHandle = setTimeout(() => { this.browser.removeEventListener('targetcreated', callback); diff --git a/src/tests/consent.js b/src/tests/consent.js index 595caf4d99..0b25eb06be 100644 --- a/src/tests/consent.js +++ b/src/tests/consent.js @@ -23,5 +23,5 @@ module.exports = async function acceptTerms(session) { const termsPage = await termsPagePromise; const acceptButton = await termsPage.$('input[type=submit]'); await acceptButton.click(); - await session.delay(500); //TODO yuck, timers -} \ No newline at end of file + await session.delay(1000); //TODO yuck, timers +} diff --git a/src/tests/invite.js b/src/tests/invite.js index 5a5c66b7c2..934beb6819 100644 --- a/src/tests/invite.js +++ b/src/tests/invite.js @@ -18,7 +18,7 @@ const assert = require('assert'); module.exports = async function invite(session, userId) { session.log.step(`invites "${userId}" to room`); - await session.delay(200); + await session.delay(1000); const inviteButton = await session.waitAndQuery(".mx_RightPanel_invite"); await inviteButton.click(); const inviteTextArea = await session.waitAndQuery(".mx_ChatInviteDialog textarea"); @@ -27,4 +27,4 @@ module.exports = async function invite(session, userId) { const confirmButton = await session.query(".mx_Dialog_primary"); await confirmButton.click(); session.log.done(); -} \ No newline at end of file +} diff --git a/src/tests/receive-message.js b/src/tests/receive-message.js index 9a283f4695..afe4247181 100644 --- a/src/tests/receive-message.js +++ b/src/tests/receive-message.js @@ -33,7 +33,7 @@ module.exports = async function receiveMessage(session, message) { } }); // wait a bit for the incoming event to be rendered - await session.delay(500); + await session.delay(1000); let lastTile = await session.query(".mx_EventTile_last"); const senderElement = await lastTile.$(".mx_SenderProfile_name"); const bodyElement = await lastTile.$(".mx_EventTile_body"); diff --git a/src/tests/room-settings.js b/src/tests/room-settings.js index 663f275203..9f802da711 100644 --- a/src/tests/room-settings.js +++ b/src/tests/room-settings.js @@ -33,7 +33,7 @@ module.exports = async function changeRoomSettings(session, settings) { session.log.startGroup(`changes the room settings`); /// XXX delay is needed here, possible because the header is being rerendered /// click doesn't do anything otherwise - await session.delay(500); + await session.delay(1000); const settingsButton = await session.query(".mx_RoomHeader .mx_AccessibleButton[title=Settings]"); await settingsButton.click(); const checks = await session.waitAndQueryAll(".mx_RoomSettings_settings input[type=checkbox]"); @@ -63,7 +63,7 @@ module.exports = async function changeRoomSettings(session, settings) { const inviteOnly = radios[0]; const publicNoGuests = radios[1]; const publicWithGuests = radios[2]; - + if (settings.visibility === "invite_only") { await inviteOnly.click(); } else if (settings.visibility === "public_no_guests") { @@ -80,4 +80,4 @@ module.exports = async function changeRoomSettings(session, settings) { await saveButton.click(); session.log.endGroup(); -} \ No newline at end of file +} diff --git a/src/tests/server-notices-consent.js b/src/tests/server-notices-consent.js index f1f4b7edae..d0c91da7b1 100644 --- a/src/tests/server-notices-consent.js +++ b/src/tests/server-notices-consent.js @@ -25,7 +25,7 @@ module.exports = async function acceptServerNoticesInviteAndConsent(session) { const termsPage = await termsPagePromise; const acceptButton = await termsPage.$('input[type=submit]'); await acceptButton.click(); - await session.delay(500); //TODO yuck, timers + await session.delay(1000); //TODO yuck, timers await termsPage.close(); session.log.done(); -} \ No newline at end of file +} diff --git a/src/tests/signup.js b/src/tests/signup.js index 363600f03d..b715e111a1 100644 --- a/src/tests/signup.js +++ b/src/tests/signup.js @@ -44,7 +44,7 @@ module.exports = async function signup(session, username, password, homeserver) //wait over a second because Registration/ServerConfig have a 1000ms //delay to internally set the homeserver url //see Registration::render and ServerConfig::props::delayTimeMs - await session.delay(1200); + await session.delay(1500); /// focus on the button to make sure error validation /// has happened before checking the form is good to go const registerButton = await session.query('.mx_Login_submit'); From f49b85897d2eef02574ef5719cf0dccb12986446 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 23 Aug 2018 00:29:24 +0200 Subject: [PATCH 2/5] remove specific timeout for selectors as these are not hard sleeps, but timeouts, its better to put them a bit larger, as in the best case they'll return quickly anyway and in the worst case where they need a lot of time it's still better if the tests don't fail --- src/tests/accept-invite.js | 4 ++-- src/tests/consent.js | 2 +- src/tests/dialog.js | 4 ++-- src/tests/server-notices-consent.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tests/accept-invite.js b/src/tests/accept-invite.js index c83e0c02cc..8cc1a0b37d 100644 --- a/src/tests/accept-invite.js +++ b/src/tests/accept-invite.js @@ -20,7 +20,7 @@ const {acceptDialogMaybe} = require('./dialog'); module.exports = async function acceptInvite(session, name) { session.log.step(`accepts "${name}" invite`); //TODO: brittle selector - const invitesHandles = await session.waitAndQueryAll('.mx_RoomTile_name.mx_RoomTile_invite', 1000); + const invitesHandles = await session.waitAndQueryAll('.mx_RoomTile_name.mx_RoomTile_invite'); const invitesWithText = await Promise.all(invitesHandles.map(async (inviteHandle) => { const text = await session.innerText(inviteHandle); return {inviteHandle, text}; @@ -38,4 +38,4 @@ module.exports = async function acceptInvite(session, name) { acceptDialogMaybe(session, "encryption"); session.log.done(); -} \ No newline at end of file +} diff --git a/src/tests/consent.js b/src/tests/consent.js index 0b25eb06be..b4a6289fca 100644 --- a/src/tests/consent.js +++ b/src/tests/consent.js @@ -17,7 +17,7 @@ limitations under the License. const assert = require('assert'); module.exports = async function acceptTerms(session) { - const reviewTermsButton = await session.waitAndQuery('.mx_QuestionDialog button.mx_Dialog_primary', 5000); + const reviewTermsButton = await session.waitAndQuery('.mx_QuestionDialog button.mx_Dialog_primary'); const termsPagePromise = session.waitForNewPage(); await reviewTermsButton.click(); const termsPage = await termsPagePromise; diff --git a/src/tests/dialog.js b/src/tests/dialog.js index 8d9c798c45..89c70470d9 100644 --- a/src/tests/dialog.js +++ b/src/tests/dialog.js @@ -27,7 +27,7 @@ async function acceptDialog(session, expectedContent) { async function acceptDialogMaybe(session, expectedContent) { let dialog = null; try { - dialog = await session.waitAndQuery(".mx_QuestionDialog", 100); + dialog = await session.waitAndQuery(".mx_QuestionDialog"); } catch(err) { return false; } @@ -44,4 +44,4 @@ async function acceptDialogMaybe(session, expectedContent) { module.exports = { acceptDialog, acceptDialogMaybe, -}; \ No newline at end of file +}; diff --git a/src/tests/server-notices-consent.js b/src/tests/server-notices-consent.js index d0c91da7b1..25c3bb3bd5 100644 --- a/src/tests/server-notices-consent.js +++ b/src/tests/server-notices-consent.js @@ -19,7 +19,7 @@ const acceptInvite = require("./accept-invite") module.exports = async function acceptServerNoticesInviteAndConsent(session) { await acceptInvite(session, "Server Notices"); session.log.step(`accepts terms & conditions`); - const consentLink = await session.waitAndQuery(".mx_EventTile_body a", 1000); + const consentLink = await session.waitAndQuery(".mx_EventTile_body a"); const termsPagePromise = session.waitForNewPage(); await consentLink.click(); const termsPage = await termsPagePromise; From 6be597505026fdc006ce6e47f9b1795ad4626596 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 23 Aug 2018 10:03:37 +0200 Subject: [PATCH 3/5] dont assume new target is a new page --- src/session.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/session.js b/src/session.js index ba0384b91f..bcccc9d6cc 100644 --- a/src/session.js +++ b/src/session.js @@ -164,17 +164,21 @@ module.exports = class RiotSession { waitForNewPage(timeout = 5000) { return new Promise((resolve, reject) => { const timeoutHandle = setTimeout(() => { - this.browser.removeEventListener('targetcreated', callback); + this.browser.removeListener('targetcreated', callback); reject(new Error(`timeout of ${timeout}ms for waitForNewPage elapsed`)); }, timeout); const callback = async (target) => { + if (target.type() !== 'page') { + return; + } + this.browser.removeListener('targetcreated', callback); clearTimeout(timeoutHandle); const page = await target.page(); resolve(page); }; - this.browser.once('targetcreated', callback); + this.browser.on('targetcreated', callback); }); } From a65d6af8c5ae72ba691756e88adb0487cfed2e72 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 23 Aug 2018 10:04:06 +0200 Subject: [PATCH 4/5] encryption dialogs dont always appear coming back from settings... weird --- src/scenario.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scenario.js b/src/scenario.js index d859b74781..394e89f7cd 100644 --- a/src/scenario.js +++ b/src/scenario.js @@ -15,7 +15,7 @@ limitations under the License. */ -const {acceptDialog} = require('./tests/dialog'); +const {acceptDialogMaybe} = require('./tests/dialog'); const signup = require('./tests/signup'); const join = require('./tests/join'); const sendMessage = require('./tests/send-message'); @@ -68,12 +68,12 @@ async function createE2ERoomAndTalk(alice, bob) { // wait some time for the encryption warning dialog // to appear after closing the settings await bob.delay(1000); - await acceptDialog(bob, "encryption"); + await acceptDialogMaybe(bob, "encryption"); const aliceDevice = await getE2EDeviceFromSettings(alice); // wait some time for the encryption warning dialog // to appear after closing the settings await alice.delay(1000); - await acceptDialog(alice, "encryption"); + await acceptDialogMaybe(alice, "encryption"); await verifyDeviceForUser(bob, "alice", aliceDevice); await verifyDeviceForUser(alice, "bob", bobDevice); const aliceMessage = "Guess what I just heard?!" From 2321e43fd8c9622efbe539efaace4089021474fc Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 23 Aug 2018 10:04:37 +0200 Subject: [PATCH 5/5] commander inverts the meaning of program args by itself ... nice, I guess --- start.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.js b/start.js index ac9a2f8684..f3eac32f9f 100644 --- a/start.js +++ b/start.js @@ -52,7 +52,7 @@ async function runTests() { } catch(err) { failure = true; console.log('failure: ', err); - if (!program.noLogs) { + if (program.logs) { for(let i = 0; i < sessions.length; ++i) { const session = sessions[i]; documentHtml = await session.page.content();