mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 18:25:49 +03:00
accept terms when joining
This commit is contained in:
parent
9c5e43a693
commit
9a2d32e642
3 changed files with 36 additions and 2 deletions
18
helpers.js
18
helpers.js
|
@ -87,6 +87,23 @@ async function waitAndQuerySelector(page, selector, timeout = 500) {
|
||||||
return await page.$(selector);
|
return await page.$(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function waitForNewPage(timeout = 500) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const timeoutHandle = setTimeout(() => {
|
||||||
|
browser.removeEventListener('targetcreated', callback);
|
||||||
|
reject(new Error(`timeout of ${timeout}ms for waitForNewPage elapsed`));
|
||||||
|
}, timeout);
|
||||||
|
|
||||||
|
const callback = async (target) => {
|
||||||
|
clearTimeout(timeoutHandle);
|
||||||
|
const page = await target.page();
|
||||||
|
resolve(page);
|
||||||
|
};
|
||||||
|
|
||||||
|
browser.once('targetcreated', callback);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// other helpers
|
// other helpers
|
||||||
|
|
||||||
function randomInt(max) {
|
function randomInt(max) {
|
||||||
|
@ -110,6 +127,7 @@ module.exports = {
|
||||||
printElements,
|
printElements,
|
||||||
replaceInputText,
|
replaceInputText,
|
||||||
waitAndQuerySelector,
|
waitAndQuerySelector,
|
||||||
|
waitForNewPage,
|
||||||
randomInt,
|
randomInt,
|
||||||
riotUrl,
|
riotUrl,
|
||||||
delay,
|
delay,
|
||||||
|
|
2
start.js
2
start.js
|
@ -37,7 +37,7 @@ async function runTests() {
|
||||||
|
|
||||||
const room = 'test';
|
const room = 'test';
|
||||||
process.stdout.write(`* joining room ${room} ... `);
|
process.stdout.write(`* joining room ${room} ... `);
|
||||||
await join(page, room);
|
await join(page, room, true);
|
||||||
process.stdout.write('done\n');
|
process.stdout.write('done\n');
|
||||||
|
|
||||||
await browser.close();
|
await browser.close();
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
const helpers = require('../helpers');
|
const helpers = require('../helpers');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
module.exports = async function join(page, roomName) {
|
module.exports = async function join(page, roomName, acceptTerms = false) {
|
||||||
//TODO: brittle selector
|
//TODO: brittle selector
|
||||||
const directoryButton = await helpers.waitAndQuerySelector(page, '.mx_RoleButton[aria-label="Room directory"]');
|
const directoryButton = await helpers.waitAndQuerySelector(page, '.mx_RoleButton[aria-label="Room directory"]');
|
||||||
await directoryButton.click();
|
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');
|
const joinLink = await helpers.waitAndQuerySelector(page, '.mx_RoomPreviewBar_join_text a');
|
||||||
await joinLink.click();
|
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');
|
await page.waitForSelector('.mx_MessageComposer');
|
||||||
}
|
}
|
Loading…
Reference in a new issue