2016-04-15 03:23:05 +08:00
|
|
|
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
|
|
|
|
|
|
|
moduleForWidget("header");
|
|
|
|
|
|
|
|
widgetTest("rendering basics", {
|
|
|
|
template: '{{mount-widget widget="header"}}',
|
|
|
|
test(assert) {
|
2019-02-25 23:04:55 +08:00
|
|
|
assert.ok(find("header.d-header").length);
|
|
|
|
assert.ok(find("#site-logo").length);
|
2016-04-15 03:23:05 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("sign up / login buttons", {
|
|
|
|
template:
|
2019-01-10 18:06:01 +08:00
|
|
|
'{{mount-widget widget="header" showCreateAccount=(action "showCreateAccount") showLogin=(action "showLogin") args=args}}',
|
2016-04-15 03:23:05 +08:00
|
|
|
anonymous: true,
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2016-04-15 03:23:05 +08:00
|
|
|
this.set("args", { canSignUp: true });
|
|
|
|
this.on("showCreateAccount", () => (this.signupShown = true));
|
|
|
|
this.on("showLogin", () => (this.loginShown = true));
|
|
|
|
},
|
|
|
|
|
2018-07-24 23:49:42 +08:00
|
|
|
async test(assert) {
|
2019-02-25 23:04:55 +08:00
|
|
|
assert.ok(find("button.sign-up-button").length);
|
|
|
|
assert.ok(find("button.login-button").length);
|
2016-04-15 03:23:05 +08:00
|
|
|
|
2018-07-24 23:49:42 +08:00
|
|
|
await click("button.sign-up-button");
|
|
|
|
assert.ok(this.signupShown);
|
2016-04-15 03:23:05 +08:00
|
|
|
|
2018-07-24 23:49:42 +08:00
|
|
|
await click("button.login-button");
|
|
|
|
assert.ok(this.loginShown);
|
2016-04-15 03:23:05 +08:00
|
|
|
}
|
|
|
|
});
|
2017-01-17 05:33:14 +08:00
|
|
|
|
|
|
|
widgetTest("anon when login required", {
|
|
|
|
template:
|
2019-01-10 18:06:01 +08:00
|
|
|
'{{mount-widget widget="header" showCreateAccount=(action "showCreateAccount") showLogin=(action "showLogin") args=args}}',
|
2017-01-17 05:33:14 +08:00
|
|
|
anonymous: true,
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2017-01-17 05:33:14 +08:00
|
|
|
this.set("args", { canSignUp: true });
|
|
|
|
this.on("showCreateAccount", () => (this.signupShown = true));
|
|
|
|
this.on("showLogin", () => (this.loginShown = true));
|
|
|
|
this.siteSettings.login_required = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
|
|
|
assert.ok(exists("button.login-button"));
|
|
|
|
assert.ok(exists("button.sign-up-button"));
|
|
|
|
assert.ok(!exists("#search-button"));
|
|
|
|
assert.ok(!exists("#toggle-hamburger-menu"));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("logged in when login required", {
|
|
|
|
template:
|
2019-01-10 18:06:01 +08:00
|
|
|
'{{mount-widget widget="header" showCreateAccount=(action "showCreateAccount") showLogin=(action "showLogin") args=args}}',
|
2017-01-17 05:33:14 +08:00
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2017-01-17 05:33:14 +08:00
|
|
|
this.set("args", { canSignUp: true });
|
|
|
|
this.on("showCreateAccount", () => (this.signupShown = true));
|
|
|
|
this.on("showLogin", () => (this.loginShown = true));
|
|
|
|
this.siteSettings.login_required = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
|
|
|
assert.ok(!exists("button.login-button"));
|
|
|
|
assert.ok(!exists("button.sign-up-button"));
|
|
|
|
assert.ok(exists("#search-button"));
|
|
|
|
assert.ok(exists("#toggle-hamburger-menu"));
|
|
|
|
assert.ok(exists("#current-user"));
|
|
|
|
}
|
|
|
|
});
|