Skip to content

Commit ecf970a

Browse files
authored
[test] Robuster extraction off CSS sources in Flight chunks (#80243)
1 parent f5cb7b1 commit ecf970a

File tree

1 file changed

+17
-35
lines changed

1 file changed

+17
-35
lines changed

test/e2e/app-dir/app-css/index.test.ts

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { nextTestSetup } from 'e2e-utils'
22
import { check } from 'next-test-utils'
33

4-
const isPPREnabledByDefault = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
5-
64
describe('app dir - css', () => {
75
const { next, isNextDev, skipped } = nextTestSetup({
86
files: __dirname,
@@ -490,47 +488,31 @@ describe('app dir - css', () => {
490488
// Even if it's deduped by Float, it should still only be included once in the payload.
491489

492490
const matches = initialHtml
493-
.match(/\/_next\/static\/css\/.+?\.css/g)
494491
// The same css chunk could be split into 2 RSC script
495-
// normalize "/_next/static/css/app/\"])</script><script>self.__next_f.push([1,\"not-found.css"
492+
// e.g.
493+
// "/_next/static/css/app/"])</script><script>self.__next_f.push([1,"not-found.css"
494+
// "/_next/stati"])</script><script>self.__next_f.push([1,"c/css/app/not-found.css?v=1749205445967"
496495
// to "/_next/static/css/app/not-found.css"
497-
.map((href) =>
498-
href.replace('"])</script><script>self.__next_f.push([1,"', '')
499-
)
496+
.replaceAll('"])</script><script>self.__next_f.push([1,"', '')
497+
.match(/\/_next\/static\/css\/.+?\.css/g)
500498
.sort()
501499

502500
// Heavy on testing React implementation details.
503501
// Assertions may change often but what needs to be checked on change is if styles are needlessly duplicated in Flight data
504502
// There are 3 matches, one for the rendered <link> (HTML), one for Float preload (Flight) and one for the <link> inside Flight payload.
505503
// And there is one match for the not found style
506-
if (isPPREnabledByDefault) {
507-
expect(matches).toEqual([
508-
// may be split across chunks when we bump React
509-
'/_next/static/css/app/css/css-duplicate-2/layout.css',
510-
'/_next/static/css/app/css/css-duplicate-2/layout.css',
511-
'/_next/static/css/app/css/css-duplicate-2/layout.css',
512-
'/_next/static/css/app/css/layout.css',
513-
'/_next/static/css/app/css/layout.css',
514-
'/_next/static/css/app/css/layout.css',
515-
'/_next/static/css/app/layout.css',
516-
'/_next/static/css/app/layout.css',
517-
'/_next/static/css/app/layout.css',
518-
'/_next/static/css/app/not-found.css',
519-
])
520-
} else {
521-
expect(matches).toEqual([
522-
'/_next/static/css/app/css/css-duplicate-2/layout.css',
523-
'/_next/static/css/app/css/css-duplicate-2/layout.css',
524-
'/_next/static/css/app/css/css-duplicate-2/layout.css',
525-
'/_next/static/css/app/css/layout.css',
526-
'/_next/static/css/app/css/layout.css',
527-
'/_next/static/css/app/css/layout.css',
528-
'/_next/static/css/app/layout.css',
529-
'/_next/static/css/app/layout.css',
530-
'/_next/static/css/app/layout.css',
531-
'/_next/static/css/app/not-found.css',
532-
])
533-
}
504+
expect(matches).toEqual([
505+
'/_next/static/css/app/css/css-duplicate-2/layout.css',
506+
'/_next/static/css/app/css/css-duplicate-2/layout.css',
507+
'/_next/static/css/app/css/css-duplicate-2/layout.css',
508+
'/_next/static/css/app/css/layout.css',
509+
'/_next/static/css/app/css/layout.css',
510+
'/_next/static/css/app/css/layout.css',
511+
'/_next/static/css/app/layout.css',
512+
'/_next/static/css/app/layout.css',
513+
'/_next/static/css/app/layout.css',
514+
'/_next/static/css/app/not-found.css',
515+
])
534516
}
535517
})
536518

0 commit comments

Comments
 (0)