mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 17:56:01 +03:00
wait for the message to be sent
This commit is contained in:
parent
40577109c2
commit
4a4b1f65aa
6 changed files with 37 additions and 40 deletions
|
@ -25,13 +25,13 @@ const receiveMessage = require('./tests/receive-message');
|
|||
const createRoom = require('./tests/create-room');
|
||||
const changeRoomSettings = require('./tests/room-settings');
|
||||
const acceptServerNoticesInviteAndConsent = require('./tests/server-notices-consent');
|
||||
const getE2EDeviceFromSettings = require('./tests/e2e-device');
|
||||
const {enableLazyLoading, getE2EDeviceFromSettings} = require('./tests/settings');
|
||||
const verifyDeviceForUser = require("./tests/verify-device");
|
||||
|
||||
module.exports = async function scenario(createSession, createRestSession) {
|
||||
async function createUser(username) {
|
||||
const session = await createSession(username);
|
||||
await signup(session, session.username, 'testtest');
|
||||
await signup(session, session.username, 'testtest', session.hsUrl);
|
||||
await acceptServerNoticesInviteAndConsent(session);
|
||||
return session;
|
||||
}
|
||||
|
@ -83,3 +83,8 @@ async function createE2ERoomAndTalk(alice, bob) {
|
|||
await sendMessage(bob, bobMessage);
|
||||
await receiveMessage(alice, {sender: "bob", body: bobMessage, encrypted: true});
|
||||
}
|
||||
|
||||
async function aLLtest(alice, bob) {
|
||||
await enableLazyLoading(alice);
|
||||
|
||||
}
|
||||
|
|
|
@ -58,9 +58,10 @@ class Logger {
|
|||
}
|
||||
|
||||
module.exports = class RiotSession {
|
||||
constructor(browser, page, username, riotserver) {
|
||||
constructor(browser, page, username, riotserver, hsUrl) {
|
||||
this.browser = browser;
|
||||
this.page = page;
|
||||
this.hsUrl = hsUrl;
|
||||
this.riotserver = riotserver;
|
||||
this.username = username;
|
||||
this.consoleLog = new LogBuffer(page, "console", (msg) => `${msg.text()}\n`);
|
||||
|
@ -72,14 +73,14 @@ module.exports = class RiotSession {
|
|||
this.log = new Logger(this.username);
|
||||
}
|
||||
|
||||
static async create(username, puppeteerOptions, riotserver) {
|
||||
static async create(username, puppeteerOptions, riotserver, hsUrl) {
|
||||
const browser = await puppeteer.launch(puppeteerOptions);
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({
|
||||
width: 1280,
|
||||
height: 800
|
||||
});
|
||||
return new RiotSession(browser, page, username, riotserver);
|
||||
return new RiotSession(browser, page, username, riotserver, hsUrl);
|
||||
}
|
||||
|
||||
async tryGetInnertext(selector) {
|
||||
|
@ -161,6 +162,22 @@ module.exports = class RiotSession {
|
|||
return await this.queryAll(selector);
|
||||
}
|
||||
|
||||
waitForReload(timeout = 5000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeoutHandle = setTimeout(() => {
|
||||
this.browser.removeEventListener('domcontentloaded', callback);
|
||||
reject(new Error(`timeout of ${timeout}ms for waitForReload elapsed`));
|
||||
}, timeout);
|
||||
|
||||
const callback = async () => {
|
||||
clearTimeout(timeoutHandle);
|
||||
resolve();
|
||||
};
|
||||
|
||||
this.page.once('domcontentloaded', callback);
|
||||
});
|
||||
}
|
||||
|
||||
waitForNewPage(timeout = 5000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeoutHandle = setTimeout(() => {
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
Copyright 2018 New Vector Ltd
|
||||
|
||||
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');
|
||||
|
||||
module.exports = async function getE2EDeviceFromSettings(session) {
|
||||
session.log.step(`gets e2e device/key from settings`);
|
||||
const settingsButton = await session.query('.mx_BottomLeftMenu_settings');
|
||||
await settingsButton.click();
|
||||
const deviceAndKey = await session.waitAndQueryAll(".mx_UserSettings_section.mx_UserSettings_cryptoSection code", 1000);
|
||||
assert.equal(deviceAndKey.length, 2);
|
||||
const id = await (await deviceAndKey[0].getProperty("innerText")).jsonValue();
|
||||
const key = await (await deviceAndKey[1].getProperty("innerText")).jsonValue();
|
||||
const closeButton = await session.query(".mx_RoomHeader_cancelButton");
|
||||
await closeButton.click();
|
||||
session.log.done();
|
||||
return {id, key};
|
||||
}
|
|
@ -25,5 +25,7 @@ module.exports = async function sendMessage(session, message) {
|
|||
const text = await session.innerText(composer);
|
||||
assert.equal(text.trim(), message.trim());
|
||||
await composer.press("Enter");
|
||||
// wait for the message to appear sent
|
||||
await session.waitAndQuery(".mx_EventTile_last:not(.mx_EventTile_sending)");
|
||||
session.log.done();
|
||||
}
|
||||
}
|
||||
|
|
6
start.js
6
start.js
|
@ -26,6 +26,8 @@ program
|
|||
.option('--riot-url [url]', "riot url to test", "http://localhost:5000")
|
||||
.parse(process.argv);
|
||||
|
||||
const hsUrl = 'http://localhost:5005';
|
||||
|
||||
async function runTests() {
|
||||
let sessions = [];
|
||||
console.log("running tests ...");
|
||||
|
@ -43,7 +45,7 @@ async function runTests() {
|
|||
|
||||
const restCreator = new RestSessionCreator(
|
||||
'synapse/installations/consent',
|
||||
'http://localhost:5005',
|
||||
hsUrl,
|
||||
__dirname
|
||||
);
|
||||
|
||||
|
@ -52,7 +54,7 @@ async function runTests() {
|
|||
}
|
||||
|
||||
async function createSession(username) {
|
||||
const session = await RiotSession.create(username, options, program.riotUrl);
|
||||
const session = await RiotSession.create(username, options, program.riotUrl, hsUrl);
|
||||
sessions.push(session);
|
||||
return session;
|
||||
}
|
||||
|
|
|
@ -31,9 +31,11 @@ python -m synapse.app.homeserver \
|
|||
--generate-config \
|
||||
--report-stats=no
|
||||
# apply configuration
|
||||
REGISTRATION_SHARED_SECRET=$(uuidgen)
|
||||
cp -r $BASE_DIR/config-templates/$CONFIG_TEMPLATE/. ./
|
||||
sed -i "s#{{SYNAPSE_ROOT}}#$(pwd)/#g" homeserver.yaml
|
||||
sed -i "s#{{SYNAPSE_PORT}}#${PORT}#g" homeserver.yaml
|
||||
sed -i "s#{{FORM_SECRET}}#$(uuidgen)#g" homeserver.yaml
|
||||
sed -i "s#{{REGISTRATION_SHARED_SECRET}}#$(uuidgen)#g" homeserver.yaml
|
||||
sed -i "s#{{REGISTRATION_SHARED_SECRET}}#${REGISTRATION_SHARED_SECRET}#g" homeserver.yaml
|
||||
sed -i "s#{{MACAROON_SECRET_KEY}}#$(uuidgen)#g" homeserver.yaml
|
||||
echo REGISTRATION_SHARED_SECRET=$REGISTRATION_SHARED_SECRET=
|
||||
|
|
Loading…
Reference in a new issue