@@ -2,15 +2,11 @@ import {expect, test} from '@playwright/test';
22import { globalDataRequests , mockApi , responseFixtures , updatedSettingsResponse } from '@tryghost/admin-x-framework/test/acceptance' ;
33
44// Helper functions to reduce mockApi boilerplate
5- const createConfigWithFeatureFlags = ( trafficAnalytics : boolean , limits ?: any ) => ( {
5+ const createConfigWithFeatureFlags = ( limits ?: any ) => ( {
66 ...globalDataRequests . browseConfig ,
77 response : {
88 config : {
99 ...responseFixtures . config . config ,
10- labs : {
11- ...responseFixtures . config . config . labs ,
12- trafficAnalytics
13- } ,
1410 hostSettings : limits ? {
1511 ...responseFixtures . config . config . hostSettings ,
1612 limits
@@ -31,14 +27,12 @@ const createSettingsWithAnalytics = (additionalSettings: Array<{key: string, val
3127} ) ;
3228
3329const createMockApiConfig = ( options : {
34- trafficAnalytics ?: boolean ;
3530 limits ?: any ;
3631 analyticsSettings ?: Array < { key : string , value : any , is_read_only ?: boolean } > ;
3732 editSettingsResponse ?: Array < { key : string , value : any } > ;
3833 additionalRequests ?: any ;
3934} ) => {
4035 const {
41- trafficAnalytics = false ,
4236 limits,
4337 analyticsSettings = [ ] ,
4438 editSettingsResponse,
@@ -47,7 +41,7 @@ const createMockApiConfig = (options: {
4741
4842 const requests : any = {
4943 ...globalDataRequests ,
50- browseConfig : createConfigWithFeatureFlags ( trafficAnalytics , limits ) ,
44+ browseConfig : createConfigWithFeatureFlags ( limits ) ,
5145 ...additionalRequests
5246 } ;
5347
@@ -69,7 +63,6 @@ const createMockApiConfig = (options: {
6963test . describe ( 'Analytics settings' , async ( ) => {
7064 test ( 'Supports toggling analytics settings' , async ( { page} ) => {
7165 const { lastApiRequests} = await mockApi ( { page, requests : createMockApiConfig ( {
72- trafficAnalytics : true ,
7366 analyticsSettings : [
7467 { key : 'web_analytics' , value : true } ,
7568 { key : 'web_analytics_enabled' , value : true } ,
@@ -163,59 +156,8 @@ test.describe('Analytics settings', async () => {
163156
164157 await expect ( newsletterClicksToggle ) . toBeDisabled ( ) ;
165158 } ) ;
166-
167- test ( 'Shows web analytics toggle when feature flag is enabled' , async ( { page} ) => {
168- await mockApi ( { page, requests : createMockApiConfig ( {
169- trafficAnalytics : true ,
170- analyticsSettings : [
171- { key : 'web_analytics' , value : true } ,
172- { key : 'web_analytics_enabled' , value : true } ,
173- { key : 'web_analytics_configured' , value : true }
174- ]
175- } ) } ) ;
176-
177- await page . goto ( '/' ) ;
178-
179- const section = page . getByTestId ( 'analytics' ) ;
180-
181- await expect ( section ) . toBeVisible ( ) ;
182-
183- // Web analytics toggle should be visible when feature flag is enabled
184- await expect ( section . getByLabel ( 'Web analytics' ) ) . toBeVisible ( ) ;
185- await expect ( section . getByLabel ( 'Web analytics' ) ) . toBeEnabled ( ) ;
186- await expect ( section . getByLabel ( 'Web analytics' ) ) . toBeChecked ( ) ;
187-
188- // Other analytics toggles should still be visible
189- await expect ( section . getByLabel ( 'Newsletter opens' ) ) . toBeVisible ( ) ;
190- await expect ( section . getByLabel ( 'Newsletter clicks' ) ) . toBeVisible ( ) ;
191- await expect ( section . getByLabel ( 'Member sources' ) ) . toBeVisible ( ) ;
192- await expect ( section . getByLabel ( 'Outbound link tagging' ) ) . toBeVisible ( ) ;
193- } ) ;
194-
195- test ( 'Hides web analytics toggle when feature flag is disabled' , async ( { page} ) => {
196- await mockApi ( { page, requests : createMockApiConfig ( {
197- trafficAnalytics : false
198- } ) } ) ;
199-
200- await page . goto ( '/' ) ;
201-
202- const section = page . getByTestId ( 'analytics' ) ;
203-
204- await expect ( section ) . toBeVisible ( ) ;
205-
206- // Web analytics toggle should not be visible when feature flag is disabled
207- await expect ( section . getByLabel ( 'Web analytics' ) ) . not . toBeVisible ( ) ;
208-
209- // Other analytics toggles should still be visible
210- await expect ( section . getByLabel ( 'Newsletter opens' ) ) . toBeVisible ( ) ;
211- await expect ( section . getByLabel ( 'Newsletter clicks' ) ) . toBeVisible ( ) ;
212- await expect ( section . getByLabel ( 'Member sources' ) ) . toBeVisible ( ) ;
213- await expect ( section . getByLabel ( 'Outbound link tagging' ) ) . toBeVisible ( ) ;
214- } ) ;
215-
216159 test ( 'Shows web analytics toggle as disabled when web_analytics_configured is false' , async ( { page} ) => {
217160 await mockApi ( { page, requests : createMockApiConfig ( {
218- trafficAnalytics : true ,
219161 analyticsSettings : [
220162 { key : 'web_analytics' , value : true } ,
221163 { key : 'web_analytics_enabled' , value : false } ,
@@ -243,7 +185,6 @@ test.describe('Analytics settings', async () => {
243185
244186 test ( 'Shows web analytics toggle as enabled and respects user setting' , async ( { page} ) => {
245187 const { lastApiRequests} = await mockApi ( { page, requests : createMockApiConfig ( {
246- trafficAnalytics : true ,
247188 analyticsSettings : [
248189 { key : 'web_analytics' , value : true } ,
249190 { key : 'web_analytics_enabled' , value : true } ,
@@ -279,7 +220,6 @@ test.describe('Analytics settings', async () => {
279220
280221 test ( 'Cannot toggle web analytics when disabled' , async ( { page} ) => {
281222 await mockApi ( { page, requests : createMockApiConfig ( {
282- trafficAnalytics : true ,
283223 analyticsSettings : [
284224 { key : 'web_analytics' , value : false } ,
285225 { key : 'web_analytics_enabled' , value : false }
@@ -304,7 +244,6 @@ test.describe('Analytics settings', async () => {
304244
305245 test ( 'Can enable web analytics when it starts deselected' , async ( { page} ) => {
306246 const { lastApiRequests} = await mockApi ( { page, requests : createMockApiConfig ( {
307- trafficAnalytics : true ,
308247 analyticsSettings : [
309248 { key : 'web_analytics' , value : false } , // Starts as false
310249 { key : 'web_analytics_enabled' , value : false } , // Feature is OFF but configurable
@@ -340,7 +279,6 @@ test.describe('Analytics settings', async () => {
340279
341280 test ( 'Shows upgrade CTA when analytics is limited (trial plan)' , async ( { page} ) => {
342281 await mockApi ( { page, requests : createMockApiConfig ( {
343- trafficAnalytics : true ,
344282 limits : {
345283 ...responseFixtures . config . config . hostSettings ?. limits ,
346284 limitAnalytics : {
@@ -377,7 +315,6 @@ test.describe('Analytics settings', async () => {
377315
378316 test ( 'Shows configuration message when not limited but not configured' , async ( { page} ) => {
379317 await mockApi ( { page, requests : createMockApiConfig ( {
380- trafficAnalytics : true ,
381318 limits : { } , // No limits
382319 analyticsSettings : [
383320 { key : 'web_analytics' , value : false } ,
@@ -402,7 +339,6 @@ test.describe('Analytics settings', async () => {
402339
403340 test ( 'Shows separator when configured and not limited' , async ( { page} ) => {
404341 await mockApi ( { page, requests : createMockApiConfig ( {
405- trafficAnalytics : true ,
406342 limits : { } , // No limits
407343 analyticsSettings : [
408344 { key : 'web_analytics' , value : true } ,
@@ -427,7 +363,6 @@ test.describe('Analytics settings', async () => {
427363
428364 test ( 'Upgrade now button navigates to /pro' , async ( { page} ) => {
429365 await mockApi ( { page, requests : createMockApiConfig ( {
430- trafficAnalytics : true ,
431366 limits : {
432367 ...responseFixtures . config . config . hostSettings ?. limits ,
433368 limitAnalytics : {
0 commit comments