Add casper tests for default language setting.

Fixes #1076.
This commit is contained in:
Umair Khan 2016-06-27 14:27:48 +05:00 committed by Tim Abbott
parent 054d14bb96
commit e4b32905bf
1 changed files with 44 additions and 1 deletions

View File

@ -5,7 +5,7 @@ common.start_and_log_in();
var form_sel = 'form[action^="/json/settings/change"]';
casper.then(function () {
casper.waitForSelector('a[href^="#settings"]', function () {
casper.test.info('Settings page');
casper.click('a[href^="#settings"]');
});
@ -122,6 +122,49 @@ casper.waitForSelector('#create_alert_word_form', function () {
casper.test.assertDoesntExist('div.alert-word-information-box');
});
casper.then(function change_default_language() {
casper.test.info('Changing the default language');
casper.evaluate(function () {
$('#default_language').val('zh_CN').change();
});
});
casper.waitUntilVisible('#display-settings-status', function () {
casper.test.assertSelectorHasText('#display-settings-status', '简体中文 is now the default language');
casper.test.info("Reloading page");
casper.reload(function () {
casper.test.info("Reloaded");
});
});
casper.waitForSelector("#settings-change-box", function () {
casper.test.info("Checking if we are on Chinese page.");
casper.test.assertEvalEquals(function () {
return document.documentElement.lang;
}, 'zh-cn');
});
casper.thenOpen('http://localhost:9981/de/#settings', function () {
casper.test.info("German page opened.");
});
casper.waitForSelector("#settings-change-box");
casper.then(function check_url_preference() {
casper.test.info("Checking i18n url language precedence.");
casper.test.assertEvalEquals(function () {
return document.documentElement.lang;
}, 'de');
casper.test.info("Changing language back to English.");
casper.evaluate(function () {
$('#default_language').val('en').change();
});
});
casper.waitUntilVisible('#display-settings-status', function () {
casper.test.assertSelectorHasText('#display-settings-status', 'English is now the default language');
});
// TODO: test the "Declare Zulip Bankruptcy option"
common.then_log_out();