"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: "cordelia@zulip.com, hamlet@zulip.com", content: "personal A"}, {recipient: "cordelia@zulip.com, hamlet@zulip.com", content: "personal B"}, {recipient: "cordelia@zulip.com", 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", ], [ "
test verona A
", "test verona B
", "test verona C
", "personal A
", "personal B
", "personal C
", ] ); casper.test.info("Sending more messages"); }); common.then_send_many([ {stream: "Verona", subject: "frontend test", content: "test verona D"}, {recipient: "cordelia@zulip.com, hamlet@zulip.com", content: "personal D"}, ]); common.then_log_out(); // Run the above queued actions. casper.run(function () { casper.test.done(); });