Skip to content

Commit 5351a9b

Browse files
committed
Update tests due to link and img preload
1 parent f730219 commit 5351a9b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,13 @@ describe('app dir - css', () => {
394394
'hello world!'
395395
)
396396

397-
// there should be only 1 preload link
398397
expect(
399398
await browser.eval(
400399
`(() => {
401400
const tags = document.querySelectorAll('link[rel="preload"][href^="/_next/static/css"]')
402401
const counts = new Map();
403402
for (const tag of tags) {
404-
counts.set(tag.href, (counts.get(tag.href) || 0) + 1)
403+
counts.set(tag.href + '|' + tag.as, (counts.get(tag.href) || 0) + 1)
405404
}
406405
return Math.max(...counts.values())
407406
})()`
@@ -483,7 +482,7 @@ describe('app dir - css', () => {
483482
if (process.env.IS_TURBOPACK_TEST) {
484483
expect(
485484
initialHtml.match(/app_css_css-duplicate-2_[\w]+\.css/g).length
486-
).toBe(5)
485+
).toBe(7)
487486
} else {
488487
// Even if it's deduped by Float, it should still only be included once in the payload.
489488

@@ -499,18 +498,26 @@ describe('app dir - css', () => {
499498

500499
// Heavy on testing React implementation details.
501500
// Assertions may change often but what needs to be checked on change is if styles are needlessly duplicated in Flight data
502-
// There are 3 matches, one for the rendered <link> (HTML), one for Float preload (Flight) and one for the <link> inside Flight payload.
501+
// There are 5 matches, one for the rendered <link> (HTML), one for Float preload (Flight), one for the <link> inside Flight payload and two preload instructions for those links.
503502
// And there is one match for the not found style
504503
expect(matches).toEqual([
505504
'/_next/static/css/app/css/css-duplicate-2/layout.css',
506505
'/_next/static/css/app/css/css-duplicate-2/layout.css',
507506
'/_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/css-duplicate-2/layout.css',
509+
'/_next/static/css/app/css/layout.css',
510+
'/_next/static/css/app/css/layout.css',
508511
'/_next/static/css/app/css/layout.css',
509512
'/_next/static/css/app/css/layout.css',
510513
'/_next/static/css/app/css/layout.css',
511514
'/_next/static/css/app/layout.css',
512515
'/_next/static/css/app/layout.css',
513516
'/_next/static/css/app/layout.css',
517+
'/_next/static/css/app/layout.css',
518+
'/_next/static/css/app/layout.css',
519+
'/_next/static/css/app/not-found.css',
520+
'/_next/static/css/app/not-found.css',
514521
'/_next/static/css/app/not-found.css',
515522
])
516523
}

0 commit comments

Comments
 (0)