Fix end-to-end tests for end-to-end encryption verification
Fixes https://github.com/vector-im/riot-web/issues/13226 This isn't the fastest route, but it is a predictable route for the happy path we probably want to test. For example, Alice will already be staring at the DM and could easily accept the verification there, but we probably want to make sure that the toast is present and does the right thing. Similarly, neither of them need to verify that there's green shields everywhere, they should be implied, however an explicit check follows a real user's gaze.
This commit is contained in:
parent
885bb112ae
commit
e72008d7f1
9 changed files with 244 additions and 71 deletions
|
@ -27,7 +27,7 @@ async function createRoom(session, roomName, encrypted=false) {
|
|||
const roomListHeaderLabels = await Promise.all(roomListHeaders.map(h => session.innerText(h)));
|
||||
const roomsIndex = roomListHeaderLabels.findIndex(l => l.toLowerCase().includes("rooms"));
|
||||
if (roomsIndex === -1) {
|
||||
throw new Error("could not find room list section that contains rooms in header");
|
||||
throw new Error("could not find room list section that contains 'rooms' in header");
|
||||
}
|
||||
const roomsHeader = roomListHeaders[roomsIndex];
|
||||
const addRoomButton = await roomsHeader.$(".mx_RoomSubList_addRoom");
|
||||
|
@ -48,4 +48,39 @@ async function createRoom(session, roomName, encrypted=false) {
|
|||
session.log.done();
|
||||
}
|
||||
|
||||
module.exports = {openRoomDirectory, createRoom};
|
||||
async function createDm(session, invitees) {
|
||||
session.log.step(`creates DM with ${JSON.stringify(invitees)}`);
|
||||
|
||||
const roomListHeaders = await session.queryAll('.mx_RoomSubList_labelContainer');
|
||||
const roomListHeaderLabels = await Promise.all(roomListHeaders.map(h => session.innerText(h)));
|
||||
const dmsIndex = roomListHeaderLabels.findIndex(l => l.toLowerCase().includes('direct messages'));
|
||||
if (dmsIndex === -1) {
|
||||
throw new Error("could not find room list section that contains 'direct messages' in header");
|
||||
}
|
||||
const dmsHeader = roomListHeaders[dmsIndex];
|
||||
const addRoomButton = await dmsHeader.$(".mx_RoomSubList_addRoom");
|
||||
await addRoomButton.click();
|
||||
|
||||
const inviteesEditor = await session.query('.mx_InviteDialog_editor textarea');
|
||||
for (const target of invitees) {
|
||||
await session.replaceInputText(inviteesEditor, target);
|
||||
await session.delay(1000); // give it a moment to figure out a suggestion
|
||||
// find the suggestion and accept it
|
||||
const suggestions = await session.queryAll('.mx_InviteDialog_roomTile_userId');
|
||||
const suggestionTexts = await Promise.all(suggestions.map(s => session.innerText(s)));
|
||||
const suggestionIndex = suggestionTexts.indexOf(target);
|
||||
if (suggestionIndex === -1) {
|
||||
throw new Error(`failed to find a suggestion in the DM dialog to invite ${target} with`);
|
||||
}
|
||||
await suggestions[suggestionIndex].click();
|
||||
}
|
||||
|
||||
// press the go button and hope for the best
|
||||
const goButton = await session.query('.mx_InviteDialog_goButton');
|
||||
await goButton.click();
|
||||
|
||||
await session.query('.mx_MessageComposer');
|
||||
session.log.done();
|
||||
}
|
||||
|
||||
module.exports = {openRoomDirectory, createRoom, createDm};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue