Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

test(traffic): browser smoke test for analytics views

Aditya Tripathi37d7e99a4a6f
diff --git a/tests/v4/Browser/TrafficAnalyticsTest.php b/tests/v4/Browser/TrafficAnalyticsTest.php
new file mode 100644
index 0000000000..d2d1ae8e06
--- /dev/null
+++ b/tests/v4/Browser/TrafficAnalyticsTest.php
@@ -0,0 +1,55 @@
+<?php
+
+use Illuminate\Foundation\Testing\RefreshDatabase;
+
+uses(RefreshDatabase::class);
+
+beforeEach(function () {
+ // seedBrowserResourceStack() creates a "localhost" server with traffic
+ // analytics disabled by default (is_traffic_analytics_enabled defaults
+ // to false), so these smoke tests exercise the deterministic, Sentinel-free
+ // "disabled" empty-state path across the three analytics surfaces.
+ $this->stack = seedBrowserResourceStack();
+ $this->application = createBrowserApplication($this->stack, [
+ 'uuid' => 'app-traffic-analytics',
+ 'name' => 'Traffic App',
+ ]);
+});
+
+it('shows the disabled empty state on the application analytics tab', function () {
+ loginAndSkipBoarding();
+
+ $url = applicationConfigurationUrl(
+ $this->stack['project'],
+ $this->stack['environment'],
+ $this->application
+ );
+
+ $page = visit("{$url}/analytics");
+
+ $page->assertSee('Traffic App')
+ ->assertSee('Traffic analytics is not enabled')
+ ->assertSee('Enable Sentinel traffic analytics for this server to start collecting request analytics.')
+ ->screenshot(filename: 'application-analytics-disabled-empty-state');
+});
+
+it('shows the disabled empty state on the server analytics tab', function () {
+ loginAndSkipBoarding();
+
+ $server = $this->stack['server'];
+
+ $page = visit("/server/{$server->uuid}/analytics");
+
+ $page->assertSee('Traffic analytics is not enabled')
+ ->assertSee('Enable Sentinel traffic analytics for this server to start collecting request analytics.')
+ ->screenshot(filename: 'server-analytics-disabled-empty-state');
+});
+
+it('shows the disabled empty state on the dashboard traffic widget', function () {
+ $page = loginAndSkipBoarding();
+
+ $page->assertSee('Traffic analytics')
+ ->assertSee('Traffic analytics is not enabled')
+ ->assertSee('Enable Sentinel traffic analytics on a server to see a team-wide summary here.')
+ ->screenshot(filename: 'dashboard-traffic-analytics-disabled-empty-state');
+});