e2e test toasts
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
b7c688d328
commit
7b6d49c416
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
|
|
||||||
const {range} = require('./util');
|
const {range} = require('./util');
|
||||||
const signup = require('./usecases/signup');
|
const signup = require('./usecases/signup');
|
||||||
|
const toastScenarios = require('./scenarios/toast');
|
||||||
const roomDirectoryScenarios = require('./scenarios/directory');
|
const roomDirectoryScenarios = require('./scenarios/directory');
|
||||||
const lazyLoadingScenarios = require('./scenarios/lazy-loading');
|
const lazyLoadingScenarios = require('./scenarios/lazy-loading');
|
||||||
const e2eEncryptionScenarios = require('./scenarios/e2e-encryption');
|
const e2eEncryptionScenarios = require('./scenarios/e2e-encryption');
|
||||||
|
@ -37,6 +38,7 @@ module.exports = async function scenario(createSession, restCreator) {
|
||||||
const alice = await createUser("alice");
|
const alice = await createUser("alice");
|
||||||
const bob = await createUser("bob");
|
const bob = await createUser("bob");
|
||||||
|
|
||||||
|
await toastScenarios(alice, bob);
|
||||||
await roomDirectoryScenarios(alice, bob);
|
await roomDirectoryScenarios(alice, bob);
|
||||||
await e2eEncryptionScenarios(alice, bob);
|
await e2eEncryptionScenarios(alice, bob);
|
||||||
console.log("create REST users:");
|
console.log("create REST users:");
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const {acceptToast} = require("../usecases/toasts");
|
||||||
|
|
||||||
|
module.exports = async function toastScenarios(alice, bob) {
|
||||||
|
console.log(" checking and clearing all toasts:");
|
||||||
|
await acceptToast(alice, "Help us improve Riot");
|
||||||
|
await acceptToast(bob, "Help us improve Riot");
|
||||||
|
};
|
|
@ -19,15 +19,6 @@ const {openRoomDirectory} = require('./create-room');
|
||||||
|
|
||||||
module.exports = async function join(session, roomName) {
|
module.exports = async function join(session, roomName) {
|
||||||
session.log.step(`joins room "${roomName}"`);
|
session.log.step(`joins room "${roomName}"`);
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
const toastDismissButton = await session.query('.mx_Toast_buttons .mx_AccessibleButton_kind_danger');
|
|
||||||
await toastDismissButton.click();
|
|
||||||
} catch (e) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await openRoomDirectory(session);
|
await openRoomDirectory(session);
|
||||||
const roomInput = await session.query('.mx_DirectorySearchBox input');
|
const roomInput = await session.query('.mx_DirectorySearchBox input');
|
||||||
await session.replaceInputText(roomInput, roomName);
|
await session.replaceInputText(roomInput, roomName);
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
async function assertToast(session, expectedTitle) {
|
||||||
|
const h2Element = await session.query('.mx_Toast_title h2');
|
||||||
|
const toastTitle = await session.innerText(h2Element);
|
||||||
|
assert(toastTitle, expectedTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function acceptToast(session, expectedTitle) {
|
||||||
|
const foundToast = await assertToast(session, expectedTitle);
|
||||||
|
if (!foundToast) {
|
||||||
|
throw new Error("could not find expected toast");
|
||||||
|
}
|
||||||
|
|
||||||
|
const btn = await session.query('.mx_Toast_buttons .mx_AccessibleButton_kind_primary');
|
||||||
|
await btn.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function rejectToast(session, expectedTitle) {
|
||||||
|
const foundToast = await assertToast(session, expectedTitle);
|
||||||
|
if (!foundToast) {
|
||||||
|
throw new Error("could not find expected toast");
|
||||||
|
}
|
||||||
|
|
||||||
|
const btn = await session.query('.mx_Toast_buttons .mx_AccessibleButton_kind_danger');
|
||||||
|
await btn.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {assertToast, acceptToast, rejectToast};
|
Loading…
Reference in New Issue