DEV: Convert TL settings to groups (#195)

* DEV: Convert TL settings to groups

This change converts the TL site settings in this plugin to use groups
instead.

See: https://meta.discourse.org/t/283408

Co-authored-by: Martin Brennan <[email protected]>
This commit is contained in:
Blake Erickson
2024-01-31 11:04:24 -07:00
committed by GitHub
co-authored by Martin Brennan
parent 19ac017dd4
commit 6f8ff34ffa
16 changed files with 348 additions and 45 deletions
+16 -3
View File
@@ -1,5 +1,6 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { AUTO_GROUPS } from "discourse/lib/constants";
import groupFixtures from "discourse/tests/fixtures/group-fixtures";
import {
acceptance,
@@ -12,7 +13,10 @@ acceptance("AdSense", function (needs) {
no_ads_for_groups: "47",
no_ads_for_categories: "1",
adsense_publisher_code: "MYADSENSEID",
adsense_through_trust_level: 2,
adsense_display_groups: [
AUTO_GROUPS.trust_level_1,
AUTO_GROUPS.trust_level_2,
],
adsense_topic_list_top_code: "list_top_ad_unit",
adsense_topic_list_top_ad_sizes: "728*90 - leaderboard",
adsense_mobile_topic_list_top_code: "mobile_list_top_ad_unit",
@@ -39,7 +43,12 @@ acceptance("AdSense", function (needs) {
});
test("correct number of ads should show", async (assert) => {
updateCurrentUser({ staff: false, trust_level: 1 });
updateCurrentUser({
staff: false,
trust_level: 1,
groups: [AUTO_GROUPS.trust_level_1],
show_adsense_ads: true,
});
await visit("/t/280"); // 20 posts
assert
@@ -64,7 +73,11 @@ acceptance("AdSense", function (needs) {
});
test("no ads for trust level 3", async (assert) => {
updateCurrentUser({ staff: false, trust_level: 3 });
updateCurrentUser({
staff: false,
trust_level: 3,
groups: [AUTO_GROUPS.trust_level_3],
});
await visit("/t/280");
assert
.dom(".google-adsense.adsense-post-bottom")
+16 -2
View File
@@ -1,5 +1,6 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { AUTO_GROUPS } from "discourse/lib/constants";
import groupFixtures from "discourse/tests/fixtures/group-fixtures";
import {
acceptance,
@@ -13,6 +14,7 @@ acceptance("DFP Ads", function (needs) {
no_ads_for_categories: "1",
dfp_publisher_id: "MYdfpID",
dfp_through_trust_level: 2,
dfp_display_groups: [AUTO_GROUPS.trust_level_1, AUTO_GROUPS.trust_level_2],
dfp_topic_list_top_code: "list_top_ad_unit",
dfp_topic_list_top_ad_sizes: "728*90 - leaderboard",
dfp_mobile_topic_list_top_code: "mobile_list_top_ad_unit",
@@ -39,7 +41,11 @@ acceptance("DFP Ads", function (needs) {
});
test("correct number of ads should show", async (assert) => {
updateCurrentUser({ staff: false, trust_level: 1 });
updateCurrentUser({
staff: false,
trust_level: 1,
show_dfp_ads: true,
});
await visit("/t/280"); // 20 posts
assert
@@ -60,7 +66,15 @@ acceptance("DFP Ads", function (needs) {
});
test("no ads for trust level 3", async (assert) => {
updateCurrentUser({ staff: false, trust_level: 3 });
updateCurrentUser({
staff: false,
trust_level: 3,
groups: [
AUTO_GROUPS.trust_level_1,
AUTO_GROUPS.trust_level_2,
AUTO_GROUPS.trust_level_3,
],
});
await visit("/t/280");
assert
.dom(".google-dfp-ad.dfp-ad-post-bottom")
@@ -1,5 +1,6 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { AUTO_GROUPS } from "discourse/lib/constants";
import {
acceptance,
count,
@@ -12,7 +13,7 @@ acceptance("Mixed Ads", function (needs) {
house_ads_after_nth_post: 6,
house_ads_frequency: 50,
dfp_publisher_id: "MYdfpID",
dfp_through_trust_level: 2,
dfp_display_groups: [AUTO_GROUPS.trust_level_1, AUTO_GROUPS.trust_level_2],
dfp_topic_list_top_code: "list_top_ad_unit",
dfp_topic_list_top_ad_sizes: "728*90 - leaderboard",
dfp_mobile_topic_list_top_code: "mobile_list_top_ad_unit",
@@ -44,7 +45,11 @@ acceptance("Mixed Ads", function (needs) {
});
test("correct ads show", async (assert) => {
updateCurrentUser({ staff: false, trust_level: 1 });
updateCurrentUser({
staff: false,
trust_level: 1,
show_dfp_ads: true,
});
await visit("/t/280"); // 20 posts
const houseAdsCount = count(".house-creative");