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(
|
|
|
|
/^http:\/\/[^\/]+\/#subscriptions/,
|
|
|
|
'URL suggests we are on subscriptions page');
|
|
|
|
casper.test.assertExists('#subscriptions.tab-pane.active', 'Subscriptions page is active');
|
|
|
|
});
|
|
|
|
});
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
2016-10-07 19:05:59 +02:00
|
|
|
|
2016-06-13 22:06:12 +02:00
|
|
|
casper.waitForSelector('.sub_unsub_button.subscribed-button', function () {
|
2013-11-08 10:12:05 +01:00
|
|
|
casper.test.assertTextExists('Subscribed', 'Initial subscriptions loaded');
|
2014-03-05 22:28:57 +01:00
|
|
|
casper.click('form#add_new_subscription input.btn');
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
2016-10-12 08:53:57 +02:00
|
|
|
casper.waitForSelector('#create_stream_button', function () {
|
|
|
|
casper.test.assertTextExists('Create stream', 'Modal for specifying new stream users');
|
|
|
|
casper.fill('form#stream_creation_form', {stream_name: 'Waseemio'});
|
|
|
|
casper.click('form#stream_creation_form button.btn.btn-primary');
|
2016-07-07 00:58:11 +02:00
|
|
|
});
|
|
|
|
casper.then(function () {
|
2016-08-23 22:23:56 +02:00
|
|
|
casper.test.assertExists('#user-checkboxes [data-name="cordelia@zulip.com"]', 'Original user list contains Cordelia');
|
|
|
|
casper.test.assertExists('#user-checkboxes [data-name="hamlet@zulip.com"]', 'Original user list contains King Hamlet');
|
2016-07-07 00:58:11 +02:00
|
|
|
});
|
|
|
|
casper.then(function () {
|
|
|
|
casper.test.info("Filtering user list with keyword 'cor'");
|
|
|
|
casper.fill('form#stream_creation_form', {user_list_filter: 'cor'});
|
|
|
|
});
|
|
|
|
casper.then(function () {
|
2016-08-23 22:23:56 +02:00
|
|
|
casper.test.assertEquals(casper.visible('#user-checkboxes [data-name="cordelia@zulip.com"]'),
|
2016-07-07 00:58:11 +02:00
|
|
|
true,
|
|
|
|
"Cordelia is visible"
|
|
|
|
);
|
2016-08-23 22:23:56 +02:00
|
|
|
casper.test.assertEquals(casper.visible('#user-checkboxes [data-name="hamlet@zulip.com"]'),
|
2016-07-07 00:58:11 +02:00
|
|
|
false,
|
|
|
|
"King Hamlet is not visible"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
casper.then(function () {
|
|
|
|
casper.test.info("Clearing user filter search box");
|
|
|
|
casper.fill('form#stream_creation_form', {user_list_filter: ''});
|
|
|
|
});
|
|
|
|
casper.then(function () {
|
2016-08-23 22:23:56 +02:00
|
|
|
casper.test.assertEquals(casper.visible('#user-checkboxes [data-name="cordelia@zulip.com"]'),
|
2016-07-07 00:58:11 +02:00
|
|
|
true,
|
|
|
|
"Cordelia is visible again"
|
|
|
|
);
|
2016-08-23 22:23:56 +02:00
|
|
|
casper.test.assertEquals(casper.visible('#user-checkboxes [data-name="hamlet@zulip.com"]'),
|
2016-07-07 00:58:11 +02:00
|
|
|
true,
|
|
|
|
"King Hamlet is visible again"
|
|
|
|
);
|
|
|
|
});
|
2014-03-07 20:58:18 +01:00
|
|
|
casper.waitFor(function () {
|
|
|
|
return casper.evaluate(function () {
|
|
|
|
return $('.subscription_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");
|
|
|
|
casper.test.assertSelectorHasText('.subscription_name', 'Waseemio');
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.fill('form#add_new_subscription', {stream_name: 'WASeemio'});
|
2014-03-05 22:28:57 +01:00
|
|
|
casper.click('form#add_new_subscription input.btn');
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
2014-03-07 20:58:18 +01:00
|
|
|
casper.waitForText('Already subscribed', function () {
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.test.assertTextExists('Already subscribed', "Can't subscribe twice to a stream");
|
|
|
|
casper.fill('form#add_new_subscription', {stream_name: ' '});
|
2014-03-05 22:28:57 +01:00
|
|
|
casper.click('form#add_new_subscription input.btn');
|
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: ' '});
|
|
|
|
casper.click('form#add_new_subscription input.btn');
|
|
|
|
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-10-12 09:45:25 +02:00
|
|
|
casper.waitForText('Filter by stream name', function () {
|
2016-10-28 23:25:00 +02:00
|
|
|
casper.test.assertSelectorHasText('.stream-row .subscription_name', 'Verona', 'Verona stream exists before filtering');
|
|
|
|
casper.test.assertSelectorDoesntHaveText('.stream-row.notdisplayed .subscription_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:25:00 +02:00
|
|
|
casper.test.assertSelectorHasText('.stream-row.notdisplayed .subscription_name', 'Verona', 'Verona stream not shown after filtering');
|
|
|
|
casper.test.assertSelectorHasText('.stream-row .subscription_name', 'Waseemio', 'Waseemio stream exists after filtering');
|
|
|
|
casper.test.assertSelectorDoesntHaveText('.stream-row.notdisplayed .subscription_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();
|
|
|
|
});
|