@@ -18,7 +18,7 @@ test.beforeEach(async ({page}) => {
1818
1919test ( 'should inject B3 headers when __server_timing param is passed' , async ( { page} ) => {
2020 const url = `${ config . RETAIL_APP_HOME } ?__server_timing=true`
21-
21+
2222 const responseHeaders = [ ]
2323 page . on ( 'response' , ( response ) => {
2424 if ( response . url ( ) . includes ( config . RETAIL_APP_HOME ) ) {
@@ -34,31 +34,34 @@ test('should inject B3 headers when __server_timing param is passed', async ({pa
3434 await answerConsentTrackingForm ( page )
3535
3636 expect ( responseHeaders . length ) . toBeGreaterThan ( 0 )
37-
38- const mainResponse = responseHeaders . find ( r =>
39- r . url . includes ( config . RETAIL_APP_HOME ) && ! r . url . includes ( 'static' )
37+
38+ const mainResponse = responseHeaders . find (
39+ ( r ) =>
40+ r . url . includes ( config . RETAIL_APP_HOME ) && ! r . url . includes ( 'static' )
4041 )
41-
42- if ( mainResponse ) {
42+
43+ if ( mainResponse ) {
4344 expect ( mainResponse . headers ) . toBeDefined ( )
44-
45+
4546 expect ( mainResponse . headers [ 'x-b3-traceid' ] ) . toBeDefined ( )
4647 expect ( mainResponse . headers [ 'x-b3-spanid' ] ) . toBeDefined ( )
4748 expect ( mainResponse . headers [ 'x-b3-sampled' ] ) . toBe ( '1' )
48-
49+
4950 // Verify trace ID format (should be 16 or 32 character hex string)
5051 const traceId = mainResponse . headers [ 'x-b3-traceid' ]
5152 expect ( traceId ) . toMatch ( / ^ [ 0 - 9 a - f ] { 16 } $ | ^ [ 0 - 9 a - f ] { 32 } $ / )
52-
53+
5354 // Verify span ID format (should be 16 character hex string)
5455 const spanId = mainResponse . headers [ 'x-b3-spanid' ]
5556 expect ( spanId ) . toMatch ( / ^ [ 0 - 9 a - f ] { 16 } $ / )
5657 }
5758} )
5859
59- test ( 'should not show Server Timing header if __server_timing param is not passed' , async ( { page} ) => {
60+ test ( 'should not show Server Timing header if __server_timing param is not passed' , async ( {
61+ page
62+ } ) => {
6063 const url = config . RETAIL_APP_HOME // No __server_timing param
61-
64+
6265 const responseHeaders = [ ]
6366 page . on ( 'response' , ( response ) => {
6467 if ( response . url ( ) . includes ( config . RETAIL_APP_HOME ) ) {
@@ -74,18 +77,21 @@ test('should not show Server Timing header if __server_timing param is not passe
7477 await answerConsentTrackingForm ( page )
7578
7679 expect ( responseHeaders . length ) . toBeGreaterThan ( 0 )
77-
78- const mainResponse = responseHeaders . find ( r =>
79- r . url . includes ( config . RETAIL_APP_HOME ) && ! r . url . includes ( 'static' )
80+
81+ const mainResponse = responseHeaders . find (
82+ ( r ) =>
83+ r . url . includes ( config . RETAIL_APP_HOME ) && ! r . url . includes ( 'static' )
8084 )
81-
85+
8286 expect ( mainResponse ) . toBeDefined ( )
8387 expect ( mainResponse . headers [ 'server-timing' ] ) . toBeUndefined ( )
8488} )
8589
86- test ( 'should validate performance marks in Server-Timing header have numeric durations' , async ( { page} ) => {
90+ test ( 'should validate performance marks in Server-Timing header have numeric durations' , async ( {
91+ page
92+ } ) => {
8793 const url = `${ config . RETAIL_APP_HOME } ?__server_timing=true`
88-
94+
8995 const responseHeaders = [ ]
9096 page . on ( 'response' , ( response ) => {
9197 if ( response . url ( ) . includes ( config . RETAIL_APP_HOME ) ) {
@@ -101,34 +107,37 @@ test('should validate performance marks in Server-Timing header have numeric dur
101107 await answerConsentTrackingForm ( page )
102108
103109 expect ( responseHeaders . length ) . toBeGreaterThan ( 0 )
104-
105- const mainResponse = responseHeaders . find ( r =>
106- r . url . includes ( config . RETAIL_APP_HOME ) && ! r . url . includes ( 'static' )
110+
111+ const mainResponse = responseHeaders . find (
112+ ( r ) =>
113+ r . url . includes ( config . RETAIL_APP_HOME ) && ! r . url . includes ( 'static' )
107114 )
108-
115+
109116 if ( mainResponse && mainResponse . headers [ 'server-timing' ] ) {
110117 const serverTiming = mainResponse . headers [ 'server-timing' ]
111-
118+
112119 // Parse timing entries and validate durations
113120 const timingEntries = serverTiming . split ( ', ' )
114- timingEntries . forEach ( entry => {
121+ timingEntries . forEach ( ( entry ) => {
115122 const match = entry . match ( / ^ ( [ ^ ; ] + ) ; d u r = ( \d + \. \d + ) $ / )
116123 expect ( match ) . toBeTruthy ( )
117-
124+
118125 const markName = match [ 1 ]
119126 const duration = parseFloat ( match [ 2 ] )
120-
127+
121128 // Duration should be a positive number
122129 expect ( duration ) . toBeGreaterThan ( 0 )
123130 expect ( duration ) . toBeLessThan ( 10000 ) // Reasonable upper bound
124-
131+
125132 // Should be one of the expected performance marks
126133 // Handle various suffixes by extracting the base mark name
127134 // Remove any suffix after the base mark name (e.g., .1, .useCategory-0, .useProductSearch-2)
128- const baseMarkName = markName . replace ( / \. ( u s e C a t e g o r y | u s e P r o d u c t S e a r c h | u s e Q u e r y ) - \d + $ / , '' ) . replace ( / \. \d + $ / , '' )
135+ const baseMarkName = markName
136+ . replace ( / \. ( u s e C a t e g o r y | u s e P r o d u c t S e a r c h | u s e Q u e r y ) - \d + $ / , '' )
137+ . replace ( / \. \d + $ / , '' )
129138 const expectedMarks = [
130139 'ssr.total' ,
131- 'ssr.render-to-string' ,
140+ 'ssr.render-to-string' ,
132141 'ssr.route-matching' ,
133142 'ssr.load-component' ,
134143 'ssr.fetch-strategies' ,
0 commit comments