2015-10-14 00:21:23 +02:00
|
|
|
var common = require('../casper_lib/common.js').common;
|
2013-03-20 22:38:20 +01:00
|
|
|
|
|
|
|
common.start_and_log_in();
|
|
|
|
|
2013-07-05 17:43:56 +02:00
|
|
|
casper.then(function () {
|
2016-10-07 19:05:59 +02:00
|
|
|
var menu_selector = '#settings-dropdown';
|
|
|
|
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.test.info('Subscriptions page');
|
2016-10-07 19:05:59 +02:00
|
|
|
|
|
|
|
casper.waitUntilVisible(menu_selector, function () {
|
|
|
|
casper.click(menu_selector);
|
|
|
|
casper.then(function () {
|
|
|
|
casper.click('a[href^="#subscriptions"]');
|
|
|
|
casper.test.assertUrlMatch(
|
2016-12-06 19:57:46 +01:00
|
|
|
/^http:\/\/[^/]+\/#subscriptions/,
|
2016-10-07 19:05:59 +02:00
|
|
|
'URL suggests we are on subscriptions page');
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.waitUntilVisible('#subscription_overlay.new-style', function () {
|
|
|
|
casper.test.assertExists('#subscription_overlay.new-style', 'Subscriptions page is active');
|
|
|
|
});
|
2016-10-07 19:05:59 +02:00
|
|
|
});
|
|
|
|
});
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
2016-10-07 19:05:59 +02:00
|
|
|
|
2016-10-29 01:58:22 +02:00
|
|
|
casper.waitForSelector('.sub_unsub_button.checked', function () {
|
|
|
|
casper.test.assertExists('.sub_unsub_button.checked', 'Initial subscriptions loaded');
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.click('#create_stream_button');
|
2016-07-07 00:58:11 +02:00
|
|
|
});
|
2016-11-01 22:32:10 +01:00
|
|
|
|
2016-07-07 00:58:11 +02:00
|
|
|
casper.then(function () {
|
2017-01-07 07:58:08 +01:00
|
|
|
casper.test.assertExists('#user-checkboxes [data-email="cordelia@zulip.com"]', 'Original user list contains Cordelia');
|
|
|
|
casper.test.assertExists('#user-checkboxes [data-email="othello@zulip.com"]', 'Original user list contains Othello');
|
2016-07-07 00:58:11 +02:00
|
|
|
});
|
2016-12-17 19:28:51 +01:00
|
|
|
|
|
|
|
casper.waitForSelector("#copy-from-stream-expand-collapse", function () {
|
|
|
|
casper.click('#copy-from-stream-expand-collapse');
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible("#stream-checkboxes", function () {
|
|
|
|
casper.test.assertExists('#stream-checkboxes [data-name="Scotland"]', 'Original stream list contains Scotland');
|
|
|
|
casper.test.assertExists('#stream-checkboxes [data-name="Rome"]', 'Original stream list contains Rome');
|
|
|
|
});
|
|
|
|
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.waitForSelector("form#stream_creation_form", function () {
|
2016-12-17 19:28:51 +01:00
|
|
|
casper.test.info("Filtering with keyword 'ot'");
|
|
|
|
casper.fill('form#stream_creation_form', {user_list_filter: 'ot'});
|
2016-07-07 00:58:11 +02:00
|
|
|
});
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.waitForSelector(".subscriber-list", function () {
|
2017-01-07 07:58:08 +01:00
|
|
|
casper.test.assertEquals(casper.visible('#user-checkboxes [data-email="cordelia@zulip.com"]'),
|
2016-12-17 19:28:51 +01:00
|
|
|
false,
|
|
|
|
"Cordelia is not visible"
|
|
|
|
);
|
2017-01-07 07:58:08 +01:00
|
|
|
casper.test.assertEquals(casper.visible('#user-checkboxes [data-email="othello@zulip.com"]'),
|
2016-07-07 00:58:11 +02:00
|
|
|
true,
|
2016-12-17 19:28:51 +01:00
|
|
|
"Othello is visible"
|
2016-07-07 00:58:11 +02:00
|
|
|
);
|
2016-12-17 19:28:51 +01:00
|
|
|
casper.test.assertEquals(casper.visible('#stream-checkboxes [data-name="Scotland"]'),
|
|
|
|
true,
|
|
|
|
"Scotland is visible"
|
|
|
|
);
|
|
|
|
casper.test.assertEquals(casper.visible('#stream-checkboxes [data-name="Rome"]'),
|
2016-07-07 00:58:11 +02:00
|
|
|
false,
|
2016-12-17 19:28:51 +01:00
|
|
|
"Rome is not visible"
|
2016-07-07 00:58:11 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
casper.then(function () {
|
|
|
|
casper.test.info("Clearing user filter search box");
|
|
|
|
casper.fill('form#stream_creation_form', {user_list_filter: ''});
|
|
|
|
});
|
|
|
|
casper.then(function () {
|
2017-01-07 07:58:08 +01:00
|
|
|
casper.test.assertEquals(casper.visible('#user-checkboxes [data-email="cordelia@zulip.com"]'),
|
2016-07-07 00:58:11 +02:00
|
|
|
true,
|
|
|
|
"Cordelia is visible again"
|
|
|
|
);
|
2017-01-07 07:58:08 +01:00
|
|
|
casper.test.assertEquals(casper.visible('#user-checkboxes [data-email="othello@zulip.com"]'),
|
2016-12-17 19:28:51 +01:00
|
|
|
true,
|
|
|
|
"Othello is visible again"
|
|
|
|
);
|
|
|
|
casper.test.assertEquals(casper.visible('#stream-checkboxes [data-name="Scotland"]'),
|
2016-07-07 00:58:11 +02:00
|
|
|
true,
|
2016-12-17 19:28:51 +01:00
|
|
|
"Scotland is visible again"
|
|
|
|
);
|
|
|
|
casper.test.assertEquals(casper.visible('#stream-checkboxes [data-name="Rome"]'),
|
|
|
|
true,
|
|
|
|
"Rome is visible again"
|
2016-07-07 00:58:11 +02:00
|
|
|
);
|
|
|
|
});
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.waitForSelector('#stream_creation_form', function () {
|
2016-12-17 19:28:51 +01:00
|
|
|
casper.test.assertTextExists('Add New Stream', 'New stream creation panel');
|
|
|
|
casper.fill('form#stream_creation_form', {stream_name: 'Waseemio', stream_description: 'Oimeesaw'});
|
|
|
|
casper.click('input[value="Scotland"] ~ span');
|
|
|
|
casper.click('input[value="cordelia@zulip.com"] ~ span');
|
|
|
|
casper.click('input[value="othello@zulip.com"] ~ span');
|
|
|
|
casper.click('form#stream_creation_form button.btn.btn-primary');
|
2016-11-01 22:32:10 +01:00
|
|
|
});
|
|
|
|
|
2014-03-07 20:58:18 +01:00
|
|
|
casper.waitFor(function () {
|
|
|
|
return casper.evaluate(function () {
|
2016-10-28 23:27:02 +02:00
|
|
|
return $('.stream-name').is(':contains("Waseemio")');
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
|
|
|
});
|
2013-07-05 17:43:56 +02:00
|
|
|
casper.then(function () {
|
2016-10-12 09:45:25 +02:00
|
|
|
casper.test.info("User should be subscribed to stream Waseemio");
|
2016-10-28 23:27:02 +02:00
|
|
|
casper.test.assertSelectorHasText('.stream-name', 'Waseemio');
|
2016-11-27 15:31:53 +01:00
|
|
|
casper.test.assertSelectorHasText('.description', 'Oimeesaw');
|
2016-12-17 19:28:51 +01:00
|
|
|
// Based on the selected checkboxes while creating stream,
|
|
|
|
// 4 users from Scotland are added.
|
|
|
|
// 1 user, Cordelia, is added. Othello (subscribed to Scotland) is not added twice.
|
|
|
|
casper.test.assertSelectorHasText('.subscriber-count-text', '5');
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.fill('form#add_new_subscription', {stream_name: 'WASeemio'});
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.click('#create_stream_button');
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.then(function () {
|
|
|
|
casper.click('#create_stream_button');
|
2016-10-12 08:53:57 +02:00
|
|
|
casper.fill('form#stream_creation_form', {stream_name: ' '});
|
|
|
|
casper.click('form#stream_creation_form button.btn.btn-primary');
|
|
|
|
});
|
2016-10-12 09:45:25 +02:00
|
|
|
casper.waitForText('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.btn.btn-default');
|
|
|
|
casper.fill('form#add_new_subscription', {stream_name: ' '});
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.click('#create_stream_button');
|
2016-10-12 09:45:25 +02:00
|
|
|
casper.fill('form#stream_creation_form', {stream_name: 'Waseemio'});
|
|
|
|
casper.click('form#stream_creation_form button.btn.btn-primary');
|
2016-10-12 08:53:57 +02:00
|
|
|
});
|
2016-10-12 09:45:25 +02:00
|
|
|
casper.waitForText('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");
|
2016-10-12 08:53:57 +02:00
|
|
|
casper.test.info('Streams should be filtered when typing in the create box');
|
2016-10-12 09:45:25 +02:00
|
|
|
casper.click('form#stream_creation_form button.btn.btn-default');
|
2016-10-12 08:53:57 +02:00
|
|
|
});
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.waitForText('Filter Streams', function () {
|
2016-10-29 00:13:19 +02:00
|
|
|
casper.test.assertSelectorHasText('.stream-row[data-stream-name="Verona"] .stream-name', 'Verona', 'Verona stream exists before filtering');
|
2016-10-28 23:27:02 +02:00
|
|
|
casper.test.assertSelectorDoesntHaveText('.stream-row.notdisplayed .stream-name', 'Verona', 'Verona stream shown before filtering');
|
2016-10-12 08:53:57 +02:00
|
|
|
});
|
|
|
|
casper.then(function () {
|
|
|
|
casper.fill('form#add_new_subscription', {stream_name: 'was'});
|
|
|
|
casper.evaluate(function () {
|
|
|
|
$('#add_new_subscription input[type="text"]').expectOne()
|
|
|
|
.trigger($.Event('input'));
|
|
|
|
});
|
|
|
|
});
|
2016-10-12 09:45:25 +02:00
|
|
|
casper.waitForSelectorTextChange('form#add_new_subscription', function () {
|
2016-10-28 23:27:02 +02:00
|
|
|
casper.test.assertSelectorHasText('.stream-row.notdisplayed .stream-name', 'Verona', 'Verona stream not shown after filtering');
|
|
|
|
casper.test.assertSelectorHasText('.stream-row .stream-name', 'Waseemio', 'Waseemio stream exists after filtering');
|
|
|
|
casper.test.assertSelectorDoesntHaveText('.stream-row.notdisplayed .stream-name', 'Waseemio', 'Waseemio stream shown after filtering');
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
common.then_log_out();
|
|
|
|
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|