2018-07-09 14:50:49 +00:00
|
|
|
/*
|
|
|
|
Copyright 2018 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2018-07-09 15:51:02 +00:00
|
|
|
const helpers = require('../helpers');
|
2018-07-09 15:43:21 +00:00
|
|
|
const assert = require('assert');
|
|
|
|
|
2018-07-09 16:35:47 +00:00
|
|
|
module.exports = async function signup(page, username, password, homeserver) {
|
|
|
|
const consoleLogs = helpers.logConsole(page);
|
|
|
|
const xhrLogs = helpers.logXHRRequests(page);
|
|
|
|
await page.goto(helpers.riotUrl('/#/register'));
|
2018-07-05 10:55:45 +00:00
|
|
|
//click 'Custom server' radio button
|
2018-07-09 16:40:25 +00:00
|
|
|
const advancedRadioButton = await helpers.waitAndQuerySelector(page, '#advanced');
|
|
|
|
await advancedRadioButton.click();
|
2018-07-05 10:55:45 +00:00
|
|
|
|
|
|
|
//fill out form
|
|
|
|
await page.waitForSelector('.mx_ServerConfig', {visible: true, timeout: 500});
|
2018-07-09 16:35:47 +00:00
|
|
|
const loginFields = await page.$$('.mx_Login_field');
|
|
|
|
assert.strictEqual(loginFields.length, 7);
|
|
|
|
const usernameField = loginFields[2];
|
|
|
|
const passwordField = loginFields[3];
|
|
|
|
const passwordRepeatField = loginFields[4];
|
|
|
|
const hsurlField = loginFields[5];
|
|
|
|
await helpers.replaceInputText(usernameField, username);
|
|
|
|
await helpers.replaceInputText(passwordField, password);
|
|
|
|
await helpers.replaceInputText(passwordRepeatField, password);
|
|
|
|
await helpers.replaceInputText(hsurlField, homeserver);
|
2018-07-05 10:55:45 +00:00
|
|
|
//wait over a second because Registration/ServerConfig have a 1000ms
|
|
|
|
//delay to internally set the homeserver url
|
|
|
|
//see Registration::render and ServerConfig::props::delayTimeMs
|
2018-07-09 15:06:17 +00:00
|
|
|
await helpers.delay(1200);
|
2018-07-05 10:55:45 +00:00
|
|
|
/// focus on the button to make sure error validation
|
|
|
|
/// has happened before checking the form is good to go
|
2018-07-09 16:35:47 +00:00
|
|
|
const registerButton = await page.$('.mx_Login_submit');
|
|
|
|
await registerButton.focus();
|
2018-07-05 10:55:45 +00:00
|
|
|
//check no errors
|
2018-07-09 16:35:47 +00:00
|
|
|
const error_text = await helpers.tryGetInnertext(page, '.mx_Login_error');
|
2018-07-09 15:43:21 +00:00
|
|
|
assert.strictEqual(!!error_text, false);
|
2018-07-05 10:55:45 +00:00
|
|
|
//submit form
|
|
|
|
await page.screenshot({path: "beforesubmit.png", fullPage: true});
|
2018-07-09 16:35:47 +00:00
|
|
|
await registerButton.click();
|
2018-07-05 10:55:45 +00:00
|
|
|
|
|
|
|
//confirm dialog saying you cant log back in without e-mail
|
2018-07-09 16:40:25 +00:00
|
|
|
const continueButton = await helpers.waitAndQuerySelector(page, '.mx_QuestionDialog button.mx_Dialog_primary');
|
2018-07-09 16:35:47 +00:00
|
|
|
await continueButton.click();
|
2018-07-05 10:55:45 +00:00
|
|
|
//wait for registration to finish so the hash gets set
|
|
|
|
//onhashchange better?
|
|
|
|
/*
|
|
|
|
await page.screenshot({path: "afterlogin.png", fullPage: true});
|
|
|
|
console.log('browser console logs:');
|
2018-07-09 16:35:47 +00:00
|
|
|
console.log(consoleLogs.logs());
|
2018-07-05 10:55:45 +00:00
|
|
|
console.log('xhr logs:');
|
2018-07-09 16:35:47 +00:00
|
|
|
console.log(xhrLogs.logs());
|
2018-07-05 10:55:45 +00:00
|
|
|
*/
|
|
|
|
|
2018-07-20 16:51:25 +00:00
|
|
|
//await acceptTerms(page);
|
2018-07-05 10:55:45 +00:00
|
|
|
|
2018-07-20 16:51:25 +00:00
|
|
|
await helpers.delay(2000);
|
2018-07-09 16:35:47 +00:00
|
|
|
//printElements('page', await page.$('#matrixchat'));
|
2018-07-05 10:55:45 +00:00
|
|
|
// await navigation_promise;
|
|
|
|
|
|
|
|
//await page.waitForSelector('.mx_MatrixChat', {visible: true, timeout: 3000});
|
|
|
|
const url = page.url();
|
2018-07-09 16:35:47 +00:00
|
|
|
assert.strictEqual(url, helpers.riotUrl('/#/home'));
|
2018-07-17 10:38:20 +00:00
|
|
|
}
|