From 6c99f271c65948677c3b916cefc19571117e890d Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Tue, 5 Apr 2022 19:02:25 -0400 Subject: [PATCH] Add tests --- test/acceptance/gated-category-test.js | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/acceptance/gated-category-test.js diff --git a/test/acceptance/gated-category-test.js b/test/acceptance/gated-category-test.js new file mode 100644 index 0000000..786bcfd --- /dev/null +++ b/test/acceptance/gated-category-test.js @@ -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" + ); + }); +});