2020-07-15 01:29:15 +02:00
|
|
|
var common = require("../casper_lib/common.js");
|
2017-02-10 07:21:26 +01:00
|
|
|
|
2020-01-29 01:54:56 +01:00
|
|
|
function user_row(name) {
|
2020-07-15 01:29:15 +02:00
|
|
|
var email = name + "@zulip.com";
|
2020-01-29 02:03:37 +01:00
|
|
|
var user_id = common.get_user_id(email);
|
|
|
|
return '.user_row[data-user-id="' + user_id + '"]';
|
2020-01-29 01:54:56 +01:00
|
|
|
}
|
|
|
|
|
2017-02-10 07:21:26 +01:00
|
|
|
common.start_and_log_in();
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
var menu_selector = "#settings-dropdown";
|
2017-02-10 07:21:26 +01:00
|
|
|
casper.waitUntilVisible(menu_selector, function () {
|
|
|
|
casper.click(menu_selector);
|
2017-04-07 21:39:58 +02:00
|
|
|
casper.click('a[href^="#organization"]');
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-12-03 01:12:52 +01:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#settings_overlay_container.show", function () {
|
2016-12-03 01:12:52 +01:00
|
|
|
casper.click("li[data-section='user-list-admin']");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-02-10 07:21:26 +01:00
|
|
|
// Test user deactivation and reactivation
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible(user_row("cordelia"), function () {
|
|
|
|
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
|
|
|
casper.click(user_row("cordelia") + " .deactivate");
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertTextExists(
|
|
|
|
"Deactivate cordelia@zulip.com",
|
|
|
|
"Deactivate modal has right user"
|
|
|
|
);
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.assertTextExists("Deactivate now", "Deactivate now button available");
|
|
|
|
casper.click("#deactivation_user_modal .do_deactivate_button");
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible(user_row("cordelia") + ".deactivated_user", function () {
|
|
|
|
casper.test.assertExists(".fa-user-plus", "Reactivate icon available");
|
|
|
|
casper.click(user_row("cordelia") + " .reactivate");
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible(user_row("cordelia") + ":not(.deactivated_user)", function () {
|
|
|
|
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
// Test Deactivated users section of admin page
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible(user_row("cordelia"), function () {
|
|
|
|
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
|
|
|
casper.click(user_row("cordelia") + " .deactivate");
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertTextExists(
|
|
|
|
"Deactivate cordelia@zulip.com",
|
|
|
|
"Deactivate modal has right user"
|
|
|
|
);
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.assertTextExists("Deactivate now", "Deactivate now button available");
|
|
|
|
casper.click("#deactivation_user_modal .do_deactivate_button");
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
// Leave the page and return
|
2017-02-21 23:58:50 +01:00
|
|
|
casper.reload();
|
2017-02-10 07:21:26 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertSelectorHasText(
|
|
|
|
"li[data-section='deactivated-users-admin']",
|
|
|
|
"Deactivated users"
|
|
|
|
);
|
2016-12-03 01:12:52 +01:00
|
|
|
casper.click("li[data-section='deactivated-users-admin']");
|
2017-02-10 07:21:26 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.waitUntilVisible(
|
|
|
|
"#admin_deactivated_users_table " + user_row("cordelia") + " .reactivate",
|
|
|
|
function () {
|
|
|
|
casper.test.assertExists(".fa-user-plus", "Reactive icon available");
|
|
|
|
casper.click("#admin_deactivated_users_table " + user_row("cordelia") + " .reactivate");
|
|
|
|
}
|
|
|
|
);
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.waitUntilVisible(
|
|
|
|
"#admin_deactivated_users_table " + user_row("cordelia") + " button:not(.reactivate)",
|
|
|
|
function () {
|
|
|
|
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
|
|
|
}
|
|
|
|
);
|
2016-12-03 01:12:52 +01:00
|
|
|
});
|
2017-02-10 07:21:26 +01:00
|
|
|
|
2016-12-03 01:12:52 +01:00
|
|
|
// Test bot deactivation and reactivation
|
|
|
|
casper.then(function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertSelectorHasText(
|
|
|
|
"li[data-section='organization-settings']",
|
|
|
|
"Organization settings"
|
|
|
|
);
|
2016-12-03 01:12:52 +01:00
|
|
|
casper.click("li[data-section='bot-list-admin']");
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible(user_row("default-bot"), function () {
|
|
|
|
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
|
|
|
casper.click(user_row("default-bot") + " .deactivate");
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible(user_row("default-bot") + ".deactivated_user", function () {
|
|
|
|
casper.test.assertExists(".fa-user-plus", "Reactivate icon available");
|
|
|
|
casper.click(user_row("default-bot") + " .reactivate");
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible(user_row("default-bot") + ":not(.deactivated_user)", function () {
|
|
|
|
casper.test.assertExists(".fa-user-times", "Deactivate icon available");
|
2017-02-10 07:21:26 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
});
|