Skip to content

Commit bc45709

Browse files
committed
wip
1 parent abece7c commit bc45709

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Plugin.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,17 @@ public function boot(): void
4747
public function onInit(): void
4848
{
4949
$tracking = ! $this->trackingRules->hasExcludedIp();
50+
$excludedRole = $this->trackingRules->hasExcludedUserRole();
5051

5152
if ($tracking && $this->settings->get(SettingName::NOSCRIPT)) {
5253
AddNoScriptTag::register();
5354
}
5455

55-
if (! $this->trackingRules->hasExcludedUserRole()) {
56+
if (! $excludedRole) {
5657
AddInactiveComment::register();
5758
}
5859

59-
if ($tracking) {
60+
if ($tracking && ! $excludedRole) {
6061
$this->scripts->push(new AnalyticsScript);
6162
} else {
6263
$this->scripts->push(new InactiveScript);

tests/Browser/PluginSettingsTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
const SA_ADMIN_NOTICE = '<!-- Simple Analytics: Not logging requests from admins -->';
88
const SA_DEFAULT_SCRIPT = 'src="https://scripts.simpleanalyticscdn.com/latest.js"></script>';
9+
const SA_INACTIVE_ADMIN_SCRIPT = 'resources/js/inactive.js"></script>';
10+
911
const WP_PLUGIN_ROW_SELECTOR = 'tr[data-slug="simpleanalytics"]';
1012
const WP_ACTIVATE_PLUGIN_SELECTOR = '#activate-simpleanalytics';
1113
const WP_DEACTIVATE_PLUGIN_SELECTOR = '#deactivate-simpleanalytics';
@@ -28,6 +30,8 @@
2830

2931
it('adds a comment when an authenticated user visits', function () {
3032
$homePage = asAdmin()->navigate('http://localhost:8100');
31-
expect($homePage->content())->dump()->toContain(SA_ADMIN_NOTICE);
32-
$homePage->assertNoConsoleLogs();
33+
34+
expect($homePage->content())->dump()
35+
->toContain(SA_ADMIN_NOTICE)
36+
->toContain(SA_INACTIVE_ADMIN_SCRIPT);
3337
});

0 commit comments

Comments
 (0)