fix changing the room settings
This commit is contained in:
parent
65ca1b33ee
commit
a27b92a49a
1 changed files with 30 additions and 22 deletions
|
@ -17,11 +17,11 @@ limitations under the License.
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const {acceptDialog} = require('./dialog');
|
const {acceptDialog} = require('./dialog');
|
||||||
|
|
||||||
async function setCheckboxSetting(session, checkbox, enabled) {
|
async function setSettingsToggle(session, toggle, enabled) {
|
||||||
const checked = await session.getElementProperty(checkbox, "checked");
|
const className = await session.getElementProperty(toggle, "className");
|
||||||
assert.equal(typeof checked, "boolean");
|
const checked = className.includes("mx_ToggleSwitch_on");
|
||||||
if (checked !== enabled) {
|
if (checked !== enabled) {
|
||||||
await checkbox.click();
|
await toggle.click();
|
||||||
session.log.done();
|
session.log.done();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -31,25 +31,40 @@ async function setCheckboxSetting(session, checkbox, enabled) {
|
||||||
|
|
||||||
module.exports = async function changeRoomSettings(session, settings) {
|
module.exports = async function changeRoomSettings(session, settings) {
|
||||||
session.log.startGroup(`changes the room settings`);
|
session.log.startGroup(`changes the room settings`);
|
||||||
/// XXX delay is needed here, possible because the header is being rerendered
|
/// XXX delay is needed here, possibly because the header is being rerendered
|
||||||
/// click doesn't do anything otherwise
|
/// click doesn't do anything otherwise
|
||||||
await session.delay(1000);
|
await session.delay(1000);
|
||||||
const settingsButton = await session.query(".mx_RoomHeader .mx_AccessibleButton[title=Settings]");
|
const settingsButton = await session.query(".mx_RoomHeader .mx_AccessibleButton[title=Settings]");
|
||||||
await settingsButton.click();
|
await settingsButton.click();
|
||||||
const checks = await session.waitAndQueryAll(".mx_RoomSettings_settings input[type=checkbox]");
|
//find tabs
|
||||||
assert.equal(checks.length, 3);
|
const tabButtons = await session.waitAndQueryAll(".mx_RoomSettingsDialog .mx_TabbedView_tabLabel");
|
||||||
const e2eEncryptionCheck = checks[0];
|
const tabLabels = await Promise.all(tabButtons.map(t => session.innerText(t)));
|
||||||
const sendToUnverifiedDevices = checks[1];
|
const securityTabButton = tabButtons[tabLabels.findIndex(l => l.toLowerCase().includes("security"))];
|
||||||
const isDirectory = checks[2];
|
|
||||||
|
const generalSwitches = await session.waitAndQueryAll(".mx_RoomSettingsDialog .mx_ToggleSwitch");
|
||||||
|
const isDirectory = generalSwitches[0];
|
||||||
|
|
||||||
if (typeof settings.directory === "boolean") {
|
if (typeof settings.directory === "boolean") {
|
||||||
session.log.step(`sets directory listing to ${settings.directory}`);
|
session.log.step(`sets directory listing to ${settings.directory}`);
|
||||||
await setCheckboxSetting(session, isDirectory, settings.directory);
|
await setSettingsToggle(session, isDirectory, settings.directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.alias) {
|
||||||
|
session.log.step(`sets alias to ${settings.alias}`);
|
||||||
|
const aliasField = await session.waitAndQuery(".mx_RoomSettingsDialog .mx_AliasSettings input[type=text]");
|
||||||
|
await session.replaceInputText(aliasField, settings.alias);
|
||||||
|
const addButton = await session.waitAndQuery(".mx_RoomSettingsDialog .mx_AliasSettings .mx_AccessibleButton");
|
||||||
|
await addButton.click();
|
||||||
|
session.log.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
securityTabButton.click();
|
||||||
|
const securitySwitches = await session.waitAndQueryAll(".mx_RoomSettingsDialog .mx_ToggleSwitch");
|
||||||
|
const e2eEncryptionToggle = securitySwitches[0];
|
||||||
|
|
||||||
if (typeof settings.encryption === "boolean") {
|
if (typeof settings.encryption === "boolean") {
|
||||||
session.log.step(`sets room e2e encryption to ${settings.encryption}`);
|
session.log.step(`sets room e2e encryption to ${settings.encryption}`);
|
||||||
const clicked = await setCheckboxSetting(session, e2eEncryptionCheck, settings.encryption);
|
const clicked = await setSettingsToggle(session, e2eEncryptionToggle, settings.encryption);
|
||||||
// if enabling, accept beta warning dialog
|
// if enabling, accept beta warning dialog
|
||||||
if (clicked && settings.encryption) {
|
if (clicked && settings.encryption) {
|
||||||
await acceptDialog(session, "encryption");
|
await acceptDialog(session, "encryption");
|
||||||
|
@ -58,7 +73,7 @@ module.exports = async function changeRoomSettings(session, settings) {
|
||||||
|
|
||||||
if (settings.visibility) {
|
if (settings.visibility) {
|
||||||
session.log.step(`sets visibility to ${settings.visibility}`);
|
session.log.step(`sets visibility to ${settings.visibility}`);
|
||||||
const radios = await session.waitAndQueryAll(".mx_RoomSettings_settings input[type=radio]");
|
const radios = await session.waitAndQueryAll(".mx_RoomSettingsDialog input[type=radio]");
|
||||||
assert.equal(radios.length, 7);
|
assert.equal(radios.length, 7);
|
||||||
const inviteOnly = radios[0];
|
const inviteOnly = radios[0];
|
||||||
const publicNoGuests = radios[1];
|
const publicNoGuests = radios[1];
|
||||||
|
@ -76,15 +91,8 @@ module.exports = async function changeRoomSettings(session, settings) {
|
||||||
session.log.done();
|
session.log.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.alias) {
|
const closeButton = await session.query(".mx_RoomSettingsDialog .mx_Dialog_cancelButton");
|
||||||
session.log.step(`sets alias to ${settings.alias}`);
|
await closeButton.click();
|
||||||
const aliasField = await session.waitAndQuery(".mx_RoomSettings .mx_EditableItemList .mx_EditableItem_editable");
|
|
||||||
await session.replaceInputText(aliasField, settings.alias);
|
|
||||||
session.log.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
const saveButton = await session.query(".mx_RoomHeader_wrapper .mx_RoomHeader_textButton");
|
|
||||||
await saveButton.click();
|
|
||||||
|
|
||||||
session.log.endGroup();
|
session.log.endGroup();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue