Skip to content
Permalink
Browse files

DEV: Add tests for no_ads_for_categories

  • Loading branch information...
nlalonde committed Sep 11, 2019
1 parent 0612054 commit b500ea171fdd53960ec2e01300b815865b225ad5
Showing with 35 additions and 2 deletions.
  1. +21 −1 test/javascripts/acceptance/adsense-test.js.es6
  2. +14 −1 test/javascripts/acceptance/dfp-test.js.es6
@@ -5,6 +5,7 @@ acceptance("AdSense", {
loggedIn: true,
settings: {
no_ads_for_groups: "discourse",
no_ads_for_categories: "1",
adsense_publisher_code: "MYADSENSEID",
adsense_through_trust_level: 2,
adsense_topic_list_top_code: "list_top_ad_unit",
@@ -15,7 +16,9 @@ acceptance("AdSense", {
adsense_post_bottom_ad_sizes: "728*90 - leaderboard",
adsense_mobile_post_bottom_code: "mobile_post_bottom_ad_unit",
adsense_mobile_post_bottom_ad_size: "300*250 - medium rectangle",
adsense_nth_post_code: 6
adsense_nth_post_code: 6,
adsense_topic_above_post_stream_code: "above_post_stream_ad_unit",
adsense_topic_above_post_stream_ad_sizes: "728*90 - leaderboard"
},
site: {
house_creatives: {
@@ -34,6 +37,13 @@ acceptance("AdSense", {
test("correct number of ads should show", async assert => {
updateCurrentUser({ staff: false, trust_level: 1 });
await visit("/t/280"); // 20 posts

assert.equal(
find(".google-adsense.adsense-topic-above-post-stream").length,
1,
"it should render 1 ad"
);

const ads = find(".google-adsense.adsense-post-bottom");
assert.equal(ads.length, 3, "it should render 3 ads");
assert.equal(
@@ -82,3 +92,13 @@ test("can omit ads based on groups", async assert => {
"it should render 0 ads"
);
});

test("can omit ads based on category", async assert => {
updateCurrentUser({ staff: false, trust_level: 1 });
await visit("/t/28830");
assert.equal(
find(".google-adsense.adsense-topic-above-post-stream").length,
0,
"it should render 0 ads"
);
});
@@ -5,6 +5,7 @@ acceptance("DFP Ads", {
loggedIn: true,
settings: {
no_ads_for_groups: "discourse",
no_ads_for_categories: "1",
dfp_publisher_id: "MYdfpID",
dfp_through_trust_level: 2,
dfp_topic_list_top_code: "list_top_ad_unit",
@@ -15,7 +16,9 @@ acceptance("DFP Ads", {
dfp_post_bottom_ad_sizes: "728*90 - leaderboard",
dfp_mobile_post_bottom_code: "mobile_post_bottom_ad_unit",
dfp_mobile_post_bottom_ad_size: "300*250 - medium rectangle",
dfp_nth_post_code: 6
dfp_nth_post_code: 6,
dfp_topic_above_post_stream_code: "list_top_ad_unit",
dfp_topic_above_post_stream_ad_sizes: "728*90 - leaderboard"
},
site: {
house_creatives: {
@@ -82,3 +85,13 @@ test("can omit ads based on groups", async assert => {
"it should render 0 ads"
);
});

test("can omit ads based on category", async assert => {
updateCurrentUser({ staff: false, trust_level: 1 });
await visit("/t/28830");
assert.equal(
find(".google-dfp-ad.dfp-ad-topic-above-post-stream").length,
0,
"it should render 0 ads"
);
});

0 comments on commit b500ea1

Please sign in to comment.
You can’t perform that action at this time.