2020-05-15 16:02:16 +02:00
|
|
|
const common = require('../puppeteer_lib/common');
|
2020-03-18 19:52:03 +01:00
|
|
|
const assert = require("assert");
|
|
|
|
|
|
|
|
const email = 'alice@test.example.com';
|
|
|
|
const subdomain = 'testsubdomain';
|
|
|
|
const organization_name = 'Awesome Organization';
|
|
|
|
const host = "zulipdev.com:9981";
|
|
|
|
|
|
|
|
async function run() {
|
|
|
|
try {
|
2020-05-15 16:02:16 +02:00
|
|
|
const page = await common.get_page('http://' + host + '/new/');
|
|
|
|
|
2020-03-18 19:52:03 +01:00
|
|
|
// submit the email for realm creation.
|
|
|
|
await page.waitForSelector('#email');
|
|
|
|
await page.type('#email', email);
|
|
|
|
await page.$eval('#send_confirm', form => form.submit());
|
2020-05-15 16:02:16 +02:00
|
|
|
|
2020-03-18 19:52:03 +01:00
|
|
|
// Make sure onfirmation email is sent.
|
|
|
|
assert(page.url().includes('/accounts/new/send_confirm/' + email));
|
|
|
|
|
|
|
|
// Special endpoint enabled only during tests for extracting confirmation key
|
|
|
|
await page.goto('http://' + host + '/confirmation_key/');
|
|
|
|
|
|
|
|
// Open the confirmation URL
|
|
|
|
const page_content = await page.evaluate(() => document.querySelector('body').innerText);
|
|
|
|
const confirmation_key = await JSON.parse(page_content).confirmation_key;
|
|
|
|
const confirmation_url = 'http://' + host + '/accounts/do_confirm/' + confirmation_key;
|
|
|
|
await page.goto(confirmation_url);
|
|
|
|
|
|
|
|
// Make sure the realm creation page is loaded correctly by
|
|
|
|
// checking the text in <p> tag under pitch class is as expected.
|
|
|
|
await page.waitForSelector('.pitch');
|
|
|
|
const text_in_pitch = await page.evaluate(() => document.querySelector('.pitch p').innerText);
|
|
|
|
assert(text_in_pitch === "We just need you to do one last thing.");
|
|
|
|
|
|
|
|
// fill the form.
|
|
|
|
await page.type('#id_team_name', organization_name);
|
|
|
|
await page.type('#id_full_name', 'Alice');
|
|
|
|
await page.type('#id_team_subdomain', subdomain);
|
|
|
|
await page.type('#id_password', 'passwordwhichisnotreallycomplex');
|
|
|
|
await page.click('#id_terms');
|
|
|
|
await page.$eval('#registration', form => form.submit());
|
|
|
|
|
|
|
|
// Check if realm is created and user is logged in by checking if
|
|
|
|
// element of id `lightbox_overlay` exists.
|
2020-05-15 16:02:16 +02:00
|
|
|
await page.waitForSelector('#lightbox_overlay'); // if element doesn't exist,timeout error raises
|
2020-03-18 19:52:03 +01:00
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
process.exit(1);
|
|
|
|
} finally {
|
2020-05-15 16:02:16 +02:00
|
|
|
common.browser.close();
|
2020-03-18 19:52:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|