2015-10-14 00:21:23 +02:00
|
|
|
var common = require('../casper_lib/common.js').common;
|
|
|
|
var test_credentials = require('../casper_lib/test_credentials.js').test_credentials;
|
2013-03-20 22:38:20 +01:00
|
|
|
|
|
|
|
common.start_and_log_in();
|
|
|
|
|
2013-06-12 17:38:13 +02:00
|
|
|
var form_sel = 'form[action^="/json/settings/change"]';
|
|
|
|
|
2013-07-05 17:43:56 +02:00
|
|
|
casper.then(function () {
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.test.info('Settings page');
|
|
|
|
casper.click('a[href^="#settings"]');
|
2016-06-10 09:03:36 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitForSelector("#settings-change-box", function () {
|
2013-03-20 22:38:20 +01:00
|
|
|
casper.test.assertUrlMatch(/^http:\/\/[^\/]+\/#settings/, 'URL suggests we are on settings page');
|
|
|
|
casper.test.assertExists('#settings.tab-pane.active', 'Settings page is active');
|
2013-06-12 17:38:13 +02:00
|
|
|
|
|
|
|
casper.test.assertNotVisible("#old_password");
|
|
|
|
|
|
|
|
casper.click(".change_password_button");
|
|
|
|
});
|
|
|
|
|
2013-07-05 17:43:56 +02:00
|
|
|
casper.waitUntilVisible("#old_password", function () {
|
2016-06-04 02:19:07 +02:00
|
|
|
casper.waitForResource("zxcvbn.js", function () {
|
|
|
|
casper.test.assertVisible("#old_password");
|
|
|
|
casper.test.assertVisible("#new_password");
|
|
|
|
casper.test.assertVisible("#confirm_password");
|
|
|
|
|
|
|
|
casper.test.assertEqual(casper.getFormValues(form_sel).full_name, "Iago");
|
|
|
|
|
|
|
|
casper.fill(form_sel, {
|
|
|
|
"full_name": "IagoNew",
|
|
|
|
"old_password": test_credentials.default_user.password,
|
|
|
|
"new_password": "qwertyuiop",
|
|
|
|
"confirm_password": "qwertyuiop"
|
|
|
|
});
|
|
|
|
casper.click('input[name="change_settings"]');
|
2013-06-12 17:38:13 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible('#settings-status', function () {
|
|
|
|
casper.test.assertSelectorHasText('#settings-status', 'Updated settings!');
|
|
|
|
|
|
|
|
casper.click('#api_key_button');
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible('#get_api_key_password', function () {
|
|
|
|
casper.fill('form[action^="/json/fetch_api_key"]', {'password':'qwertyuiop'});
|
|
|
|
casper.click('input[name="view_api_key"]');
|
2013-03-20 22:38:20 +01:00
|
|
|
});
|
|
|
|
|
2013-06-12 17:38:13 +02:00
|
|
|
casper.waitUntilVisible('#api_key_value', function () {
|
|
|
|
casper.test.assertMatch(casper.fetchText('#api_key_value'), /[a-zA-Z0-9]{32}/, "Looks like an API key");
|
|
|
|
|
|
|
|
// Change it all back so the next test can still log in
|
|
|
|
casper.fill(form_sel, {
|
|
|
|
"full_name": "Iago",
|
|
|
|
"old_password": "qwertyuiop",
|
2015-08-20 02:57:30 +02:00
|
|
|
"new_password": test_credentials.default_user.password,
|
|
|
|
"confirm_password": test_credentials.default_user.password
|
2013-06-12 17:38:13 +02:00
|
|
|
});
|
|
|
|
casper.click('input[name="change_settings"]');
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.waitUntilVisible('#settings-status', function () {
|
|
|
|
casper.test.assertSelectorHasText('#settings-status', 'Updated settings!');
|
|
|
|
});
|
|
|
|
|
2014-02-19 16:07:28 +01:00
|
|
|
|
|
|
|
casper.then(function create_bot() {
|
|
|
|
casper.test.info('Filling out the create bot form');
|
|
|
|
|
|
|
|
casper.fill('#create_bot_form',{
|
|
|
|
bot_name: 'Bot 1',
|
|
|
|
bot_short_name: '1',
|
|
|
|
bot_default_sending_stream: 'Denmark',
|
|
|
|
bot_default_events_register_stream: 'Rome'
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.test.info('Submiting the create bot form');
|
|
|
|
casper.click('#create_bot_button');
|
|
|
|
});
|
|
|
|
|
2015-08-21 22:26:41 +02:00
|
|
|
casper.waitUntilVisible('.open_edit_bot_form[data-email="1-bot@zulip.com"]', function open_edit_bot_form() {
|
2014-02-19 16:07:28 +01:00
|
|
|
casper.test.info('Opening edit bot form');
|
2015-08-21 22:26:41 +02:00
|
|
|
casper.click('.open_edit_bot_form[data-email="1-bot@zulip.com"]');
|
2014-02-19 16:07:28 +01:00
|
|
|
});
|
|
|
|
|
2015-08-21 22:26:41 +02:00
|
|
|
casper.waitUntilVisible('.edit_bot_form[data-email="1-bot@zulip.com"]', function test_edit_bot_form_values() {
|
|
|
|
var form_sel = '.edit_bot_form[data-email="1-bot@zulip.com"]';
|
2014-02-19 16:07:28 +01:00
|
|
|
casper.test.info('Testing edit bot form values');
|
|
|
|
|
2014-07-18 03:01:40 +02:00
|
|
|
// casper.test.assertEqual(
|
|
|
|
// common.get_form_field_value(form_sel + ' [name=bot_name]'),
|
|
|
|
// 'Bot 1'
|
|
|
|
// );
|
|
|
|
// casper.test.assertEqual(
|
|
|
|
// common.get_form_field_value(form_sel + ' [name=bot_default_sending_stream]'),
|
|
|
|
// 'Denmark'
|
|
|
|
// );
|
|
|
|
// casper.test.assertEqual(
|
|
|
|
// common.get_form_field_value(form_sel + ' [name=bot_default_events_register_stream]'),
|
|
|
|
// 'Rome'
|
|
|
|
// );
|
2014-02-19 16:07:28 +01:00
|
|
|
casper.test.assertEqual(
|
2015-09-20 08:01:55 +02:00
|
|
|
common.get_form_field_value(form_sel + ' [name=bot_name]'),
|
|
|
|
'Bot 1'
|
2014-02-19 16:07:28 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2013-08-06 21:32:15 +02:00
|
|
|
// TODO: test the "Declare Zulip Bankruptcy option"
|
2013-06-12 17:38:13 +02:00
|
|
|
|
2013-03-20 22:38:20 +01:00
|
|
|
common.then_log_out();
|
|
|
|
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|