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 () {
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.test.info('Subscriptions page');
|
|
|
|
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');
|
|
|
|
// subscriptions need to load; if they have *any* subs,
|
|
|
|
// the word "Unsubscribe" will appear
|
|
|
|
});
|
2014-03-07 20:58:18 +01:00
|
|
|
casper.waitForText('Subscribed', function () {
|
2013-11-08 10:12:05 +01:00
|
|
|
casper.test.assertTextExists('Subscribed', 'Initial subscriptions loaded');
|
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('Waseemio', function () {
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.test.assertTextExists('Create stream Waseemio', 'Modal for specifying new stream users');
|
|
|
|
casper.click('form#stream_creation_form button.btn.btn-primary');
|
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
|
|
|
});
|
|
|
|
});
|
2014-03-07 20:58:18 +01:00
|
|
|
|
2013-07-05 17:43:56 +02:00
|
|
|
casper.then(function () {
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.test.assertSelectorHasText('.subscription_name', 'Waseemio', 'Subscribing to a stream');
|
|
|
|
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');
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
2014-03-07 20:58:18 +01:00
|
|
|
casper.waitForText('Error adding subscription', function () {
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.test.assertTextExists('Error adding subscription', "Can't subscribe to an empty stream name");
|
|
|
|
});
|
|
|
|
|
|
|
|
common.then_log_out();
|
|
|
|
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|