Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tests: Remove casper tests that were added in puppeteer.

Dinesh184b2b055d93
diff --git a/frontend_tests/casper_tests/00-realm-creation.js b/frontend_tests/casper_tests/00-realm-creation.js
deleted file mode 100644
index 5816df80c0f..00000000000
--- a/frontend_tests/casper_tests/00-realm-creation.js
+++ /dev/null
@@ -1,95 +0,0 @@
-"use strict";
-
-var common = require("../casper_lib/common.js");
-
-var email = "[email protected]";
-var subdomain = "testsubdomain";
-var organization_name = "Awesome Organization";
-var host = "zulipdev.com:9981";
-var realm_host = "testsubdomain" + "." + host;
-
-casper.start("http://" + host + "/new/");
-
-casper.then(function () {
- // Submit the email for realm creation
- this.waitUntilVisible('form[name="email_form"]', function () {
- this.fill(
- 'form[name="email_form"]',
- {
- email: email,
- },
- true
- );
- });
- // Make sure confirmation email is send
- this.waitWhileVisible('form[name="email_form"]', function () {
- var regex = new RegExp("^http://[^/]+/accounts/new/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", "We just need you to do one last thing.");
- });
-
- this.waitUntilVisible("#id_email", function () {
- this.test.assertEvalEquals(function () {
- return $("#id_email").html();
- }, 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,
- realm_in_root_domain: false,
- },
- 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
- casper.waitUntilVisible(
- ".message_row",
- function () {
- this.test.assertTitleMatch(/ - Zulip$/, "Successfully logged into Zulip webapp");
- },
- null,
- 20000
- );
-});
-
-common.then_log_out();
-
-casper.run(function () {
- casper.test.done();
-});
diff --git a/frontend_tests/casper_tests/01-login.js b/frontend_tests/casper_tests/01-login.js
deleted file mode 100644
index 6fca4a4d974..00000000000
--- a/frontend_tests/casper_tests/01-login.js
+++ /dev/null
@@ -1,22 +0,0 @@
-"use strict";
-
-var common = require("../casper_lib/common.js");
-
-var realm_url = "http://zulip.zulipdev.com:9981/";
-
-// Start of test script.
-common.init_viewport();
-casper.start(realm_url, common.initialize_casper);
-
-casper.then(function () {
- casper.test.assertUrlMatch(/^http:\/\/[^/]+\/login\/$/, "Redirected to /login/");
-});
-
-common.then_log_in();
-
-common.then_log_out();
-
-// Run the above queued actions.
-casper.run(function () {
- casper.test.done();
-});
diff --git a/frontend_tests/casper_tests/02-site.js b/frontend_tests/casper_tests/02-site.js
deleted file mode 100644
index 9f58ceae8ce..00000000000
--- a/frontend_tests/casper_tests/02-site.js
+++ /dev/null
@@ -1,82 +0,0 @@
-"use strict";
-
-/* Script for testing the web client.
-
- This runs under CasperJS. It's an end-to-end black-box sort of test. It
- simulates clicking around in the app, sending messages, etc. We run against
- a real development server instance and avoid mocking as much as possible.
-*/
-
-// Provides a few utility functions.
-// See https://web.archive.org/web/20200110122733if_/https://docs.casperjs.org/en/latest/modules/utils.html
-// For example, utils.dump() prints an Object with nice formatting.
-var common = require("../casper_lib/common.js");
-
-common.start_and_log_in();
-
-casper.then(function () {
- casper.test.info("Sanity-checking existing messages");
-
- var msg = common.get_rendered_messages("zhome");
-
- msg.headings.forEach(function (heading) {
- casper.test.assertMatch(
- common.normalize_spaces(heading),
- /(^You and )|( )/,
- "Heading is well-formed"
- );
- });
-
- casper.test.info("Sending messages");
-});
-
-// Send some messages.
-
-common.then_send_many([
- {stream: "Verona", subject: "frontend test", content: "test verona A"},
-
- {stream: "Verona", subject: "frontend test", content: "test verona B"},
-
- {stream: "Verona", subject: "other subject", content: "test verona C"},
-
- {recipient: "[email protected], [email protected]", content: "personal A"},
-
- {recipient: "[email protected], [email protected]", content: "personal B"},
-
- {recipient: "[email protected]", content: "personal C"},
-]);
-
-common.wait_for_receive(function () {
- common.expected_messages(
- "zhome",
- [
- "Verona > frontend test",
- "Verona > other subject",
- "You and Cordelia Lear, King Hamlet",
- "You and Cordelia Lear",
- ],
- [
- "<p>test verona A</p>",
- "<p>test verona B</p>",
- "<p>test verona C</p>",
- "<p>personal A</p>",
- "<p>personal B</p>",
- "<p>personal C</p>",
- ]
- );
-
- casper.test.info("Sending more messages");
-});
-
-common.then_send_many([
- {stream: "Verona", subject: "frontend test", content: "test verona D"},
-
- {recipient: "[email protected], [email protected]", content: "personal D"},
-]);
-
-common.then_log_out();
-
-// Run the above queued actions.
-casper.run(function () {
- casper.test.done();
-});
diff --git a/frontend_tests/casper_tests/04-compose.js b/frontend_tests/casper_tests/04-compose.js
deleted file mode 100644
index 514157b3613..00000000000
--- a/frontend_tests/casper_tests/04-compose.js
+++ /dev/null
@@ -1,248 +0,0 @@
-"use strict";
-
-var common = require("../casper_lib/common.js");
-
-common.start_and_log_in();
-
-var msgs_qty;
-
-casper.then(function () {
- casper.waitUntilVisible("#zhome");
-});
-
-casper.then(function () {
- msgs_qty = this.evaluate(function () {
- return $("#zhome .message_row").length;
- });
-});
-
-// Send a message to try replying to
-common.then_send_many([
- {stream: "Verona", subject: "Reply test", content: "We reply to this message"},
- {recipient: "[email protected]", content: "And reply to this message"},
-]);
-
-casper.then(function () {
- casper.waitFor(function check_length() {
- return casper.evaluate(function (expected_length) {
- return $("#zhome .message_row").length === expected_length;
- }, msgs_qty + 2);
- });
-});
-
-casper.then(function () {
- // TODO: Test opening the compose box from the left side buttons
- casper.click("body");
- casper.page.sendEvent("keypress", "c");
-});
-
-function check_compose_is_cleared() {
- common.check_form(
- "#send_message_form",
- {
- stream_message_recipient_stream: "",
- stream_message_recipient_topic: "",
- },
- "Stream empty on new compose"
- );
-}
-
-casper.then(function () {
- casper.waitUntilVisible("#compose", function () {
- casper.test.assertVisible("#stream-message", "Stream input box visible");
- check_compose_is_cleared();
- casper.click("body");
- casper.page.sendEvent("keypress", "x");
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#private_message_recipient", function () {
- common.pm_recipient.expect("");
- casper.click("body");
- casper.page.sendEvent("keypress", "c");
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#stream-message", function () {
- check_compose_is_cleared();
-
- // Check that when you reply to a message it pre-populates the stream and subject fields
- casper.click("body");
- });
-});
-
-casper.then(function () {
- casper.waitWhileVisible("#stream-message", function () {
- casper.clickLabel("We reply to this message");
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#stream-message", function () {
- common.check_form(
- "#send_message_form",
- {
- stream_message_recipient_stream: "Verona",
- stream_message_recipient_topic: "Reply test",
- },
- "Stream populated after reply by click"
- );
- // Or recipient field
- casper.click("body");
- casper.clickLabel("And reply to this message");
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#private_message_recipient", function () {
- common.pm_recipient.expect("[email protected]");
-
- common.keypress(27); //Esc
- casper.page.sendEvent("keypress", "k");
- casper.page.sendEvent("keypress", "r");
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#stream-message", function () {
- common.check_form(
- "#send_message_form",
- {
- stream_message_recipient_stream: "Verona",
- stream_message_recipient_topic: "Reply test",
- },
- "Stream populated after reply with `r`"
- );
-
- // Test "closing" the compose box
- casper.click("body");
- });
-});
-
-casper.then(function () {
- casper.waitWhileVisible("#stream-message", function () {
- casper.test.assertNotVisible("#stream-message", "Close stream compose box");
- casper.page.sendEvent("keypress", "x");
- casper.click("body");
- });
-});
-
-casper.then(function () {
- casper.waitWhileVisible("#private-message", function () {
- casper.test.assertNotVisible("#private-message", "Close PM compose box");
- });
-});
-
-// Test focus after narrowing to PMs with a user and typing 'c'
-casper.then(function () {
- casper.click('*[title="Narrow to your private messages with Cordelia Lear"]');
-});
-
-casper.then(function () {
- var cordelia_user_id = common.get_user_id("[email protected]");
- var pm_li =
- 'li[data-user-ids-string="' +
- cordelia_user_id +
- '"].expanded_private_message.active-sub-filter';
-
- casper.waitUntilVisible(pm_li, function () {
- casper.page.sendEvent("keypress", "c");
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#compose", function () {
- casper.test.assertEval(function () {
- return (
- document.activeElement === $(".compose_table #stream_message_recipient_stream")[0]
- );
- }, "Stream box focused after narrowing to PMs with a user and pressing `c`");
- });
-});
-
-// Make sure multiple PM recipients display properly.
-var recipients = ["[email protected]", "[email protected]"];
-casper.then(function () {
- common.keypress(27); // Esc to dismiss compose box
-});
-casper.waitWhileVisible(".message_comp");
-common.then_send_message("private", {
- recipient: recipients.join(","),
- outside_view: true,
- content: "A huddle to check spaces",
-});
-
-casper.then(function () {
- common.keypress(27); // Esc to dismiss compose box
-});
-casper.then(function () {
- common.un_narrow();
-});
-casper.waitUntilVisible("#zhome", function () {
- casper.clickLabel("A huddle to check spaces");
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#compose", function () {
- common.pm_recipient.expect(recipients.join(","));
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#markdown_preview", function () {
- casper.test.assertNotVisible("#undo_markdown_preview", "Write button is hidden");
- casper.click("#markdown_preview");
- });
-});
-
-casper.then(function () {
- casper.waitWhileVisible("#markdown_preview", function () {
- casper.test.assertVisible("#undo_markdown_preview", "Write button is visible");
- casper.test.assertEquals(
- casper.getHTML("#preview_content"),
- "Nothing to preview",
- "Nothing to preview"
- );
- casper.click("#undo_markdown_preview");
- });
-});
-
-casper.then(function () {
- casper.waitWhileVisible("#undo_markdown_preview", function () {
- casper.test.assertVisible("#markdown_preview", "Preview button is visible.");
- casper.test.assertNotVisible("#undo_markdown_preview", "Write button is hidden.");
- casper.test.assertEquals(
- casper.getHTML("#preview_content"),
- "",
- "Markdown preview area is empty"
- );
-
- casper.fill(
- 'form[action^="/json/messages"]',
- {
- content: "**Markdown preview** >> Test for Markdown preview",
- },
- false
- );
-
- casper.click("#markdown_preview");
- });
-});
-
-casper.then(function () {
- casper.waitForSelectorTextChange("#preview_content", function () {
- casper.test.assertEquals(
- casper.getHTML("#preview_content"),
- "<p><strong>Markdown preview</strong> &gt;&gt; Test for Markdown preview</p>",
- "Check Markdown is previewed properly"
- );
- });
-});
-
-common.then_log_out();
-
-casper.run(function () {
- casper.test.done();
-});
diff --git a/frontend_tests/casper_tests/05-subscriptions.js b/frontend_tests/casper_tests/05-subscriptions.js
deleted file mode 100644
index d4a46097647..00000000000
--- a/frontend_tests/casper_tests/05-subscriptions.js
+++ /dev/null
@@ -1,250 +0,0 @@
-"use strict";
-
-var common = require("../casper_lib/common.js");
-
-function stream_checkbox(stream_name) {
- var stream_id = common.get_stream_id(stream_name);
- return '#stream-checkboxes [data-stream-id="' + stream_id + '"]';
-}
-
-function stream_span(stream_name) {
- return stream_checkbox(stream_name) + " input ~ span";
-}
-
-function user_checkbox(email) {
- var user_id = common.get_user_id(email);
- return '#user-checkboxes [data-user-id="' + user_id + '"]';
-}
-
-function user_span(email) {
- return user_checkbox(email) + " input ~ span";
-}
-
-function is_checked(email) {
- var sel = user_checkbox(email);
- return casper.evaluate(
- function (sel) {
- return $(sel).find("input")[0].checked;
- },
- {
- sel: sel,
- }
- );
-}
-
-common.start_and_log_in();
-
-casper.then(function () {
- var menu_selector = "#settings-dropdown";
-
- casper.test.info("Streams page");
-
- casper.waitUntilVisible(menu_selector, function () {
- casper.click(menu_selector);
- casper.then(function () {
- casper.click('a[href^="#streams"]');
- casper.test.assertUrlMatch(
- /^http:\/\/[^/]+\/#streams/,
- "URL suggests we are on streams page"
- );
- casper.waitUntilVisible("#subscription_overlay.new-style", function () {
- casper.test.assertExists(
- "#subscription_overlay.new-style",
- "Streams page is active"
- );
- });
- });
- });
-});
-
-casper.waitUntilVisible(".sub_unsub_button.checked", function () {
- casper.test.assertExists(".sub_unsub_button.checked", "Initial subscriptions loaded");
- casper.click("#add_new_subscription .create_stream_button");
-});
-
-casper.then(function () {
- casper.test.assertExists(
- user_checkbox("[email protected]"),
- "Original user list contains Cordelia"
- );
- casper.test.assertExists(
- user_checkbox("[email protected]"),
- "Original user list contains Othello"
- );
-});
-
-casper.waitUntilVisible("#copy-from-stream-expand-collapse", function () {
- casper.click("#copy-from-stream-expand-collapse");
-});
-
-casper.waitUntilVisible("#stream-checkboxes", function () {
- casper.test.assertExists(stream_checkbox("Scotland"), "Original stream list contains Scotland");
- casper.test.assertExists(stream_checkbox("Rome"), "Original stream list contains Rome");
-});
-
-casper.waitUntilVisible("form#stream_creation_form", function () {
- casper.test.info("Filtering with keyword 'ot'");
- casper.fill("form#stream_creation_form", {user_list_filter: "ot"});
-});
-casper.waitUntilVisible("#user-checkboxes", function () {
- casper.test.assertEquals(
- casper.visible(user_checkbox("[email protected]")),
- false,
- "Cordelia is not visible"
- );
- casper.test.assertEquals(
- casper.visible(user_checkbox("[email protected]")),
- true,
- "Othello is visible"
- );
-
- /* The filter should not impact streams */
- casper.test.assertEquals(
- casper.visible(stream_checkbox("Scotland")),
- true,
- "Scotland is visible"
- );
- casper.test.assertEquals(casper.visible(stream_checkbox("Rome")), true, "Rome is visible");
-});
-casper.then(function () {
- casper.test.info("Check Uncheck only visible users for new stream");
- casper.click(".subs_set_all_users");
- casper.wait(100, function () {
- casper.test.assert(!is_checked("[email protected]"), "Cordelia is unchecked");
- casper.test.assert(is_checked("[email protected]"), "Othello is checked");
- });
-});
-casper.then(function () {
- casper.test.info("Check Uncheck only visible users for new stream");
- casper.click(".subs_unset_all_users");
- casper.wait(100, function () {
- casper.test.assert(!is_checked("[email protected]"), "Othello is unchecked");
- });
-});
-casper.then(function () {
- casper.test.info("Clearing user filter search box");
- casper.fill("form#stream_creation_form", {user_list_filter: ""});
-});
-casper.then(function () {
- casper.test.assertEquals(
- casper.visible(user_checkbox("[email protected]")),
- true,
- "Cordelia is visible again"
- );
- casper.test.assertEquals(
- casper.visible(user_checkbox("[email protected]")),
- true,
- "Othello is visible again"
- );
- casper.test.assertEquals(
- casper.visible(stream_checkbox("Scotland")),
- true,
- "Scotland is visible again"
- );
- casper.test.assertEquals(
- casper.visible(stream_checkbox("Rome")),
- true,
- "Rome is visible again"
- );
-});
-casper.then(function () {
- casper.waitUntilVisible("#stream_creation_form", function () {
- casper.test.assertTextExists("Create stream", "New stream creation panel");
- casper.fill("form#stream_creation_form", {
- stream_name: "Waseemio",
- stream_description: "Oimeesaw",
- });
- casper.click(stream_span("Scotland"));
- casper.click(user_span("[email protected]"));
- casper.click(user_span("[email protected]"));
- casper.click("form#stream_creation_form button.button.sea-green");
- });
-});
-
-casper.then(function () {
- casper.waitFor(function () {
- return casper.evaluate(function () {
- return $(".stream-name").is(':contains("Waseemio")');
- });
- });
-});
-
-casper.then(function () {
- casper.test.info("User should be subscribed to stream Waseemio");
- casper.test.assertSelectorHasText(".stream-name", "Waseemio");
- casper.test.assertSelectorHasText(".description", "Oimeesaw");
- // Based on the selected checkboxes while creating stream,
- // 4 users from Scotland are added.
- // 1 user, Cordelia, is added. Othello (subscribed to Scotland) is removed.
- // FIXME: This assertion may pick up the count from a random other stream.
- casper.test.assertSelectorHasText(".subscriber-count-text", "4");
- casper.fill("form#stream_creation_form", {stream_name: " "});
- casper.click("form#stream_creation_form button.button.sea-green");
-});
-casper.then(function () {
- common.wait_for_text("#stream_name_error", "A stream needs to have a name", function () {
- casper.test.assertTextExists(
- "A stream needs to have a name",
- "Can't create a stream with an empty name"
- );
- casper.click("form#stream_creation_form button.button.white");
- casper.fill("form#stream_creation_form", {stream_name: "Waseemio"});
- casper.click("form#stream_creation_form button.button.sea-green");
- });
-});
-casper.then(function () {
- common.wait_for_text(
- "#stream_name_error",
- "A stream with this name already exists",
- function () {
- casper.test.assertTextExists(
- "A stream with this name already exists",
- "Can't create a stream with a duplicate name"
- );
- casper.test.info("Streams should be filtered when typing in the create box");
- casper.click("form#stream_creation_form button.button.white");
- }
- );
-});
-casper.then(function () {
- common.wait_for_text("#search_stream_name", "", function () {
- casper.test.assertSelectorHasText(
- '.stream-row[data-stream-name="Verona"] .stream-name',
- "Verona",
- "Verona stream exists before filtering"
- );
- casper.test.assertSelectorDoesntHaveText(
- ".stream-row.notdisplayed .stream-name",
- "Verona",
- "Verona stream shown before filtering"
- );
- });
-});
-casper.then(function () {
- casper.evaluate(function () {
- $('#stream_filter input[type="text"]').expectOne().val("waseem").trigger($.Event("input"));
- });
-});
-casper.waitForSelectorTextChange(".streams-list", function () {
- casper.test.assertSelectorHasText(
- ".stream-row .stream-name",
- "Waseemio",
- "Waseemio stream exists after filtering"
- );
- casper.test.assertSelectorHasText(
- ".stream-row.notdisplayed .stream-name",
- "Verona",
- "Verona stream not shown after filtering"
- );
- casper.test.assertSelectorDoesntHaveText(
- ".stream-row.notdisplayed .stream-name",
- "Waseemio",
- "Waseemio stream shown after filtering"
- );
-});
-
-common.then_log_out();
-
-casper.run(function () {
- casper.test.done();
-});
diff --git a/frontend_tests/casper_tests/06-settings.js b/frontend_tests/casper_tests/06-settings.js
deleted file mode 100644
index 75b215513bb..00000000000
--- a/frontend_tests/casper_tests/06-settings.js
+++ /dev/null
@@ -1,420 +0,0 @@
-"use strict";
-
-var test_credentials = require("../../var/casper/test_credentials.js").test_credentials;
-var common = require("../casper_lib/common.js");
-
-var OUTGOING_WEBHOOK_BOT_TYPE = "3";
-var GENERIC_BOT_TYPE = "1";
-
-common.start_and_log_in();
-
-// Password change form test commented out due to Django logging out the user.
-
-// var form_sel = 'form[action^="/json/settings"]';
-var regex_zuliprc = /^data:application\/octet-stream;charset=utf-8,\[api\]\nemail=.+\nkey=.+\nsite=.+\n$/;
-var regex_outgoing_webhook_zuliprc = /^data:application\/octet-stream;charset=utf-8,\[api\]\nemail=.+\nkey=.+\nsite=.+\ntoken=.+\n$/;
-var regex_botserverrc = /^data:application\/octet-stream;charset=utf-8,\[\]\nemail=.+\nkey=.+\nsite=.+\ntoken=.+\n$/;
-
-casper.then(function () {
- var menu_selector = "#settings-dropdown";
- casper.waitUntilVisible(menu_selector, function () {
- casper.click(menu_selector);
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible('a[href^="#settings"]', function () {
- casper.test.info("Settings page");
- casper.click('a[href^="#settings"]');
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#settings_content .account-settings-form", function () {
- casper.test.assertUrlMatch(
- /^http:\/\/[^/]+\/#settings/,
- "URL suggests we are on settings page"
- );
- casper.test.assertVisible(".account-settings-form", "Settings page is active");
-
- casper.test.assertNotVisible("#pw_change_controls");
-
- // casper.click(".change_password_button");
- casper.click("#api_key_button");
- });
-});
-
-/*
-casper.then(function () {
- casper.waitUntilVisible("#pw_change_controls", function () {
- casper.waitForResource("zxcvbn.js", function () {
- casper.test.assertVisible("#old_password");
- casper.test.assertVisible("#new_password");
-
- casper.test.assertEqual(casper.getFormValues(form_sel).full_name, "Desdemona");
-
- casper.fill(form_sel, {
- full_name: "DesdemonaNew",
- old_password: test_credentials.default_user.password,
- new_password: "qwertyuiop",
- });
- casper.test.assertNotVisible("#account-settings-status");
- casper.click('button[name="change_settings"]');
- });
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible('#account-settings-status', function () {
- casper.test.assertSelectorHasText('#account-settings-status', 'Updated settings!');
- casper.click('#api_key_button');
- });
-});
-*/
-
-casper.then(function () {
- casper.waitUntilVisible("#get_api_key_button", function () {
- casper.fill("#api_key_form", {password: test_credentials.default_user.password});
- casper.click("#get_api_key_button");
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#show_api_key", function () {
- casper.test.assertMatch(
- casper.fetchText("#api_key_value"),
- /[a-zA-Z0-9]{32}/,
- "Looks like an API key"
- );
-
- /*
- // Change it all back so the next test can still log in
- casper.fill(form_sel, {
- full_name: "Desdemona",
- old_password: "qwertyuiop",
- new_password: test_credentials.default_user.password,
- });
- casper.click('button[name="change_settings"]');
- */
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#show_api_key", function () {
- casper.test.assertExists("#download_zuliprc", "~/.zuliprc button exists");
- casper.click("#download_zuliprc");
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible('#download_zuliprc[href^="data:application"]', function () {
- casper.test.assertMatch(
- decodeURIComponent(casper.getElementsAttribute("#download_zuliprc", "href")),
- regex_zuliprc,
- "Looks like a zuliprc file"
- );
- });
-});
-
-casper.then(function () {
- casper.click("#api_key_modal .close");
-
- // casper.waitUntilVisible('#account-settings-status', function () {
- casper.click('[data-section="your-bots"]');
- // });
-});
-
-casper.then(function create_bot() {
- casper.test.info("Filling out the create bot form for an outgoing webhook bot");
-
- casper.fill("#create_bot_form", {
- bot_name: "Bot 1",
- bot_short_name: "1",
- bot_type: OUTGOING_WEBHOOK_BOT_TYPE,
- payload_url: "http://hostname.example.com/bots/followup",
- });
-
- casper.test.info("Submitting the create bot form");
- casper.click("#create_bot_button");
-});
-
-var bot_email = "[email protected]";
-var button_sel = '.download_bot_zuliprc[data-email="' + bot_email + '"]';
-
-casper.then(function () {
- casper.waitUntilVisible(button_sel, function () {
- casper.click(button_sel);
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible(button_sel + '[href^="data:application"]', function () {
- casper.test.assertMatch(
- decodeURIComponent(casper.getElementsAttribute(button_sel, "href")),
- regex_outgoing_webhook_zuliprc,
- "Looks like an outgoing webhook bot ~/.zuliprc file"
- );
- });
-});
-
-casper.then(function create_bot() {
- casper.test.info("Filling out the create bot form for a normal bot");
-
- casper.fill("#create_bot_form", {
- bot_name: "Bot 2",
- bot_short_name: "2",
- bot_type: GENERIC_BOT_TYPE,
- });
-
- casper.test.info("Submitting the create bot form");
- casper.click("#create_bot_button");
-});
-
-var second_bot_email = "[email protected]";
-var second_button_sel = '.download_bot_zuliprc[data-email="' + second_bot_email + '"]';
-
-casper.then(function () {
- casper.waitUntilVisible(second_button_sel, function () {
- casper.click(second_button_sel);
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible(second_button_sel + '[href^="data:application"]', function () {
- casper.test.assertMatch(
- decodeURIComponent(casper.getElementsAttribute(second_button_sel, "href")),
- regex_zuliprc,
- "Looks like a bot ~/.zuliprc file"
- );
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#download_botserverrc", function () {
- casper.click("#download_botserverrc");
-
- casper.waitUntilVisible('#download_botserverrc[href^="data:application"]', function () {
- casper.test.assertMatch(
- decodeURIComponent(casper.getElementsAttribute("#download_botserverrc", "href")),
- regex_botserverrc,
- "Looks like a botserverrc file"
- );
- });
- });
-});
-
-casper.then(function () {
- casper.waitUntilVisible(
- '.open_edit_bot_form[data-email="' + bot_email + '"]',
- function open_edit_bot_form() {
- casper.test.info("Opening edit bot form");
- casper.click('.open_edit_bot_form[data-email="' + bot_email + '"]');
- }
- );
-});
-
-casper.then(function () {
- casper.waitUntilVisible(
- '.edit_bot_form[data-email="' + bot_email + '"]',
- function test_edit_bot_form_values() {
- var form_sel = '.edit_bot_form[data-email="' + bot_email + '"]';
- casper.test.info("Testing edit bot form values");
-
- // casper.test.assertEqual(
- // common.get_form_field_value(form_sel + ' [name=bot_name]'),
- // 'Bot 1');
- // casper.test.assertEqual(
- // common.get_form_field_value(form_sel + ' [name=bot_default_sending_stream]'),
- // 'Denmark');
- // casper.test.assertEqual(
- // common.get_form_field_value(form_sel + ' [name=bot_default_events_register_stream]'),
- // 'Rome');
- casper.test.assertEqual(
- common.get_form_field_value(form_sel + " [name=bot_name]"),
- "Bot 1"
- );
- }
- );
-});
-
-casper.then(function () {
- casper.click('[data-section="alert-words"]');
- casper.waitUntilVisible("#create_alert_word_form", function () {
- casper.test.info("Attempting to submit an empty alert word");
- casper.click("#create_alert_word_button");
- casper.waitUntilVisible("#alert_word_status", function () {
- casper.test.info("Checking that an error is displayed");
- casper.test.assertSelectorHasText(
- ".alert_word_status_text",
- "Alert word can't be empty!"
- );
- casper.test.info("Closing the error message");
- casper.click(".close-alert-word-status");
- casper.test.info("Checking the error is hidden");
- casper.test.assertNotVisible("#alert_word_status");
- });
- });
-});
-
-casper.then(function () {
- casper.test.info("Filling out the alert word input");
- casper.sendKeys("#create_alert_word_name", "some phrase");
- casper.click("#create_alert_word_button");
- casper.test.info("Checking that a success message is displayed");
- casper.waitUntilVisible("#alert_word_status", function () {
- casper.test.assertSelectorHasText(
- ".alert_word_status_text",
- 'Alert word "some phrase" added successfully!'
- );
- casper.test.info("Closing the status message");
- casper.click(".close-alert-word-status");
- casper.test.info("Checking the status message is hidden");
- casper.test.assertNotVisible("#alert_word_status");
- });
-});
-
-casper.then(function () {
- casper.test.info("Checking that an element was created");
- casper.waitUntilVisible(".alert-word-item[data-word='some phrase']", function () {
- casper.test.assertExists("div.alert-word-information-box");
- casper.test.assertSelectorHasText("span.value", "some phrase");
- });
-});
-
-casper.then(function () {
- casper.test.info("Trying to create a duplicate alert word");
- casper.sendKeys("#create_alert_word_name", "some phrase");
- casper.click("#create_alert_word_button");
- casper.test.info("Checking that an error message is displayed");
- casper.waitUntilVisible("#alert_word_status", function () {
- casper.test.assertSelectorHasText(".alert_word_status_text", "Alert word already exists!");
- casper.test.info("Closing the status message");
- casper.click(".close-alert-word-status");
- casper.test.info("Checking the status message is hidden");
- casper.test.assertNotVisible("#alert_word_status");
- });
-});
-
-casper.then(function () {
- casper.test.info("Deleting alert word");
- casper.click("button.remove-alert-word[data-word='some phrase']");
- casper.test.info("Checking that a success message is displayed");
- casper.waitUntilVisible("#alert_word_status", function () {
- casper.test.assertSelectorHasText(
- ".alert_word_status_text",
- "Alert word removed successfully!"
- );
- casper.test.info("Closing the status message");
- casper.click(".close-alert-word-status");
- casper.test.info("Checking the status message is hidden");
- casper.test.assertNotVisible("#alert_word_status");
- });
- casper.test.info("Checking that the element was deleted");
- casper.waitWhileVisible(".alert-word-item[data-word='some phrase']", function () {
- casper.test.info("Element deleted successfully");
- });
-});
-
-casper.then(function change_default_language() {
- casper.test.info("Changing the default language");
- casper.click('[data-section="display-settings"]');
- casper.waitUntilVisible("#default_language");
-});
-
-casper.thenClick("#default_language");
-
-casper.waitUntilVisible("#default_language_modal");
-
-casper.thenClick('a[data-code="zh-hans"]');
-
-casper.waitUntilVisible("#language-settings-status a", function () {
- casper.test.assertSelectorHasText(
- "#language-settings-status",
- "Saved. Please reload for the change to take effect."
- );
- casper.test.info("Reloading the page.");
- casper.reload();
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#default_language", function () {
- casper.test.info("Checking if we are on Chinese page.");
- casper.test.assertEvalEquals(function () {
- return $("#default_language_name").text().trim();
- }, "简体中文");
- casper.test.info("Opening German page through i18n url.");
- });
-});
-
-var settings_url = "http://zulip.zulipdev.com:9981/de/#settings";
-
-casper.thenOpen(settings_url);
-
-casper.waitUntilVisible("#settings-change-box", function check_url_preference() {
- casper.test.info("Checking the i18n url language precedence.");
- casper.test.assertEvalEquals(function () {
- return document.documentElement.lang;
- }, "de");
- casper.test.info("English is now the default language");
- casper.click('[data-section="display-settings"]');
-});
-
-casper.thenClick("#default_language");
-
-casper.waitUntilVisible("#default_language_modal");
-
-casper.thenClick('a[data-code="en"]');
-
-/*
- * Changing the language back to English so that subsequent tests pass.
- */
-casper.waitUntilVisible("#language-settings-status a", function () {
- casper.test.assertSelectorHasText(
- "#language-settings-status",
- "Gespeichert. Bitte lade die Seite neu um die Änderungen zu aktivieren."
- );
-});
-
-casper.then(function () {
- casper.waitUntilVisible('[data-section="notifications"]', function () {
- casper.test.info("Testing disabled/enabled behavior for Notification sound");
- casper.click('[data-section="notifications"]');
- });
-});
-
-casper.then(function () {
- // At the beginning, `#enable_sounds` will be on and `#enable_stream_audible_notifications`
- // will be off by default.
- casper.test.assertVisible(
- "#notification_sound:enabled",
- "Notification sound selector is enabled"
- );
-
- casper.click("#enable_stream_audible_notifications");
- casper.test.assertVisible(
- "#notification_sound:enabled",
- "Notification sound selector is enabled"
- );
-
- casper.click("#enable_sounds");
- casper.test.assertVisible(
- "#notification_sound:enabled",
- "Notification sound selector is enabled"
- );
-
- casper.click("#enable_stream_audible_notifications");
- casper.test.assertVisible(
- "#notification_sound:disabled",
- "Notification sound selector is disabled"
- );
-});
-
-casper.thenOpen("http://zulip.zulipdev.com:9981/");
-
-// TODO: test the "Declare Zulip Bankruptcy option"
-
-common.then_log_out();
-
-casper.run(function () {
- casper.test.done();
-});
diff --git a/frontend_tests/casper_tests/07-stars.js b/frontend_tests/casper_tests/07-stars.js
deleted file mode 100644
index e3028116bc2..00000000000
--- a/frontend_tests/casper_tests/07-stars.js
+++ /dev/null
@@ -1,85 +0,0 @@
-"use strict";
-
-var common = require("../casper_lib/common.js");
-
-function star_count() {
- return casper.evaluate(function () {
- return $("#zhome .fa-star:not(.empty-star)").length;
- });
-}
-
-function toggle_test_star_message() {
- var error = casper.evaluate(function () {
- var msg = $('.message_content:contains("test star"):visible').last();
-
- if (msg.length !== 1) {
- return "cannot find test star message";
- }
-
- var star_icon = msg.closest(".messagebox").find(".star");
-
- if (star_icon.length !== 1) {
- return "cannot find star icon";
- }
-
- star_icon.trigger("click");
- });
-
- if (error) {
- casper.test.info("\n\nERROR: " + error);
- }
-
- casper.test.assert(!error);
-}
-
-common.start_and_log_in();
-
-casper.then(function () {
- casper.test.info("Sending test message");
-});
-
-common.then_send_message("stream", {
- stream: "Verona",
- subject: "stars",
- content: "test star",
-});
-
-casper.then(function () {
- common.wait_for_text("#zhome .message_row", "test star");
-});
-
-casper.then(function () {
- casper.test.info("Checking star counts");
-
- // Initially, no messages are starred.
- casper.test.assertEquals(star_count(), 0, "Got expected empty star count.");
-
- // Clicking on a message star stars it.
- toggle_test_star_message();
-});
-
-casper.then(function () {
- casper.waitUntilVisible("#zhome .fa-star", function () {
- casper.test.assertEquals(star_count(), 1, "Got expected single star count.");
-
- casper.click('a[href^="#narrow/is/starred"]');
- });
-});
-
-casper.waitUntilVisible("#zfilt", function () {
- // You can narrow to your starred messages.
- common.expected_messages("zfilt", ["Verona > stars"], ["<p>test star</p>"]);
- common.un_narrow();
-});
-
-casper.then(function () {
- // Clicking on a starred message unstars it.
- toggle_test_star_message();
- casper.test.assertEquals(star_count(), 0, "Got expected re-empty star count.");
-});
-
-common.then_log_out();
-
-casper.run(function () {
- casper.test.done();
-});
diff --git a/frontend_tests/casper_tests/08-edit.js b/frontend_tests/casper_tests/08-edit.js
deleted file mode 100644
index 2639e21d809..00000000000
--- a/frontend_tests/casper_tests/08-edit.js
+++ /dev/null
@@ -1,93 +0,0 @@
-"use strict";
-
-var common = require("../casper_lib/common.js");
-
-casper.options.verbose = true;
-casper.options.logLevel = "debug";
-
-common.start_and_log_in();
-
-function then_edit_last_message() {
- casper.then(function () {
- casper.evaluate(function () {
- var msg = $("#zhome .message_row").last();
- msg.find(".info").trigger("click");
- $(".popover_edit_message").trigger("click");
- });
- });
- casper.then(function () {
- casper.waitUntilVisible(".message_edit_content");
- });
-}
-
-// Send and edit a stream message
-
-common.then_send_message("stream", {
- stream: "Verona",
- subject: "edits",
- content: "test editing",
-});
-
-then_edit_last_message();
-
-casper.then(function () {
- casper.evaluate(function () {
- var msg = $("#zhome .message_row").last();
- msg.find(".message_edit_topic").val("edited");
- msg.find(".message_edit_content").val("test edited");
- msg.find(".message_edit_save").trigger("click");
- });
-});
-
-casper.waitWhileVisible("textarea.message_edit_content", function () {
- casper.test.assertSelectorHasText(".last_message .message_content", "test edited");
-});
-
-common.then_send_message("stream", {
- stream: "Verona",
- subject: "edits",
- content: "/me test editing one line with me",
-});
-
-then_edit_last_message();
-
-casper.then(function () {
- casper.evaluate(function () {
- var msg = $("#zhome .message_row").last();
- msg.find(".message_edit_topic").val("edited");
- msg.find(".message_edit_content").val("/me test edited one line with me");
- msg.find(".message_edit_save").trigger("click");
- });
-});
-
-casper.waitWhileVisible("textarea.message_edit_content", function () {
- casper.test.assertSelectorHasText(
- ".last_message .sender-status",
- "test edited one line with me"
- );
-});
-
-common.then_send_message("private", {
- recipient: "[email protected]",
- content: "test editing pm",
-});
-
-then_edit_last_message();
-
-casper.then(function () {
- casper.evaluate(function () {
- var msg = $("#zhome .message_row").last();
- msg.find(".message_edit_content").val("test edited pm");
- msg.find(".message_edit_save").trigger("click");
- });
-});
-
-casper.then(function () {
- casper.waitWhileVisible("textarea.message_edit_content", function () {
- casper.test.assertSelectorHasText(".last_message .message_content", "test edited pm");
- });
-});
-
-casper.run(function () {
- casper.test.done();
-});