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

@@ -25,12 +25,12 @@ module.exports = async function join(session, roomName) {
const roomInput = await session.waitAndQuery('.mx_DirectorySearchBox_input');
await session.replaceInputText(roomInput, roomName);
const firstRoomLabel = await session.waitAndQuery('.mx_RoomDirectory_table .mx_RoomDirectory_name:first-child');
const firstRoomLabel = await session.waitAndQuery('.mx_RoomDirectory_table .mx_RoomDirectory_name:first-child', 1000);
await firstRoomLabel.click();
const joinLink = await session.waitAndQuery('.mx_RoomPreviewBar_join_text a');
await joinLink.click();
await session.waitForSelector('.mx_MessageComposer');
await session.waitAndQuery('.mx_MessageComposer');
session.log.done();
}

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();
}

View File

@@ -41,5 +41,6 @@ module.exports = async function acceptServerNoticesInviteAndConsent(session, not
const acceptButton = await termsPage.$('input[type=submit]');
await acceptButton.click();
await session.delay(500); //TODO yuck, timers
await termsPage.close();
session.log.done();
}