mirror of
https://github.com/zulip/zulip.git
synced 2025-11-20 22:48:16 +00:00
This test was failing nondeterministically, because depending on when the check was done, the unread message may or may not have been read.
88 lines
2.9 KiB
JavaScript
88 lines
2.9 KiB
JavaScript
var common = require('../casper_lib/common.js').common;
|
|
|
|
var email = 'alice@test.example.com';
|
|
var subdomain = 'testsubdomain';
|
|
var organization_name = 'Awesome Organization';
|
|
var REALMS_HAVE_SUBDOMAINS = casper.cli.get('subdomains');
|
|
var host;
|
|
var realm_host;
|
|
|
|
if (REALMS_HAVE_SUBDOMAINS) {
|
|
host = 'zulipdev.com:9981';
|
|
realm_host = subdomain + '.' + host;
|
|
} else {
|
|
host = realm_host = 'localhost:9981';
|
|
}
|
|
|
|
casper.start('http://' + host + '/create_realm/');
|
|
|
|
casper.then(function () {
|
|
// Submit the email for realm creation
|
|
this.waitUntilVisible('form[action^="/create_realm/"]', function () {
|
|
this.fill('form[action^="/create_realm/"]', {
|
|
email: email,
|
|
}, true);
|
|
});
|
|
// Make sure confirmation email is send
|
|
this.waitWhileVisible('form[action^="/create_realm/"]', function () {
|
|
var regex = new RegExp('^http://[^/]+/accounts/send_confirm/' + email);
|
|
this.test.assertUrlMatch(regex, 'Confirmation mail send');
|
|
});
|
|
});
|
|
|
|
// Special endpoint enabled only during tests for extracting confirmation key
|
|
casper.thenOpen('http://' + host + '/confirmation_key/');
|
|
|
|
// 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;
|
|
this.thenOpen(confirmation_url);
|
|
});
|
|
|
|
// Make sure the realm creation page is loaded correctly
|
|
casper.then(function () {
|
|
this.waitUntilVisible('.pitch', function () {
|
|
this.test.assertSelectorContains('.pitch', "You're almost there.");
|
|
});
|
|
|
|
this.waitUntilVisible('#id_email', function () {
|
|
this.test.assertEvalEquals(function () {
|
|
return $('#id_email').attr('placeholder');
|
|
}, email);
|
|
});
|
|
|
|
this.waitUntilVisible('label[for=id_team_name]', function () {
|
|
this.test.assertSelectorHasText('label[for=id_team_name]', 'Organization name');
|
|
});
|
|
});
|
|
|
|
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,
|
|
}, true);
|
|
});
|
|
|
|
this.waitWhileVisible('form[action^="/accounts/register/"]', function () {
|
|
casper.test.assertUrlMatch(realm_host + '/', 'Home page loaded');
|
|
});
|
|
});
|
|
|
|
casper.then(function () {
|
|
// The user is logged in to the newly created realm and the app is loaded
|
|
// '(1) home - ' + organization_name + ' - Zulip' (but the (1) may or may not be there)
|
|
this.test.assertTitleMatch(/ - Zulip$/, "Title ends with Zulip");
|
|
this.test.assertTitleMatch(/home - /, "Title shows in the home view");
|
|
});
|
|
|
|
common.then_log_out();
|
|
|
|
casper.run(function () {
|
|
casper.test.done();
|
|
});
|