add support for changing the room settings
This commit is contained in:
parent
643af2d344
commit
a78c095cf6
6 changed files with 83 additions and 21 deletions
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||
const signup = require('./tests/signup');
|
||||
const join = require('./tests/join');
|
||||
const createRoom = require('./tests/create-room');
|
||||
const changeRoomSettings = require('./tests/room-settings');
|
||||
const acceptServerNoticesInviteAndConsent = require('./tests/server-notices-consent');
|
||||
|
||||
module.exports = async function scenario(createSession) {
|
||||
|
@ -33,5 +34,6 @@ module.exports = async function scenario(createSession) {
|
|||
const bob = await createUser("bob");
|
||||
const room = 'test';
|
||||
await createRoom(alice, room);
|
||||
// await join(bob, room);
|
||||
await changeRoomSettings(alice, {directory: true, visibility: "public_no_guests"});
|
||||
await join(bob, room);
|
||||
}
|
||||
|
|
|
@ -33,15 +33,27 @@ class LogBuffer {
|
|||
|
||||
class Logger {
|
||||
constructor(username) {
|
||||
this.indent = 0;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
step(description) {
|
||||
process.stdout.write(` * ${this.username} ${description} ... `);
|
||||
startGroup(description) {
|
||||
const indent = " ".repeat(this.indent * 2);
|
||||
console.log(`${indent} * ${this.username} ${description}:`);
|
||||
this.indent += 1;
|
||||
}
|
||||
|
||||
done() {
|
||||
process.stdout.write("done\n");
|
||||
endGroup() {
|
||||
this.indent -= 1;
|
||||
}
|
||||
|
||||
step(description) {
|
||||
const indent = " ".repeat(this.indent * 2);
|
||||
process.stdout.write(`${indent} * ${this.username} ${description} ... `);
|
||||
}
|
||||
|
||||
done(status = "done") {
|
||||
process.stdout.write(status + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,9 +91,17 @@ module.exports = class RiotSession {
|
|||
return null;
|
||||
}
|
||||
|
||||
async innerText(field) {
|
||||
const text_handle = await field.getProperty('innerText');
|
||||
return await text_handle.jsonValue();
|
||||
async getElementProperty(handle, property) {
|
||||
const propHandle = await handle.getProperty(property);
|
||||
return await propHandle.jsonValue();
|
||||
}
|
||||
|
||||
innerText(field) {
|
||||
return this.getElementProperty(field, 'innerText');
|
||||
}
|
||||
|
||||
getOuterHTML(element_handle) {
|
||||
return this.getElementProperty(field, 'outerHTML');
|
||||
}
|
||||
|
||||
consoleLogs() {
|
||||
|
@ -111,11 +131,6 @@ module.exports = class RiotSession {
|
|||
}
|
||||
}
|
||||
|
||||
async getOuterHTML(element_handle) {
|
||||
const html_handle = await element_handle.getProperty('outerHTML');
|
||||
return await html_handle.jsonValue();
|
||||
}
|
||||
|
||||
async printElements(label, elements) {
|
||||
console.log(label, await Promise.all(elements.map(getOuterHTML)));
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
8
start.js
8
start.js
|
@ -25,6 +25,7 @@ async function runTests() {
|
|||
|
||||
console.log("running tests ...");
|
||||
const options = {};
|
||||
// options.headless = false;
|
||||
if (process.env.CHROME_PATH) {
|
||||
const path = process.env.CHROME_PATH;
|
||||
console.log(`(using external chrome/chromium at ${path}, make sure it's compatible with puppeteer)`);
|
||||
|
@ -41,6 +42,7 @@ async function runTests() {
|
|||
try {
|
||||
await scenario(createSession);
|
||||
} catch(err) {
|
||||
failure = true;
|
||||
console.log('failure: ', err);
|
||||
for(let i = 0; i < sessions.length; ++i) {
|
||||
const session = sessions[i];
|
||||
|
@ -54,13 +56,9 @@ async function runTests() {
|
|||
console.log(documentHtml);
|
||||
console.log(`---------------- END OF ${session.username} LOGS ----------------`);
|
||||
}
|
||||
failure = true;
|
||||
}
|
||||
|
||||
for(let i = 0; i < sessions.length; ++i) {
|
||||
const session = sessions[i];
|
||||
await session.close();
|
||||
}
|
||||
await Promise.all(sessions.map((session) => session.close()));
|
||||
|
||||
if (failure) {
|
||||
process.exit(-1);
|
||||
|
|
Loading…
Reference in a new issue