2018-06-15 11:03:24 -04:00
|
|
|
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
2016-04-14 15:23:05 -04:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
moduleForWidget("user-menu");
|
2016-04-14 15:23:05 -04:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("basics", {
|
2016-04-14 15:23:05 -04:00
|
|
|
template: '{{mount-widget widget="user-menu"}}',
|
|
|
|
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".user-menu").length);
|
|
|
|
assert.ok(find(".user-activity-link").length);
|
|
|
|
assert.ok(find(".user-bookmarks-link").length);
|
|
|
|
assert.ok(find(".user-preferences-link").length);
|
|
|
|
assert.ok(find(".notifications").length);
|
|
|
|
assert.ok(find(".dismiss-link").length);
|
2016-04-14 15:23:05 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-01-15 21:40:16 -05:00
|
|
|
widgetTest("notifications", {
|
|
|
|
template: '{{mount-widget widget="user-menu"}}',
|
|
|
|
|
|
|
|
test(assert) {
|
|
|
|
const $links = find(".notifications li a");
|
|
|
|
|
|
|
|
assert.equal($links.length, 2);
|
|
|
|
assert.ok($links[0].href.includes("/t/a-slug/123"));
|
|
|
|
|
|
|
|
assert.ok(
|
|
|
|
$links[1].href.includes(
|
|
|
|
"/u/eviltrout/notifications/likes-received?acting_username=aquaman"
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
$links[1].text,
|
|
|
|
`aquaman ${I18n.t("notifications.liked_consolidated_description", {
|
|
|
|
count: 5
|
|
|
|
})}`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("log out", {
|
2019-01-10 05:06:01 -05:00
|
|
|
template: '{{mount-widget widget="user-menu" logout=(action "logout")}}',
|
2016-04-14 15:23:05 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.on("logout", () => (this.loggedOut = true));
|
2016-04-14 15:23:05 -04:00
|
|
|
},
|
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".logout").length);
|
2016-04-14 15:23:05 -04:00
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".logout");
|
|
|
|
assert.ok(this.loggedOut);
|
2016-04-14 15:23:05 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("private messages - disabled", {
|
2016-04-14 15:23:05 -04:00
|
|
|
template: '{{mount-widget widget="user-menu"}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-01-31 01:03:12 -05:00
|
|
|
this.siteSettings.enable_personal_messages = false;
|
2016-04-14 15:23:05 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(!find(".user-pms-link").length);
|
2016-04-14 15:23:05 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("private messages - enabled", {
|
2016-04-14 15:23:05 -04:00
|
|
|
template: '{{mount-widget widget="user-menu"}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-01-31 01:03:12 -05:00
|
|
|
this.siteSettings.enable_personal_messages = true;
|
2016-04-14 15:23:05 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".user-pms-link").length);
|
2016-04-14 15:23:05 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("anonymous", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="user-menu" toggleAnonymous=(action "toggleAnonymous")}}',
|
2016-04-14 15:23:05 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-04-14 15:23:05 -04:00
|
|
|
this.currentUser.setProperties({ is_anonymous: false, trust_level: 3 });
|
|
|
|
this.siteSettings.allow_anonymous_posting = true;
|
|
|
|
this.siteSettings.anonymous_posting_min_trust_level = 3;
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
this.on("toggleAnonymous", () => (this.anonymous = true));
|
2016-04-14 15:23:05 -04:00
|
|
|
},
|
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".enable-anonymous").length);
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".enable-anonymous");
|
|
|
|
assert.ok(this.anonymous);
|
2016-04-14 15:23:05 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("anonymous - disabled", {
|
2016-04-14 15:23:05 -04:00
|
|
|
template: '{{mount-widget widget="user-menu"}}',
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-04-14 15:23:05 -04:00
|
|
|
this.siteSettings.allow_anonymous_posting = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(!find(".enable-anonymous").length);
|
2016-04-14 15:23:05 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("anonymous - switch back", {
|
|
|
|
template:
|
2019-01-10 05:06:01 -05:00
|
|
|
'{{mount-widget widget="user-menu" toggleAnonymous=(action "toggleAnonymous")}}',
|
2016-04-14 15:23:05 -04:00
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-04-14 15:23:05 -04:00
|
|
|
this.currentUser.setProperties({ is_anonymous: true });
|
|
|
|
this.siteSettings.allow_anonymous_posting = true;
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
this.on("toggleAnonymous", () => (this.anonymous = true));
|
2016-04-14 15:23:05 -04:00
|
|
|
},
|
|
|
|
|
2018-07-24 11:49:42 -04:00
|
|
|
async test(assert) {
|
2019-02-25 10:04:55 -05:00
|
|
|
assert.ok(find(".disable-anonymous").length);
|
2018-07-24 11:49:42 -04:00
|
|
|
await click(".disable-anonymous");
|
|
|
|
assert.ok(this.anonymous);
|
2016-04-14 15:23:05 -04:00
|
|
|
}
|
|
|
|
});
|