2015-05-13 10:42:36 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
acceptance("User Preferences", { loggedIn: true });
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("update some fields", assert => {
|
2017-03-28 14:27:54 -04:00
|
|
|
visit("/u/eviltrout/preferences");
|
2015-05-13 10:42:36 -04:00
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok($('body.user-preferences-page').length, "has the body class");
|
|
|
|
assert.equal(currentURL(), '/u/eviltrout/preferences/account', "defaults to account tab");
|
|
|
|
assert.ok(exists('.user-preferences'), 'it shows the preferences');
|
2015-05-13 10:42:36 -04:00
|
|
|
});
|
|
|
|
|
2017-05-03 13:49:16 -04:00
|
|
|
const savePreferences = () => {
|
|
|
|
click('.save-user');
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!exists('.saved-user'), "it hasn't been saved yet");
|
2017-05-03 13:49:16 -04:00
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(exists('.saved-user'), 'it displays the saved message');
|
2017-05-03 13:49:16 -04:00
|
|
|
});
|
|
|
|
};
|
2017-04-26 16:18:16 -04:00
|
|
|
|
2017-05-04 12:03:59 -04:00
|
|
|
fillIn(".pref-name input[type=text]", "Jon Snow");
|
|
|
|
savePreferences();
|
|
|
|
|
2017-05-03 13:49:16 -04:00
|
|
|
click(".preferences-nav .nav-profile a");
|
2015-05-13 10:42:36 -04:00
|
|
|
fillIn("#edit-location", "Westeros");
|
2017-05-03 13:49:16 -04:00
|
|
|
savePreferences();
|
2015-05-13 10:42:36 -04:00
|
|
|
|
2017-05-03 13:49:16 -04:00
|
|
|
click(".preferences-nav .nav-emails a");
|
|
|
|
click(".pref-activity-summary input[type=checkbox]");
|
|
|
|
savePreferences();
|
|
|
|
|
|
|
|
click(".preferences-nav .nav-notifications a");
|
2017-12-22 07:08:12 -05:00
|
|
|
selectKit('.control-group.notifications .combo-box.duration').expand().selectRowByValue(1440);
|
2017-05-03 13:49:16 -04:00
|
|
|
savePreferences();
|
|
|
|
|
|
|
|
click(".preferences-nav .nav-categories a");
|
|
|
|
fillIn('.category-controls .category-selector', 'faq');
|
|
|
|
savePreferences();
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!exists('.preferences-nav .nav-tags a'), "tags tab isn't there when tags are disabled");
|
2017-05-03 13:49:16 -04:00
|
|
|
|
2017-05-03 15:33:25 -04:00
|
|
|
// Error: Unhandled request in test environment: /themes/assets/10d71596-7e4e-4dc0-b368-faa3b6f1ce6d?_=1493833562388 (GET)
|
|
|
|
// click(".preferences-nav .nav-interface a");
|
|
|
|
// click('.control-group.other input[type=checkbox]:first');
|
|
|
|
// savePreferences();
|
2017-05-03 13:49:16 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(!exists('.preferences-nav .nav-apps a'), "apps tab isn't there when you have no authorized apps");
|
2015-05-13 10:42:36 -04:00
|
|
|
});
|
2016-11-10 15:54:21 -05:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("username", assert => {
|
2017-03-28 14:27:54 -04:00
|
|
|
visit("/u/eviltrout/preferences/username");
|
2016-11-10 15:54:21 -05:00
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(exists("#change_username"), "it has the input element");
|
2016-11-10 15:54:21 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("about me", assert => {
|
2017-03-28 14:27:54 -04:00
|
|
|
visit("/u/eviltrout/preferences/about-me");
|
2016-11-10 15:54:21 -05:00
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(exists(".raw-bio"), "it has the input element");
|
2016-11-10 15:54:21 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test("email", assert => {
|
2017-03-28 14:27:54 -04:00
|
|
|
visit("/u/eviltrout/preferences/email");
|
2016-11-10 16:20:31 -05:00
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.ok(exists("#change-email"), "it has the input element");
|
2016-12-21 04:00:45 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
fillIn("#change-email", 'invalidemail');
|
|
|
|
|
|
|
|
andThen(() => {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(find('.tip.bad').text().trim(), I18n.t('user.email.invalid'), 'it should display invalid email tip');
|
2016-11-10 16:20:31 -05:00
|
|
|
});
|
2017-12-22 07:08:12 -05:00
|
|
|
});
|