mirror of https://github.com/zulip/zulip.git
116 lines
4.3 KiB
JavaScript
116 lines
4.3 KiB
JavaScript
var common = require('../casper_lib/common.js');
|
|
|
|
function user_row(name) {
|
|
var email = name + '@zulip.com';
|
|
var user_id = common.get_user_id(email);
|
|
return '.user_row[data-user-id="' + user_id + '"]';
|
|
}
|
|
|
|
common.start_and_log_in();
|
|
|
|
casper.then(function () {
|
|
var menu_selector = '#settings-dropdown';
|
|
casper.waitUntilVisible(menu_selector, function () {
|
|
casper.click(menu_selector);
|
|
casper.click('a[href^="#organization"]');
|
|
});
|
|
});
|
|
|
|
casper.then(function () {
|
|
casper.waitUntilVisible('#settings_overlay_container.show', function () {
|
|
casper.click("li[data-section='user-list-admin']");
|
|
});
|
|
});
|
|
|
|
// Test user deactivation and reactivation
|
|
casper.then(function () {
|
|
casper.waitUntilVisible(user_row('cordelia'), function () {
|
|
casper.test.assertSelectorHasText(user_row('cordelia'), 'Deactivate');
|
|
casper.click(user_row('cordelia') + ' .deactivate');
|
|
casper.test.assertTextExists('Deactivate cordelia@zulip.com', 'Deactivate modal has right user');
|
|
casper.test.assertTextExists('Deactivate now', 'Deactivate now button available');
|
|
casper.click('#deactivation_user_modal .do_deactivate_button');
|
|
});
|
|
});
|
|
|
|
casper.then(function () {
|
|
casper.waitUntilVisible(user_row('cordelia') + '.deactivated_user', function () {
|
|
casper.test.assertSelectorHasText(user_row('cordelia'), 'Reactivate');
|
|
casper.click(user_row('cordelia') + ' .reactivate');
|
|
});
|
|
});
|
|
|
|
casper.then(function () {
|
|
casper.waitUntilVisible(user_row('cordelia') + ':not(.deactivated_user)', function () {
|
|
casper.test.assertSelectorHasText(user_row('cordelia'), 'Deactivate');
|
|
});
|
|
});
|
|
|
|
casper.then(function () {
|
|
// Test Deactivated users section of admin page
|
|
casper.waitUntilVisible(user_row('cordelia'), function () {
|
|
casper.test.assertSelectorHasText(user_row('cordelia'), 'Deactivate');
|
|
casper.click(user_row('cordelia') + ' .deactivate');
|
|
casper.test.assertTextExists('Deactivate cordelia@zulip.com', 'Deactivate modal has right user');
|
|
casper.test.assertTextExists('Deactivate now', 'Deactivate now button available');
|
|
casper.click('#deactivation_user_modal .do_deactivate_button');
|
|
});
|
|
});
|
|
|
|
casper.then(function () {
|
|
// Leave the page and return
|
|
casper.reload();
|
|
|
|
casper.test.assertSelectorHasText("li[data-section='deactivated-users-admin']", "Deactivated users");
|
|
casper.click("li[data-section='deactivated-users-admin']");
|
|
|
|
|
|
casper.waitUntilVisible('#admin_deactivated_users_table ' + user_row('cordelia') + ' .reactivate', function () {
|
|
casper.test.assertSelectorHasText('#admin_deactivated_users_table ' + user_row('cordelia') + '', 'Reactivate');
|
|
casper.click('#admin_deactivated_users_table ' + user_row('cordelia') + ' .reactivate');
|
|
});
|
|
});
|
|
|
|
casper.then(function () {
|
|
casper.waitUntilVisible('#admin_deactivated_users_table ' + user_row('cordelia') + ' button:not(.reactivate)', function () {
|
|
casper.test.assertSelectorHasText('#admin_deactivated_users_table ' + user_row('cordelia') + '', 'Deactivate');
|
|
});
|
|
});
|
|
|
|
// Test bot deactivation and reactivation
|
|
casper.then(function () {
|
|
casper.test.assertSelectorHasText("li[data-section='organization-settings']", "Organization settings");
|
|
casper.click("li[data-section='bot-list-admin']");
|
|
});
|
|
|
|
casper.then(function () {
|
|
casper.waitUntilVisible(user_row('default-bot'), function () {
|
|
casper.test.assertSelectorHasText(user_row('default-bot'), 'Deactivate');
|
|
casper.click(user_row('default-bot') + ' .deactivate');
|
|
});
|
|
});
|
|
|
|
casper.then(function () {
|
|
casper.waitUntilVisible(user_row('default-bot') + '.deactivated_user', function () {
|
|
casper.test.assertSelectorHasText(user_row('default-bot'), 'Reactivate');
|
|
casper.click(user_row('default-bot') + ' .reactivate');
|
|
});
|
|
});
|
|
|
|
casper.then(function () {
|
|
casper.waitUntilVisible(user_row('default-bot') + ':not(.deactivated_user)', function () {
|
|
casper.test.assertSelectorHasText(user_row('default-bot'), 'Deactivate');
|
|
});
|
|
});
|
|
|
|
// NOTE: Any additional test code adding to the bottom of this test
|
|
// suite has risk of being weirdly flaky; we don't know why, but we
|
|
// recommend just adding a new suite if needed, since there isn't much
|
|
// overhead.
|
|
|
|
common.then_log_out();
|
|
|
|
casper.run(function () {
|
|
casper.test.done();
|
|
});
|