accept terms when joining

This commit is contained in:
Bruno Windels 2018-07-10 19:26:47 +02:00
parent 9c5e43a693
commit 9a2d32e642
3 changed files with 36 additions and 2 deletions

View file

@ -17,7 +17,7 @@ limitations under the License.
const helpers = require('../helpers');
const assert = require('assert');
module.exports = async function join(page, roomName) {
module.exports = async function join(page, roomName, acceptTerms = false) {
//TODO: brittle selector
const directoryButton = await helpers.waitAndQuerySelector(page, '.mx_RoleButton[aria-label="Room directory"]');
await directoryButton.click();
@ -31,5 +31,21 @@ module.exports = async function join(page, roomName) {
const joinLink = await helpers.waitAndQuerySelector(page, '.mx_RoomPreviewBar_join_text a');
await joinLink.click();
if (acceptTerms) {
const reviewTermsButton = await helpers.waitAndQuerySelector(page, '.mx_QuestionDialog button.mx_Dialog_primary');
const termsPagePromise = helpers.waitForNewPage();
await reviewTermsButton.click();
const termsPage = await termsPagePromise;
const acceptButton = await termsPage.$('input[type=submit]');
await acceptButton.click();
await helpers.delay(500); //TODO yuck, timers
//try to join again after accepting the terms
//TODO need to do this because joinLink is detached after switching target
const joinLink2 = await helpers.waitAndQuerySelector(page, '.mx_RoomPreviewBar_join_text a');
await joinLink2.click();
}
await page.waitForSelector('.mx_MessageComposer');
}