<commit_before>const common = require('../puppeteer_lib/common');
const assert = require("assert");

const email = '<EMAIL>';
const subdomain = 'testsubdomain';
const organization_name = 'Awesome Organization';
const host = "zulipdev.com:9981";

async function realm_creation_tests(page) {
    await page.goto('http://' + host + '/new/');

    // submit the email for realm creation.
    await page.waitForSelector('#email');
    await page.type('#email', email);
    await page.$eval('#send_confirm', form => form.submit());

    // 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');<commit_msg>puppetter: Add a waitForNavigation call before asserting the url.<commit_after>const common = require('../puppeteer_lib/common');
const assert = require("assert");

const email = '<EMAIL>';
const subdomain = 'testsubdomain';
const organization_name = 'Awesome Organization';
const host = "zulipdev.com:9981";

async function realm_creation_tests(page) {
    await page.goto('http://' + host + '/new/');

    // submit the email for realm creation.
    await page.waitForSelector('#email');
    await page.type('#email', email);
    await Promise.all([
        page.waitForNavigation(),
        page.$eval('#send_confirm', form => form.submit()),
    ]);

    // 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');
{'fraction_non_alphanumeric': 0.1396045536249251, 'fraction_numerical': 0.002396644697423607, 'mean_word_length': 3.93205317577548, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6954943', 'n_tokens_mistral': 949, 'n_tokens_neox': 932, 'n_words': 275}