discourse/test/javascripts/widgets/hamburger-menu-test.js.es6

176 lines
4.0 KiB
Plaintext
Raw Normal View History

2018-06-15 11:03:24 -04:00
import { moduleForWidget, widgetTest } from "helpers/widget-test";
2018-06-15 11:03:24 -04:00
moduleForWidget("hamburger-menu");
2018-06-15 11:03:24 -04:00
widgetTest("prioritize faq", {
template: '{{mount-widget widget="hamburger-menu"}}',
2017-06-14 13:57:58 -04:00
beforeEach() {
2018-06-15 11:03:24 -04:00
this.siteSettings.faq_url = "http://example.com/faq";
this.currentUser.set("read_faq", false);
},
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(this.$(".faq-priority").length);
assert.ok(!this.$(".faq-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("prioritize faq - user has read", {
template: '{{mount-widget widget="hamburger-menu"}}',
2017-06-14 13:57:58 -04:00
beforeEach() {
2018-06-15 11:03:24 -04:00
this.siteSettings.faq_url = "http://example.com/faq";
this.currentUser.set("read_faq", true);
},
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(!this.$(".faq-priority").length);
assert.ok(this.$(".faq-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("staff menu - not staff", {
template: '{{mount-widget widget="hamburger-menu"}}',
2017-06-14 13:57:58 -04:00
beforeEach() {
2018-06-15 11:03:24 -04:00
this.currentUser.set("staff", false);
},
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(!this.$(".admin-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("staff menu", {
template: '{{mount-widget widget="hamburger-menu"}}',
2017-06-14 13:57:58 -04:00
beforeEach() {
2018-06-15 11:03:24 -04:00
this.currentUser.setProperties({
staff: true,
site_flagged_posts_count: 3
});
},
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(this.$(".admin-link").length);
assert.ok(this.$(".flagged-posts-link").length);
assert.equal(this.$(".flagged-posts").text(), "3");
assert.ok(!this.$(".settings-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("staff menu - admin", {
template: '{{mount-widget widget="hamburger-menu"}}',
2017-06-14 13:57:58 -04:00
beforeEach() {
this.currentUser.setProperties({ staff: true, admin: true });
},
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(this.$(".settings-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("queued posts", {
template: '{{mount-widget widget="hamburger-menu"}}',
2017-06-14 13:57:58 -04:00
beforeEach() {
this.currentUser.setProperties({
staff: true,
show_queued_posts: true,
post_queue_new_count: 5
});
},
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(this.$(".queued-posts-link").length);
assert.equal(this.$(".queued-posts").text(), "5");
}
});
2018-06-15 11:03:24 -04:00
widgetTest("queued posts - disabled", {
template: '{{mount-widget widget="hamburger-menu"}}',
2017-06-14 13:57:58 -04:00
beforeEach() {
this.currentUser.setProperties({ staff: true, show_queued_posts: false });
},
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(!this.$(".queued-posts-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("logged in links", {
template: '{{mount-widget widget="hamburger-menu"}}',
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(this.$(".new-topics-link").length);
assert.ok(this.$(".unread-topics-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("general links", {
template: '{{mount-widget widget="hamburger-menu"}}',
anonymous: true,
test(assert) {
assert.ok(this.$("li[class='']").length === 0);
2018-06-15 11:03:24 -04:00
assert.ok(this.$(".latest-topics-link").length);
assert.ok(!this.$(".new-topics-link").length);
assert.ok(!this.$(".unread-topics-link").length);
assert.ok(this.$(".top-topics-link").length);
assert.ok(this.$(".badge-link").length);
assert.ok(this.$(".category-link").length > 0);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("badges link - disabled", {
template: '{{mount-widget widget="hamburger-menu"}}',
2017-06-14 13:57:58 -04:00
beforeEach() {
this.siteSettings.enable_badges = false;
},
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(!this.$(".badge-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("badges link", {
template: '{{mount-widget widget="hamburger-menu"}}',
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(this.$(".badge-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("user directory link", {
template: '{{mount-widget widget="hamburger-menu"}}',
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(this.$(".user-directory-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("user directory link - disabled", {
template: '{{mount-widget widget="hamburger-menu"}}',
2017-06-14 13:57:58 -04:00
beforeEach() {
this.siteSettings.enable_user_directory = false;
},
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(!this.$(".user-directory-link").length);
}
});
2018-06-15 11:03:24 -04:00
widgetTest("general links", {
template: '{{mount-widget widget="hamburger-menu"}}',
test(assert) {
2018-06-15 11:03:24 -04:00
assert.ok(this.$(".about-link").length);
assert.ok(this.$(".keyboard-shortcuts-link").length);
}
});