Add tests

This commit is contained in:
Penar Musaraj 2022-04-05 19:02:25 -04:00
parent 5a6b24ceb9
commit 6c99f271c6
No known key found for this signature in database
GPG Key ID: E390435D881FF0F7
1 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,51 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
acceptance("Gated Category - Anonymous", function (needs) {
needs.hooks.beforeEach(() => {
settings.enabled_categories = "2";
});
needs.hooks.afterEach(() => {
settings.enabled_categories = "";
});
test("Viewing Topic in gated category", async function (assert) {
await visit("/t/internationalization-localization/280");
assert.ok(
query(".topic-in-gated-category .custom-gated-topic-content"),
"gated category prompt shown for anons on selected category"
);
});
test("Viewing Topic in non-gated category", async function (assert) {
await visit("/t/34");
assert.notOk(
query(".topic-in-gated-category .custom-gated-topic-content"),
"gated category prompt shown for anons on selected category"
);
});
});
acceptance("Gated Category - Logged In", function (needs) {
needs.user();
needs.hooks.beforeEach(() => {
settings.enabled_categories = "2";
});
needs.hooks.afterEach(() => {
settings.enabled_categories = "";
});
test("Viewing Topic in gated category", async function (assert) {
await visit("/t/internationalization-localization/280");
assert.notOk(
query(".topic-in-gated-category .custom-gated-topic-content"),
"gated category prompt not shown on selected category"
);
});
});