fix signup

This commit is contained in:
Bruno Windels 2019-03-29 12:04:51 +01:00
parent 3056d936f5
commit ab5a2452ee

View file

@ -19,31 +19,26 @@ const assert = require('assert');
module.exports = async function signup(session, username, password, homeserver) { module.exports = async function signup(session, username, password, homeserver) {
session.log.step("signs up"); session.log.step("signs up");
await session.goto(session.url('/#/register')); await session.goto(session.url('/#/register'));
//click 'Custom server' radio button // change the homeserver by clicking the "Change" link.
if (homeserver) { if (homeserver) {
const advancedRadioButton = await session.waitAndQuery('#advanced'); const changeServerDetailsLink = await session.waitAndQuery('.mx_AuthBody_editServerDetails');
await advancedRadioButton.click(); await changeServerDetailsLink.click();
const hsInputField = await session.query('#mx_ServerConfig_hsUrl');
await session.replaceInputText(hsInputField, homeserver);
const nextButton = await session.query('.mx_Login_submit');
await nextButton.click();
} }
// wait until register button is visible
await session.waitAndQuery('.mx_Login_submit[value=Register]');
//fill out form //fill out form
const loginFields = await session.queryAll('.mx_Login_field'); const usernameField = await session.waitAndQuery("#mx_RegistrationForm_username");
assert.strictEqual(loginFields.length, 7); const passwordField = await session.waitAndQuery("#mx_RegistrationForm_password");
const usernameField = loginFields[2]; const passwordRepeatField = await session.waitAndQuery("#mx_RegistrationForm_passwordConfirm");
const passwordField = loginFields[3];
const passwordRepeatField = loginFields[4];
const hsurlField = loginFields[5];
await session.replaceInputText(usernameField, username); await session.replaceInputText(usernameField, username);
await session.replaceInputText(passwordField, password); await session.replaceInputText(passwordField, password);
await session.replaceInputText(passwordRepeatField, password); await session.replaceInputText(passwordRepeatField, password);
if (homeserver) { //wait over a second because Registration/ServerConfig have a 250ms
await session.waitAndQuery('.mx_ServerConfig');
await session.replaceInputText(hsurlField, homeserver);
}
//wait over a second because Registration/ServerConfig have a 1000ms
//delay to internally set the homeserver url //delay to internally set the homeserver url
//see Registration::render and ServerConfig::props::delayTimeMs //see Registration::render and ServerConfig::props::delayTimeMs
await session.delay(1500); await session.delay(300);
/// focus on the button to make sure error validation /// focus on the button to make sure error validation
/// has happened before checking the form is good to go /// has happened before checking the form is good to go
const registerButton = await session.query('.mx_Login_submit'); const registerButton = await session.query('.mx_Login_submit');
@ -60,7 +55,7 @@ module.exports = async function signup(session, username, password, homeserver)
await continueButton.click(); await continueButton.click();
//find the privacy policy checkbox and check it //find the privacy policy checkbox and check it
const policyCheckbox = await session.waitAndQuery('.mx_Login_box input[type="checkbox"]'); const policyCheckbox = await session.waitAndQuery('.mx_InteractiveAuthEntryComponents_termsPolicy input');
await policyCheckbox.click(); await policyCheckbox.click();
//now click the 'Accept' button to agree to the privacy policy //now click the 'Accept' button to agree to the privacy policy