2016-06-25 19:04:36 +02:00
|
|
|
var common = require('../casper_lib/common.js').common;
|
|
|
|
|
|
|
|
var email = 'alice@test.example.com';
|
2016-07-19 14:35:08 +02:00
|
|
|
var subdomain = 'testsubdomain';
|
2016-06-25 19:04:36 +02:00
|
|
|
var organization_name = 'Awesome Organization';
|
2017-08-25 05:41:04 +02:00
|
|
|
var host = "zulipdev.com:9981";
|
|
|
|
var realm_host = "testsubdomain" + '.' + host;
|
2016-07-19 14:35:08 +02:00
|
|
|
|
2018-02-28 16:41:21 +01:00
|
|
|
casper.start('http://' + host + '/new/');
|
2016-06-25 19:04:36 +02:00
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
// Submit the email for realm creation
|
2018-02-28 16:41:21 +01:00
|
|
|
this.waitUntilVisible('form[action^="/new/"]', function () {
|
|
|
|
this.fill('form[action^="/new/"]', {
|
2016-12-03 23:18:30 +01:00
|
|
|
email: email,
|
2016-06-25 19:04:36 +02:00
|
|
|
}, true);
|
|
|
|
});
|
|
|
|
// Make sure confirmation email is send
|
2018-02-28 16:41:21 +01:00
|
|
|
this.waitWhileVisible('form[action^="/new/"]', function () {
|
2018-05-07 01:42:17 +02:00
|
|
|
var regex = new RegExp('^http://[^/]+/accounts/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
|
2016-07-19 14:35:08 +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;
|
2016-07-19 14:35:08 +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 () {
|
2017-02-10 08:01:34 +01:00
|
|
|
this.waitUntilVisible('.pitch', function () {
|
2016-08-24 21:21:28 +02:00
|
|
|
this.test.assertSelectorContains('.pitch', "You're almost there.");
|
2016-06-25 19:04:36 +02:00
|
|
|
});
|
|
|
|
|
2017-02-10 08:01:34 +01:00
|
|
|
this.waitUntilVisible('#id_email', function () {
|
2016-09-16 19:05:14 +02:00
|
|
|
this.test.assertEvalEquals(function () {
|
|
|
|
return $('#id_email').attr('placeholder');
|
|
|
|
}, email);
|
|
|
|
});
|
2016-06-25 19:04:36 +02:00
|
|
|
|
2017-02-10 08:01:34 +01:00
|
|
|
this.waitUntilVisible('label[for=id_team_name]', function () {
|
2016-06-25 19:04:36 +02:00
|
|
|
this.test.assertSelectorHasText('label[for=id_team_name]', 'Organization name');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2017-02-10 08:01:34 +01:00
|
|
|
this.waitUntilVisible('form[action^="/accounts/register/"]', function () {
|
2016-10-27 03:05:21 +02:00
|
|
|
this.fill('form[action^="/accounts/register/"]', {
|
|
|
|
full_name: 'Alice',
|
|
|
|
realm_name: organization_name,
|
|
|
|
realm_subdomain: subdomain,
|
2017-01-09 18:04:23 +01:00
|
|
|
password: 'passwordwhichisreallyreallyreallycomplexandnotguessable',
|
2016-12-03 23:18:30 +01:00
|
|
|
terms: true,
|
2017-10-06 03:58:09 +02:00
|
|
|
realm_in_root_domain: false,
|
2016-10-27 03:05:21 +02:00
|
|
|
}, true);
|
2016-06-25 19:04:36 +02:00
|
|
|
});
|
|
|
|
|
2017-02-10 08:01:34 +01:00
|
|
|
this.waitWhileVisible('form[action^="/accounts/register/"]', function () {
|
2016-10-06 01:23:27 +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
|
2017-09-22 05:40:22 +02:00
|
|
|
casper.waitUntilVisible('#zfilt', function () {
|
2017-07-11 01:17:25 +02:00
|
|
|
this.test.assertTitleMatch(/ - Zulip$/, "Successfully logged into Zulip webapp");
|
|
|
|
});
|
2016-06-25 19:04:36 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
common.then_log_out();
|
|
|
|
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|