This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js
Robin Ward b302321451 REFACTOR: Test assertions should be imported.
Previously they were global functions.
2020-10-28 11:39:06 -04:00

46 lines
1.2 KiB
JavaScript

import { exists } from "discourse/tests/helpers/qunit-helpers";
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import {
acceptance,
updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("Email Disabled Banner", function (needs) {
needs.user();
test("when disabled", async function (assert) {
this.siteSettings.disable_emails = "no";
await visit("/");
assert.notOk(
exists(".alert-emails-disabled"),
"alert is not displayed when email enabled"
);
});
test("when enabled", async function (assert) {
this.siteSettings.disable_emails = "yes";
await visit("/latest");
assert.ok(
exists(".alert-emails-disabled"),
"alert is displayed when email disabled"
);
});
test("when non-staff", async function (assert) {
this.siteSettings.disable_emails = "non-staff";
await visit("/");
assert.ok(
exists(".alert-emails-disabled"),
"alert is displayed when email disabled for non-staff"
);
updateCurrentUser({ moderator: true });
await visit("/");
assert.ok(
exists(".alert-emails-disabled"),
"alert is displayed to staff when email disabled for non-staff"
);
});
});