zulip/frontend_tests/casper_tests/00-realm-creation.js

96 lines
2.9 KiB
JavaScript
Raw Normal View History

"use strict";
var common = require("../casper_lib/common.js");
2016-06-25 19:04:36 +02:00
var email = "alice@test.example.com";
var subdomain = "testsubdomain";
var organization_name = "Awesome Organization";
var host = "zulipdev.com:9981";
var realm_host = "testsubdomain" + "." + host;
casper.start("http://" + host + "/new/");
2016-06-25 19:04:36 +02:00
casper.then(function () {
// Submit the email for realm creation
this.waitUntilVisible('form[name="email_form"]', function () {
this.fill(
'form[name="email_form"]',
{
email: email,
},
true
);
2016-06-25 19:04:36 +02:00
});
// Make sure confirmation email is send
this.waitWhileVisible('form[name="email_form"]', function () {
var regex = new RegExp("^http://[^/]+/accounts/new/send_confirm/" + email);
this.test.assertUrlMatch(regex, "Confirmation mail send");
2016-06-25 19:04:36 +02:00
});
});
// Special endpoint enabled only during tests for extracting confirmation key
casper.thenOpen("http://" + host + "/confirmation_key/");
2016-06-25 19:04:36 +02:00
// Open the confirmation URL
casper.then(function () {
var confirmation_key = JSON.parse(this.getPageContent()).confirmation_key;
var confirmation_url = "http://" + host + "/accounts/do_confirm/" + confirmation_key;
2016-06-25 19:04:36 +02:00
this.thenOpen(confirmation_url);
});
// Make sure the realm creation page is loaded correctly
casper.then(function () {
this.waitUntilVisible(".pitch", function () {
this.test.assertSelectorContains(".pitch", "We just need you to do one last thing.");
2016-06-25 19:04:36 +02:00
});
this.waitUntilVisible("#id_email", function () {
this.test.assertEvalEquals(function () {
return $("#id_email").html();
}, email);
});
2016-06-25 19:04:36 +02:00
this.waitUntilVisible("label[for=id_team_name]", function () {
this.test.assertSelectorHasText("label[for=id_team_name]", "Organization name");
2016-06-25 19:04:36 +02:00
});
});
casper.then(function () {
this.waitUntilVisible('form[action^="/accounts/register/"]', function () {
this.fill(
'form[action^="/accounts/register/"]',
{
full_name: "Alice",
realm_name: organization_name,
realm_subdomain: subdomain,
password: "passwordwhichisreallyreallyreallycomplexandnotguessable",
terms: true,
realm_in_root_domain: false,
},
true
);
2016-06-25 19:04:36 +02:00
});
this.waitWhileVisible('form[action^="/accounts/register/"]', function () {
casper.test.assertUrlMatch(realm_host + "/", "Home page loaded");
2016-06-25 19:04:36 +02:00
});
});
casper.then(function () {
// The user is logged in to the newly created realm and the app is loaded
casper.waitUntilVisible(
".message_row",
function () {
this.test.assertTitleMatch(/ - Zulip$/, "Successfully logged into Zulip webapp");
},
null,
20000
);
2016-06-25 19:04:36 +02:00
});
common.then_log_out();
casper.run(function () {
casper.test.done();
});