fix composer issue and more
parent
af0c0c0afe
commit
2c983f8cee
|
@ -15,6 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
|
||||
const {acceptDialog} = require('./tests/dialog');
|
||||
const signup = require('./tests/signup');
|
||||
const join = require('./tests/join');
|
||||
const sendMessage = require('./tests/send-message');
|
||||
|
@ -31,8 +32,7 @@ module.exports = async function scenario(createSession) {
|
|||
async function createUser(username) {
|
||||
const session = await createSession(username);
|
||||
await signup(session, session.username, 'testtest');
|
||||
const noticesName = "Server Notices";
|
||||
await acceptServerNoticesInviteAndConsent(session, noticesName);
|
||||
await acceptServerNoticesInviteAndConsent(session);
|
||||
return session;
|
||||
}
|
||||
|
||||
|
@ -46,26 +46,40 @@ module.exports = async function scenario(createSession) {
|
|||
async function createDirectoryRoomAndTalk(alice, bob) {
|
||||
console.log(" creating a public room and join through directory:");
|
||||
const room = 'test';
|
||||
const message = "hi Alice!";
|
||||
await createRoom(alice, room);
|
||||
await changeRoomSettings(alice, {directory: true, visibility: "public_no_guests"});
|
||||
await join(bob, room);
|
||||
await sendMessage(bob, message);
|
||||
await receiveMessage(alice, {sender: "bob", body: message});
|
||||
const bobMessage = "hi Alice!";
|
||||
await sendMessage(bob, bobMessage);
|
||||
await receiveMessage(alice, {sender: "bob", body: bobMessage});
|
||||
const aliceMessage = "hi Bob, welcome!"
|
||||
await sendMessage(alice, aliceMessage);
|
||||
await receiveMessage(bob, {sender: "alice", body: aliceMessage});
|
||||
}
|
||||
|
||||
async function createE2ERoomAndTalk(alice, bob) {
|
||||
console.log(" creating an e2e encrypted room and join through invite:");
|
||||
const room = "secrets";
|
||||
const message = "Guess what I just heard?!"
|
||||
await createRoom(bob, room);
|
||||
await changeRoomSettings(bob, {encryption: true});
|
||||
await invite(bob, "@alice:localhost");
|
||||
await acceptInvite(alice, room);
|
||||
const bobDevice = await getE2EDeviceFromSettings(bob);
|
||||
// wait some time for the encryption warning dialog
|
||||
// to appear after closing the settings
|
||||
await bob.delay(500);
|
||||
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 acceptDialog(alice, "encryption");
|
||||
await verifyDeviceForUser(bob, "alice", aliceDevice);
|
||||
await verifyDeviceForUser(alice, "bob", bobDevice);
|
||||
await sendMessage(alice, message);
|
||||
await receiveMessage(bob, {sender: "alice", body: message, encrypted: true});
|
||||
const aliceMessage = "Guess what I just heard?!"
|
||||
await sendMessage(alice, aliceMessage);
|
||||
await receiveMessage(bob, {sender: "alice", body: aliceMessage, encrypted: true});
|
||||
const bobMessage = "You've got to tell me!";
|
||||
await sendMessage(bob, bobMessage);
|
||||
await receiveMessage(alice, {sender: "bob", body: bobMessage, encrypted: true});
|
||||
}
|
||||
|
|
|
@ -35,9 +35,7 @@ module.exports = async function acceptInvite(session, name) {
|
|||
await acceptInvitationLink.click();
|
||||
|
||||
// accept e2e warning dialog
|
||||
try {
|
||||
acceptDialogMaybe(session, "encryption");
|
||||
} catch(err) {}
|
||||
acceptDialogMaybe(session, "encryption");
|
||||
|
||||
session.log.done();
|
||||
}
|
|
@ -16,26 +16,33 @@ limitations under the License.
|
|||
|
||||
const assert = require('assert');
|
||||
|
||||
|
||||
async function getMessageFromTile(eventTile) {
|
||||
}
|
||||
|
||||
module.exports = async function receiveMessage(session, message) {
|
||||
session.log.step(`receives message "${message.body}" from ${message.sender} in room`);
|
||||
session.log.step(`receives message "${message.body}" from ${message.sender}`);
|
||||
// wait for a response to come in that contains the message
|
||||
// crude, but effective
|
||||
await session.page.waitForResponse(async (response) => {
|
||||
if (response.request().url().indexOf("/sync") === -1) {
|
||||
return false;
|
||||
}
|
||||
const body = await response.text();
|
||||
return body.indexOf(message.body) !== -1;
|
||||
if (message.encrypted) {
|
||||
return body.indexOf(message.sender) !== -1 &&
|
||||
body.indexOf("m.room.encrypted") !== -1;
|
||||
} else {
|
||||
return body.indexOf(message.body) !== -1;
|
||||
}
|
||||
});
|
||||
// wait a bit for the incoming event to be rendered
|
||||
await session.delay(100);
|
||||
await session.delay(300);
|
||||
let lastTile = await session.query(".mx_EventTile_last");
|
||||
const senderElement = await lastTile.$(".mx_SenderProfile_name");
|
||||
const bodyElement = await lastTile.$(".mx_EventTile_body");
|
||||
const sender = await(await senderElement.getProperty("innerText")).jsonValue();
|
||||
const body = await(await bodyElement.getProperty("innerText")).jsonValue();
|
||||
|
||||
if (message.encrypted) {
|
||||
const e2eIcon = await lastTile.$(".mx_EventTile_e2eIcon");
|
||||
assert.ok(e2eIcon);
|
||||
}
|
||||
assert.equal(body, message.body);
|
||||
assert.equal(sender, message.sender);
|
||||
session.log.done();
|
||||
|
|
|
@ -18,8 +18,12 @@ const assert = require('assert');
|
|||
|
||||
module.exports = async function sendMessage(session, message) {
|
||||
session.log.step(`writes "${message}" in room`);
|
||||
const composer = await session.waitAndQuery('.mx_MessageComposer');
|
||||
// this selector needs to be the element that has contenteditable=true,
|
||||
// not any if its parents, otherwise it behaves flaky at best.
|
||||
const composer = await session.waitAndQuery('.mx_MessageComposer_editor');
|
||||
await composer.type(message);
|
||||
const text = await session.innerText(composer);
|
||||
assert.equal(text.trim(), message.trim());
|
||||
await composer.press("Enter");
|
||||
session.log.done();
|
||||
}
|
|
@ -16,8 +16,8 @@ limitations under the License.
|
|||
|
||||
const assert = require('assert');
|
||||
const acceptInvite = require("./accept-invite")
|
||||
module.exports = async function acceptServerNoticesInviteAndConsent(session, noticesName) {
|
||||
await acceptInvite(session, noticesName);
|
||||
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 termsPagePromise = session.waitForNewPage();
|
||||
|
|
|
@ -20,20 +20,18 @@ module.exports = async function verifyDeviceForUser(session, name, expectedDevic
|
|||
session.log.step(`verifies e2e device for ${name}`);
|
||||
const memberNameElements = await session.queryAll(".mx_MemberList .mx_EntityTile_name");
|
||||
const membersAndNames = await Promise.all(memberNameElements.map(async (el) => {
|
||||
const innerTextHandle = await memberNameElements.getProperty("innerText");
|
||||
const innerText = await innerTextHandle.jsonValue();
|
||||
return [el, innerText];
|
||||
return [el, await session.innerText(el)];
|
||||
}));
|
||||
const matchingMember = membersAndNames.filter(([el, text]) => {
|
||||
return text === name;
|
||||
}).map(([el, name]) => el);
|
||||
}).map(([el]) => el)[0];
|
||||
await matchingMember.click();
|
||||
const firstVerifyButton = await session.waitAndQuery(".mx_MemberDeviceInfo_verify");
|
||||
await firstVerifyButton.click();
|
||||
const dialogCodeFields = await session.waitAndQueryAll(".mx_QuestionDialog code");
|
||||
assert.equal(dialogCodeFields.length, 2);
|
||||
const deviceId = dialogCodeFields[0];
|
||||
const deviceKey = dialogCodeFields[1];
|
||||
const deviceId = await session.innerText(dialogCodeFields[0]);
|
||||
const deviceKey = await session.innerText(dialogCodeFields[1]);
|
||||
assert.equal(expectedDevice.id, deviceId);
|
||||
assert.equal(expectedDevice.key, deviceKey);
|
||||
const confirmButton = await session.query(".mx_Dialog_primary");
|
||||
|
|
6
start.js
6
start.js
|
@ -21,13 +21,17 @@ const scenario = require('./src/scenario');
|
|||
const riotserver = 'http://localhost:5000';
|
||||
|
||||
const noLogs = process.argv.indexOf("--no-logs") !== -1;
|
||||
const debug = process.argv.indexOf("--debug") !== -1;
|
||||
|
||||
async function runTests() {
|
||||
let sessions = [];
|
||||
|
||||
console.log("running tests ...");
|
||||
const options = {};
|
||||
options.headless = false;
|
||||
if (debug) {
|
||||
// options.slowMo = 10;
|
||||
options.headless = false;
|
||||
}
|
||||
if (process.env.CHROME_PATH) {
|
||||
const path = process.env.CHROME_PATH;
|
||||
console.log(`(using external chrome/chromium at ${path}, make sure it's compatible with puppeteer)`);
|
||||
|
|
Loading…
Reference in New Issue