2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
var common = require("../casper_lib/common.js");
|
2016-06-25 19:04:36 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
var email = "alice@test.example.com";
|
|
|
|
var subdomain = "testsubdomain";
|
|
|
|
var organization_name = "Awesome Organization";
|
2017-08-25 05:41:04 +02:00
|
|
|
var host = "zulipdev.com:9981";
|
2020-07-15 01:29:15 +02:00
|
|
|
var realm_host = "testsubdomain" + "." + host;
|
2016-07-19 14:35:08 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.start("http://" + host + "/new/");
|
2016-06-25 19:04:36 +02:00
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
// Submit the email for realm creation
|
2018-08-24 10:22:11 +02:00
|
|
|
this.waitUntilVisible('form[name="email_form"]', function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
this.fill(
|
|
|
|
'form[name="email_form"]',
|
|
|
|
{
|
|
|
|
email: email,
|
|
|
|
},
|
|
|
|
true
|
|
|
|
);
|
2016-06-25 19:04:36 +02:00
|
|
|
});
|
|
|
|
// Make sure confirmation email is send
|
2018-08-24 10:22:11 +02:00
|
|
|
this.waitWhileVisible('form[name="email_form"]', function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
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
|
2020-07-15 01:29:15 +02:00
|
|
|
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;
|
2020-07-15 01:29:15 +02:00
|
|
|
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 () {
|
2020-07-15 01:29:15 +02:00
|
|
|
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
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
this.waitUntilVisible("#id_email", function () {
|
2016-09-16 19:05:14 +02:00
|
|
|
this.test.assertEvalEquals(function () {
|
2020-07-22 08:49:51 +02:00
|
|
|
return $("#id_email").html();
|
2016-09-16 19:05:14 +02:00
|
|
|
}, email);
|
|
|
|
});
|
2016-06-25 19:04:36 +02:00
|
|
|
|
2020-07-15 01:29:15 +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 () {
|
2017-02-10 08:01:34 +01:00
|
|
|
this.waitUntilVisible('form[action^="/accounts/register/"]', function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
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
|
|
|
});
|
|
|
|
|
2017-02-10 08:01:34 +01:00
|
|
|
this.waitWhileVisible('form[action^="/accounts/register/"]', function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.assertUrlMatch(realm_host + "/", "Home page loaded");
|
2016-06-25 19:04:36 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2017-07-08 06:14:52 +02:00
|
|
|
// The user is logged in to the newly created realm and the app is loaded
|
2020-07-15 00:34:28 +02:00
|
|
|
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();
|
|
|
|
});
|