11import { nextTestSetup } from 'e2e-utils'
22
3- describe ( 'react-performance-track' , ( ) => {
3+ describe . each ( [
4+ {
5+ description : 'caching enabled' ,
6+ enableCache : true ,
7+ } ,
8+ {
9+ description : 'caching disabled' ,
10+ enableCache : false ,
11+ } ,
12+ ] ) ( 'react-performance-track - $description' , ( { enableCache } ) => {
413 // false is the default when visiting pages as an ordinary user.
514 // true is the default when having Chrome DevTools open.
615 // Hardcoded for now since most of the actual behavior is not intended.
7- const disableCache = false
8- const extraHTTPHeaders = disableCache
9- ? { 'Cache-Control' : 'no-cache' }
10- : undefined
16+ const extraHTTPHeaders = enableCache
17+ ? undefined
18+ : { 'Cache-Control' : 'no-cache' }
1119
1220 const { next } = nextTestSetup ( {
1321 files : __dirname ,
1422 } )
1523
24+ // We only get the "Prefetchable" label when caches are enabled.
25+ // If caches are disabled, the environement will be "Server",
26+ // which react doesn't display because it's the default.
27+ // So we can't check the label, but we'll still test that the API resulted in an IO entry.
28+ const PREFETCHABLE_LABEL = enableCache ? ' [Prefetchable]' : ''
29+
1630 it ( 'should show setTimeout' , async ( ) => {
1731 const browser = await next . browser ( '/set-timeout' , { extraHTTPHeaders } )
1832 await browser . elementByCss ( '[data-react-server-requests-done]' , {
@@ -61,7 +75,7 @@ describe('react-performance-track', () => {
6175 expect ( track ) . toEqual (
6276 expect . arrayContaining ( [
6377 {
64- name : ' \u200bparams [Prefetchable]' ,
78+ name : ` \u200bparams${ PREFETCHABLE_LABEL } ` ,
6579 properties : [ ] ,
6680 } ,
6781 ] )
@@ -80,7 +94,7 @@ describe('react-performance-track', () => {
8094 expect ( track ) . toEqual (
8195 expect . arrayContaining ( [
8296 {
83- name : ' \u200bsearchParams [Prefetchable]' ,
97+ name : ` \u200bsearchParams${ PREFETCHABLE_LABEL } ` ,
8498 properties : [ ] ,
8599 } ,
86100 ] )
@@ -97,7 +111,7 @@ describe('react-performance-track', () => {
97111 expect ( track ) . toEqual (
98112 expect . arrayContaining ( [
99113 {
100- name : ' \u200bcookies [Prefetchable]' ,
114+ name : ` \u200bcookies${ PREFETCHABLE_LABEL } ` ,
101115 properties : [ ] ,
102116 } ,
103117 // TODO: The error message makes this seem like it shouldn't pop up here.
@@ -123,7 +137,7 @@ describe('react-performance-track', () => {
123137 } )
124138
125139 const track = await browser . eval ( 'window.reactServerRequests.getSnapshot()' )
126- // TODO: Should include "draftMode [Prefetchable]" .
140+ // draftMode should not show up as IO .
127141 expect ( track ) . toEqual ( [
128142 {
129143 name : '\u200b' ,
@@ -142,7 +156,7 @@ describe('react-performance-track', () => {
142156 expect ( track ) . toEqual (
143157 expect . arrayContaining ( [
144158 {
145- name : ' \u200bheaders [Prefetchable]' ,
159+ name : ` \u200bheaders${ PREFETCHABLE_LABEL } ` ,
146160 properties : [ ] ,
147161 } ,
148162 // TODO: The error message makes this seem like it shouldn't pop up here.
0 commit comments