mirror of
https://github.com/discourse/discourse-adplugin.git
synced 2025-03-09 13:19:11 +00:00
A new setting has been added in Admin > Settings > Ad Plugin called "no ads for groups". Add group names to this list. If a user belongs to any of the groups, they will not see any ads. This is an alternative to using trust level settings like "adsense through trust level".
73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
|
|
import groupFixtures from "fixtures/group-fixtures";
|
|
|
|
acceptance("AdSense", {
|
|
loggedIn: true,
|
|
settings: {
|
|
no_ads_for_groups: "discourse",
|
|
adsense_publisher_code: "MYADSENSEID",
|
|
adsense_through_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",
|
|
adsense_mobile_topic_list_top_ad_size: "300*250 - medium rectangle",
|
|
adsense_post_bottom_code: "post_bottom_ad_unit",
|
|
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
|
|
}
|
|
});
|
|
|
|
test("correct number of ads should show", async assert => {
|
|
replaceCurrentUser({ staff: false, trust_level: 1 });
|
|
await visit("/t/280"); // 20 posts
|
|
const ads = find(".google-adsense.adsense-post-bottom");
|
|
assert.equal(ads.length, 3, "it should render 3 ads");
|
|
assert.equal(
|
|
find("#post_6 + .widget-connector").find(
|
|
".google-adsense.adsense-post-bottom"
|
|
).length,
|
|
1,
|
|
"ad after 6th post"
|
|
);
|
|
assert.equal(
|
|
find("#post_12 + .widget-connector").find(
|
|
".google-adsense.adsense-post-bottom"
|
|
).length,
|
|
1,
|
|
"ad after 12th post"
|
|
);
|
|
assert.equal(
|
|
find("#post_18 + .widget-connector").find(
|
|
".google-adsense.adsense-post-bottom"
|
|
).length,
|
|
1,
|
|
"ad after 18th post"
|
|
);
|
|
});
|
|
|
|
test("no ads for trust level 3", async assert => {
|
|
replaceCurrentUser({ staff: false, trust_level: 3 });
|
|
await visit("/t/280");
|
|
assert.equal(
|
|
find(".google-adsense.adsense-post-bottom").length,
|
|
0,
|
|
"it should render 0 ads"
|
|
);
|
|
});
|
|
|
|
QUnit.only("can omit ads based on groups", async assert => {
|
|
replaceCurrentUser({
|
|
staff: false,
|
|
trust_level: 1,
|
|
groups: [groupFixtures["/groups/discourse.json"].group]
|
|
});
|
|
await visit("/t/280");
|
|
assert.equal(
|
|
find(".google-adsense.adsense-post-bottom").length,
|
|
0,
|
|
"it should render 0 ads"
|
|
);
|
|
});
|