2012-11-09 00:44:00 +01:00
|
|
|
/* 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 http://casperjs.org/api.html#utils
|
|
|
|
// For example, utils.dump() prints an Object with nice formatting.
|
|
|
|
var utils = require('utils');
|
|
|
|
|
2015-10-14 00:21:23 +02:00
|
|
|
var common = require('../casper_lib/common.js').common;
|
2013-03-05 17:05:12 +01:00
|
|
|
|
2013-03-05 20:52:54 +01:00
|
|
|
common.start_and_log_in();
|
2012-11-09 00:44:00 +01:00
|
|
|
|
2013-03-05 16:32:55 +01:00
|
|
|
casper.then(function () {
|
2012-11-09 00:44:00 +01:00
|
|
|
casper.test.info('Sanity-checking existing messages');
|
|
|
|
|
2013-03-20 23:59:44 +01:00
|
|
|
var msg = common.get_rendered_messages('zhome');
|
2012-11-09 00:44:00 +01:00
|
|
|
|
|
|
|
msg.headings.forEach(function (heading) {
|
2013-03-20 23:59:44 +01:00
|
|
|
casper.test.assertMatch(common.normalize_spaces(heading),
|
2013-05-10 22:48:02 +02:00
|
|
|
/(^You and )|( )/,
|
2012-11-09 00:44:00 +01:00
|
|
|
'Heading is well-formed');
|
|
|
|
});
|
|
|
|
|
|
|
|
msg.bodies.forEach(function (body) {
|
|
|
|
casper.test.assertMatch(body,
|
|
|
|
/^(<p>(.|\n)*<\/p>)?$/,
|
|
|
|
'Body is well-formed');
|
|
|
|
});
|
|
|
|
|
2013-03-18 18:40:47 +01:00
|
|
|
casper.test.info('Sending messages');
|
2013-03-12 16:05:46 +01:00
|
|
|
});
|
|
|
|
|
2013-03-21 17:46:52 +01:00
|
|
|
// Send some messages.
|
2012-11-09 00:44:00 +01:00
|
|
|
|
2014-03-07 20:59:30 +01:00
|
|
|
common.then_send_many([
|
2013-03-21 17:46:52 +01:00
|
|
|
{ stream: 'Verona', subject: 'frontend test',
|
2016-09-30 14:20:01 +02:00
|
|
|
content: 'test verona A' },
|
2012-11-09 00:44:00 +01:00
|
|
|
|
2013-03-21 17:46:52 +01:00
|
|
|
{ stream: 'Verona', subject: 'frontend test',
|
2016-09-30 14:20:01 +02:00
|
|
|
content: 'test verona B' },
|
2012-11-09 00:44:00 +01:00
|
|
|
|
2013-03-21 17:46:52 +01:00
|
|
|
{ stream: 'Verona', subject: 'other subject',
|
2016-09-30 14:20:01 +02:00
|
|
|
content: 'test verona C' },
|
2012-11-09 00:44:00 +01:00
|
|
|
|
2013-07-24 20:41:09 +02:00
|
|
|
{ recipient: 'cordelia@zulip.com, hamlet@zulip.com',
|
2013-03-21 17:46:52 +01:00
|
|
|
content: 'personal A' },
|
2012-11-09 00:44:00 +01:00
|
|
|
|
2013-07-24 20:41:09 +02:00
|
|
|
{ recipient: 'cordelia@zulip.com, hamlet@zulip.com',
|
2013-03-21 17:46:52 +01:00
|
|
|
content: 'personal B' },
|
|
|
|
|
2013-07-24 20:41:09 +02:00
|
|
|
{ recipient: 'cordelia@zulip.com',
|
2013-03-21 17:46:52 +01:00
|
|
|
content: 'personal C' }]);
|
2012-11-09 00:44:00 +01:00
|
|
|
|
2013-03-20 23:59:44 +01:00
|
|
|
common.wait_for_receive(function () {
|
|
|
|
common.expected_messages('zhome', [
|
2013-07-17 22:53:07 +02:00
|
|
|
'Verona > frontend test',
|
|
|
|
'Verona > other subject',
|
2012-11-09 00:44:00 +01:00
|
|
|
'You and Cordelia Lear, King Hamlet',
|
|
|
|
'You and Cordelia Lear'
|
|
|
|
], [
|
2016-09-30 14:20:01 +02:00
|
|
|
'<p>test verona A</p>',
|
|
|
|
'<p>test verona B</p>',
|
|
|
|
'<p>test verona C</p>',
|
2012-11-09 00:44:00 +01:00
|
|
|
'<p>personal A</p>',
|
|
|
|
'<p>personal B</p>',
|
|
|
|
'<p>personal C</p>'
|
|
|
|
]);
|
|
|
|
|
|
|
|
casper.test.info('Sending more messages');
|
|
|
|
});
|
|
|
|
|
2014-03-07 20:59:30 +01:00
|
|
|
common.then_send_many([
|
2013-03-21 17:46:52 +01:00
|
|
|
{ stream: 'Verona', subject: 'frontend test',
|
2016-09-30 14:20:01 +02:00
|
|
|
content: 'test verona D' },
|
2013-03-21 17:46:52 +01:00
|
|
|
|
2013-07-24 20:41:09 +02:00
|
|
|
{ recipient: 'cordelia@zulip.com, hamlet@zulip.com',
|
2013-03-21 17:46:52 +01:00
|
|
|
content: 'personal D' }
|
|
|
|
]);
|
2012-11-09 00:44:00 +01:00
|
|
|
|
2013-03-05 20:52:54 +01:00
|
|
|
common.then_log_out();
|
2013-03-05 17:05:12 +01:00
|
|
|
|
2012-11-09 00:44:00 +01:00
|
|
|
// Run the above queued actions.
|
|
|
|
casper.run(function () {
|
2012-12-07 17:11:12 +01:00
|
|
|
casper.test.done();
|
2012-11-09 00:44:00 +01:00
|
|
|
});
|