set('services.umami.enabled', false); $this->get('https://presseecho.test/de') ->assertSuccessful() ->assertDontSee('sys.adametz.media', false); }); test('the umami snippet renders the website id of the requested brand', function (string $host, string $websiteId) { /** @var TestCase $this */ config()->set('services.umami.enabled', true); // /de/faq existiert auf allen drei Hosts (die Hub-Startseite liegt auf /). $this->get("https://{$host}/de/faq") ->assertSuccessful() ->assertSee('https://sys.adametz.media/config.js', false) ->assertSee('data-website-id="'.$websiteId.'"', false); })->with([ 'presseecho' => ['presseecho.test', '3ea8a7b0-105d-4519-b200-138cadc0fbdc'], 'businessportal24' => ['businessportal24.test', 'f03a5fc3-ac44-488f-9118-84004861099f'], 'pressekonto hub' => ['pressekonto.test', 'ca440b65-a5bd-42c1-8cdb-96f34734003c'], ]); test('the web snippet carries the query filter, web vitals and no identity', function () { /** @var TestCase $this */ config()->set('services.umami.enabled', true); config()->set('services.umami.identify_users', true); $this->actingAs(User::factory()->create()); $this->get('https://presseecho.test/de/faq') ->assertSuccessful() ->assertSee('data-tag="web"', false) ->assertSee('data-before-send="pkUmamiBeforeSend"', false) ->assertSee('window.pkUmamiBeforeSend', false) ->assertSee('data-performance="true"', false) ->assertDontSee('umami.identify', false); }); /** * Kundenbereich (Monitoring-Plan M2, M6, M7). */ function umamiCustomer(): User { test()->seed(RolesAndPermissionsSeeder::class); $customer = User::factory()->create(['is_active' => true]); $customer->assignRole('customer'); return $customer; } test('the customer area is tracked only with its own switch', function () { /** @var TestCase $this */ config()->set('services.umami.enabled', true); config()->set('services.umami.portal_enabled', false); $this->actingAs(umamiCustomer()); $this->get(route('me.dashboard'))->assertSuccessful()->assertDontSee('sys.adametz.media', false); config()->set('services.umami.portal_enabled', true); $this->get(route('me.dashboard')) ->assertSuccessful() ->assertSee('data-tag="portal"', false) ->assertSee('data-website-id="ca440b65-a5bd-42c1-8cdb-96f34734003c"', false) ->assertDontSee('umami.identify', false); }); test('customers are identified by user id only when identify is switched on', function () { /** @var TestCase $this */ config()->set('services.umami.enabled', true); config()->set('services.umami.portal_enabled', true); config()->set('services.umami.identify_users', true); $customer = umamiCustomer(); $this->actingAs($customer); $this->get(route('me.dashboard')) ->assertSuccessful() ->assertSee("window.umami.identify('user-{$customer->id}')", false) ->assertDontSee("identify('{$customer->email}", false); }); test('the admin area and impersonated sessions are never tracked', function () { /** @var TestCase $this */ config()->set('services.umami.enabled', true); config()->set('services.umami.portal_enabled', true); config()->set('services.umami.identify_users', true); $customer = umamiCustomer(); $admin = User::factory()->create(['is_active' => true, 'is_super_admin' => true]); $this->actingAs($admin)->get(route('dashboard'))->assertSuccessful()->assertDontSee('sys.adametz.media', false); $this->actingAs($customer) ->withSession([UserImpersonation::SessionKey => $admin->id]) ->get(route('me.dashboard')) ->assertSuccessful() ->assertDontSee('sys.adametz.media', false); });