2019-10-25 09:45:13 +02:00
|
|
|
var common = require('../casper_lib/common.js');
|
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';
|
|
|
|
|
2017-03-09 00:20:22 +01:00
|
|
|
casper.test.info('Streams page');
|
2016-10-07 19:05:59 +02:00
|
|
|
|
|
|
|
casper.waitUntilVisible(menu_selector, function () {
|
|
|
|
casper.click(menu_selector);
|
|
|
|
casper.then(function () {
|
2017-03-09 00:20:22 +01:00
|
|
|
casper.click('a[href^="#streams"]');
|
2016-10-07 19:05:59 +02:00
|
|
|
casper.test.assertUrlMatch(
|
2017-03-09 00:20:22 +01:00
|
|
|
/^http:\/\/[^/]+\/#streams/,
|
|
|
|
'URL suggests we are on streams page');
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.waitUntilVisible('#subscription_overlay.new-style', function () {
|
2017-03-09 00:20:22 +01:00
|
|
|
casper.test.assertExists('#subscription_overlay.new-style', 'Streams page is active');
|
2016-11-01 22:32:10 +01:00
|
|
|
});
|
2016-10-07 19:05:59 +02:00
|
|
|
});
|
|
|
|
});
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
2016-10-07 19:05:59 +02:00
|
|
|
|
2017-02-10 07:57:28 +01:00
|
|
|
casper.waitUntilVisible('.sub_unsub_button.checked', function () {
|
2016-10-29 01:58:22 +02:00
|
|
|
casper.test.assertExists('.sub_unsub_button.checked', 'Initial subscriptions loaded');
|
2017-09-29 19:20:44 +02:00
|
|
|
casper.click('#add_new_subscription .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
|
|
|
|
2017-02-10 07:57:28 +01:00
|
|
|
casper.waitUntilVisible("#copy-from-stream-expand-collapse", function () {
|
2016-12-17 19:28:51 +01:00
|
|
|
casper.click('#copy-from-stream-expand-collapse');
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible("#stream-checkboxes", function () {
|
2017-01-07 08:03:28 +01:00
|
|
|
casper.test.assertExists('#stream-checkboxes [data-stream-name="Scotland"]', 'Original stream list contains Scotland');
|
|
|
|
casper.test.assertExists('#stream-checkboxes [data-stream-name="Rome"]', 'Original stream list contains Rome');
|
2016-12-17 19:28:51 +01:00
|
|
|
});
|
|
|
|
|
2017-02-10 07:57:28 +01:00
|
|
|
casper.waitUntilVisible("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
|
|
|
});
|
2017-02-10 07:57:28 +01:00
|
|
|
casper.waitUntilVisible("#user-checkboxes", 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,
|
2017-01-11 23:47:14 +01:00
|
|
|
"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,
|
2017-01-11 23:47:14 +01:00
|
|
|
"Othello is visible");
|
2017-01-26 16:06:21 +01:00
|
|
|
|
|
|
|
/* The filter should not impact streams */
|
2017-01-07 08:03:28 +01:00
|
|
|
casper.test.assertEquals(casper.visible('#stream-checkboxes [data-stream-name="Scotland"]'),
|
2016-12-17 19:28:51 +01:00
|
|
|
true,
|
2017-01-11 23:47:14 +01:00
|
|
|
"Scotland is visible");
|
2017-01-07 08:03:28 +01:00
|
|
|
casper.test.assertEquals(casper.visible('#stream-checkboxes [data-stream-name="Rome"]'),
|
2017-01-26 16:06:21 +01:00
|
|
|
true,
|
|
|
|
"Rome is visible");
|
2016-07-07 00:58:11 +02:00
|
|
|
});
|
2017-01-12 21:41:14 +01:00
|
|
|
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(casper.evaluate(function () {
|
|
|
|
return !$('#user-checkboxes [value="cordelia@zulip.com"]')[0].checked;
|
|
|
|
}), "Cordelia is unchecked");
|
|
|
|
casper.test.assert(casper.evaluate(function () {
|
|
|
|
return $('#user-checkboxes [value="othello@zulip.com"]')[0].checked;
|
|
|
|
}), "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(casper.evaluate(function () {
|
|
|
|
return !$('#user-checkboxes [value="othello@zulip.com"]')[0].checked;
|
|
|
|
}), "Othello is unchecked");
|
|
|
|
});
|
|
|
|
});
|
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,
|
2017-01-11 23:47:14 +01:00
|
|
|
"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,
|
2017-01-11 23:47:14 +01:00
|
|
|
"Othello is visible again");
|
2017-01-07 08:03:28 +01:00
|
|
|
casper.test.assertEquals(casper.visible('#stream-checkboxes [data-stream-name="Scotland"]'),
|
2016-07-07 00:58:11 +02:00
|
|
|
true,
|
2017-01-11 23:47:14 +01:00
|
|
|
"Scotland is visible again");
|
2017-01-07 08:03:28 +01:00
|
|
|
casper.test.assertEquals(casper.visible('#stream-checkboxes [data-stream-name="Rome"]'),
|
2016-12-17 19:28:51 +01:00
|
|
|
true,
|
2017-01-11 23:47:14 +01:00
|
|
|
"Rome is visible again");
|
2016-07-07 00:58:11 +02:00
|
|
|
});
|
2017-03-21 07:21:38 +01:00
|
|
|
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('input[value="Scotland"] ~ span');
|
|
|
|
casper.click('input[value="cordelia@zulip.com"] ~ span');
|
|
|
|
casper.click('input[value="othello@zulip.com"] ~ span');
|
2017-09-29 19:20:44 +02:00
|
|
|
casper.click('form#stream_creation_form button.button.sea-green');
|
2017-03-21 07:21:38 +01:00
|
|
|
});
|
2016-11-01 22:32:10 +01:00
|
|
|
});
|
|
|
|
|
2017-03-21 07:21:38 +01:00
|
|
|
casper.then(function () {
|
|
|
|
casper.waitFor(function () {
|
|
|
|
return casper.evaluate(function () {
|
|
|
|
return $('.stream-name').is(':contains("Waseemio")');
|
|
|
|
});
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
|
|
|
});
|
2017-03-21 07:21:38 +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'});
|
2017-09-29 19:20:44 +02:00
|
|
|
casper.click('#add_new_subscription .create_stream_button');
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
2016-11-01 22:32:10 +01:00
|
|
|
casper.then(function () {
|
2017-09-29 19:20:44 +02:00
|
|
|
casper.click('#add_new_subscription .create_stream_button');
|
2016-10-12 08:53:57 +02:00
|
|
|
casper.fill('form#stream_creation_form', {stream_name: ' '});
|
2017-09-29 19:20:44 +02:00
|
|
|
casper.click('form#stream_creation_form button.button.sea-green');
|
2016-10-12 08:53:57 +02:00
|
|
|
});
|
2017-06-07 09:33:25 +02:00
|
|
|
casper.then(function () {
|
|
|
|
casper.waitForSelectorText('#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");
|
2017-09-29 19:20:44 +02:00
|
|
|
casper.click('form#stream_creation_form button.button.white');
|
2017-06-07 09:33:25 +02:00
|
|
|
casper.fill('form#add_new_subscription', {stream_name: ' '});
|
2017-09-29 19:20:44 +02:00
|
|
|
casper.click('#add_new_subscription .create_stream_button');
|
2017-06-07 09:33:25 +02:00
|
|
|
casper.fill('form#stream_creation_form', {stream_name: 'Waseemio'});
|
2017-09-29 19:20:44 +02:00
|
|
|
casper.click('form#stream_creation_form button.button.sea-green');
|
2017-06-07 09:33:25 +02:00
|
|
|
});
|
2016-10-12 08:53:57 +02:00
|
|
|
});
|
2017-06-07 09:33:25 +02:00
|
|
|
casper.then(function () {
|
|
|
|
casper.waitForSelectorText('#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');
|
2017-09-29 19:20:44 +02:00
|
|
|
casper.click('form#stream_creation_form button.button.white');
|
2017-06-07 09:33:25 +02:00
|
|
|
});
|
2016-10-12 08:53:57 +02:00
|
|
|
});
|
2017-06-07 09:33:25 +02:00
|
|
|
casper.then(function () {
|
|
|
|
casper.waitForSelectorText('#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');
|
|
|
|
});
|
2016-10-12 08:53:57 +02:00
|
|
|
});
|
|
|
|
casper.then(function () {
|
|
|
|
casper.fill('form#add_new_subscription', {stream_name: 'was'});
|
|
|
|
casper.evaluate(function () {
|
2018-05-07 01:42:17 +02:00
|
|
|
$('#add_new_subscription input[type="text"]').expectOne()
|
|
|
|
.trigger($.Event('input'));
|
2016-10-12 08:53:57 +02:00
|
|
|
});
|
|
|
|
});
|
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();
|
|
|
|
});
|