fix creating a room

pull/21833/head
Bruno Windels 2019-03-29 12:27:48 +01:00
parent ab5a2452ee
commit 65ca1b33ee
1 changed files with 11 additions and 3 deletions

View File

@ -18,8 +18,16 @@ const assert = require('assert');
module.exports = async function createRoom(session, roomName) {
session.log.step(`creates room "${roomName}"`);
//TODO: brittle selector
const createRoomButton = await session.waitAndQuery('.mx_RoleButton[aria-label="Create new room"]');
const roomListHeaders = await session.queryAll('.mx_RoomSubList_labelContainer');
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");
}
const roomsHeader = roomListHeaders[roomsIndex];
const addRoomButton = await roomsHeader.$(".mx_RoomSubList_addRoom");
await addRoomButton.click();
const createRoomButton = await session.waitAndQuery('.mx_RoomDirectory_createRoom');
await createRoomButton.click();
const roomNameInput = await session.waitAndQuery('.mx_CreateRoomDialog_input');