From 7486338efaa31e9e2657a5458e86388c2a9e5536 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 27 May 2020 16:51:04 +0100 Subject: [PATCH] Fix.the.tests. Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- test/end-to-end-tests/src/scenarios/toast.js | 48 +++++--------------- test/end-to-end-tests/src/session.js | 4 +- test/end-to-end-tests/src/usecases/toasts.js | 9 ++-- 3 files changed, 18 insertions(+), 43 deletions(-) diff --git a/test/end-to-end-tests/src/scenarios/toast.js b/test/end-to-end-tests/src/scenarios/toast.js index 97b5caa14f..1206ef40b0 100644 --- a/test/end-to-end-tests/src/scenarios/toast.js +++ b/test/end-to-end-tests/src/scenarios/toast.js @@ -20,25 +20,13 @@ module.exports = async function toastScenarios(alice, bob) { console.log(" checking and clearing toasts:"); alice.log.startGroup(`clears toasts`); - // alice.log.step(`accepts desktop notifications toast`); - // await acceptToast(alice, "Notifications"); - // alice.log.done(); - // - // alice.log.step(`accepts analytics toast`); - // await acceptToast(alice, "Help us improve Riot"); - // alice.log.done(); + alice.log.step(`reject desktop notifications toast`); + await rejectToast(alice, "Notifications"); + alice.log.done(); - while (true) { - try { - const h2Element = await alice.query('.mx_Toast_title h2'); - const toastTitle = await alice.innerText(h2Element); - console.log("DEBUG closing", toastTitle); - const toastDismissButton = await alice.query('.mx_Toast_buttons .mx_AccessibleButton_kind_danger'); - await toastDismissButton.click(); - } catch (e) { - break; - } - } + alice.log.step(`accepts analytics toast`); + await acceptToast(alice, "Help us improve Riot"); + alice.log.done(); alice.log.step(`checks no remaining toasts`); await assertNoToasts(alice); @@ -46,25 +34,13 @@ module.exports = async function toastScenarios(alice, bob) { alice.log.endGroup(); bob.log.startGroup(`clears toasts`); - // bob.log.step(`reject desktop notifications toast`); - // await rejectToast(bob, "Notifications"); - // bob.log.done(); - // - // bob.log.step(`reject analytics toast`); - // await rejectToast(bob, "Help us improve Riot"); - // bob.log.done(); + bob.log.step(`reject desktop notifications toast`); + await rejectToast(bob, "Notifications"); + bob.log.done(); - while (true) { - try { - const h2Element = await bob.query('.mx_Toast_title h2'); - const toastTitle = await bob.innerText(h2Element); - console.log("DEBUG closing", toastTitle); - const toastDismissButton = await bob.query('.mx_Toast_buttons .mx_AccessibleButton_kind_danger'); - await toastDismissButton.click(); - } catch (e) { - break; - } - } + bob.log.step(`reject analytics toast`); + await rejectToast(bob, "Help us improve Riot"); + bob.log.done(); bob.log.step(`checks no remaining toasts`); await assertNoToasts(bob); diff --git a/test/end-to-end-tests/src/session.js b/test/end-to-end-tests/src/session.js index 55c2ed440c..907ee2fb8e 100644 --- a/test/end-to-end-tests/src/session.js +++ b/test/end-to-end-tests/src/session.js @@ -122,8 +122,8 @@ module.exports = class RiotSession { await input.type(text); } - query(selector, timeout = DEFAULT_TIMEOUT) { - return this.page.waitForSelector(selector, {visible: true, timeout}); + query(selector, timeout = DEFAULT_TIMEOUT, hidden = false) { + return this.page.waitForSelector(selector, {visible: true, timeout, hidden}); } async queryAll(selector) { diff --git a/test/end-to-end-tests/src/usecases/toasts.js b/test/end-to-end-tests/src/usecases/toasts.js index 75142ed08f..204ed2b983 100644 --- a/test/end-to-end-tests/src/usecases/toasts.js +++ b/test/end-to-end-tests/src/usecases/toasts.js @@ -18,14 +18,13 @@ const assert = require('assert'); async function assertNoToasts(session) { try { - await session.query('.mx_Toast_toast'); + await session.query('.mx_Toast_toast', 1000, true); } catch (e) { - return; + const h2Element = await session.query('.mx_Toast_title h2', 1000); + const toastTitle = await session.innerText(h2Element); + throw new Error(`"${toastTitle}" toast found when none expected`); } - const h2Element = await session.query('.mx_Toast_title h2'); - const toastTitle = await session.innerText(h2Element); - throw new Error(`"${toastTitle}" toast found when none expected`); } async function assertToast(session, expectedTitle) {