mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 02:05:45 +03:00
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 {acceptDialog} = require('./dialog');
|
||||
|
||||
async function setCheckboxSetting(session, checkbox, enabled) {
|
||||
const checked = await session.getElementProperty(checkbox, "checked");
|
||||
assert.equal(typeof checked, "boolean");
|
||||
async function setSettingsToggle(session, toggle, enabled) {
|
||||
const className = await session.getElementProperty(toggle, "className");
|
||||
const checked = className.includes("mx_ToggleSwitch_on");
|
||||
if (checked !== enabled) {
|
||||
await checkbox.click();
|
||||
await toggle.click();
|
||||
session.log.done();
|
||||
return true;
|
||||
} else {
|
||||
|
@ -31,25 +31,40 @@ async function setCheckboxSetting(session, checkbox, enabled) {
|
|||
|
||||
module.exports = async function changeRoomSettings(session, 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
|
||||
await session.delay(1000);
|
||||
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];
|
||||
//find tabs
|
||||
const tabButtons = await session.waitAndQueryAll(".mx_RoomSettingsDialog .mx_TabbedView_tabLabel");
|
||||
const tabLabels = await Promise.all(tabButtons.map(t => session.innerText(t)));
|
||||
const securityTabButton = tabButtons[tabLabels.findIndex(l => l.toLowerCase().includes("security"))];
|
||||
|
||||
const generalSwitches = await session.waitAndQueryAll(".mx_RoomSettingsDialog .mx_ToggleSwitch");
|
||||
const isDirectory = generalSwitches[0];
|
||||
|
||||
if (typeof settings.directory === "boolean") {
|
||||
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") {
|
||||
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 (clicked && settings.encryption) {
|
||||
await acceptDialog(session, "encryption");
|
||||
|
@ -58,7 +73,7 @@ module.exports = async function changeRoomSettings(session, settings) {
|
|||
|
||||
if (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);
|
||||
const inviteOnly = radios[0];
|
||||
const publicNoGuests = radios[1];
|
||||
|
@ -76,15 +91,8 @@ module.exports = async function changeRoomSettings(session, settings) {
|
|||
session.log.done();
|
||||
}
|
||||
|
||||
if (settings.alias) {
|
||||
session.log.step(`sets alias to ${settings.alias}`);
|
||||
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();
|
||||
const closeButton = await session.query(".mx_RoomSettingsDialog .mx_Dialog_cancelButton");
|
||||
await closeButton.click();
|
||||
|
||||
session.log.endGroup();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue