add support for changing the room settings

This commit is contained in:
Bruno Windels 2018-08-08 11:39:17 +02:00
parent 643af2d344
commit a78c095cf6
6 changed files with 83 additions and 21 deletions

View file

@ -17,5 +17,51 @@ limitations under the License.
const assert = require('assert');
module.exports = async function changeRoomSettings(session, settings) {
session.waitFor
session.log.startGroup(`changes the room settings`);
/// XXX delay is needed here, possible because the header is being rerendered
/// click doesn't do anything otherwise
await session.delay(500);
const settingsButton = await session.query(".mx_RoomHeader .mx_AccessibleButton[title=Settings]");
await settingsButton.click();
const checks = await session.waitAndQueryAll(".mx_RoomSettings_settings input[type=checkbox]");
assert.equal(checks.length, 3);
const e2eEncryptionCheck = checks[0];
const sendToUnverifiedDevices = checks[1];
const isDirectory = checks[2];
if (typeof settings.directory === "boolean") {
session.log.step(`sets directory listing to ${settings.directory}`);
const checked = await session.getElementProperty(isDirectory, "checked");
assert(typeof checked, "boolean");
if (checked !== settings.directory) {
await isDirectory.click();
session.log.done();
} else {
session.log.done("already set");
}
}
if (settings.visibility) {
session.log.step(`sets visibility to ${settings.visibility}`);
const radios = await session.waitAndQueryAll(".mx_RoomSettings_settings input[type=radio]");
assert.equal(radios.length, 7);
const inviteOnly = radios[0];
const publicNoGuests = radios[1];
const publicWithGuests = radios[2];
if (settings.visibility === "invite_only") {
await inviteOnly.click();
} else if (settings.visibility === "public_no_guests") {
await publicNoGuests.click();
} else if (settings.visibility === "public_with_guests") {
await publicWithGuests.click();
} else {
throw new Error(`unrecognized room visibility setting: ${settings.visibility}`);
}
session.log.done();
}
const saveButton = await session.query(".mx_RoomHeader_wrapper .mx_RoomHeader_textButton");
await saveButton.click();
session.log.endGroup();
}