Skip to content

Add an e2e test for the css serving issue #81683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/e2e/app-dir/initial-css-not-found/app/(default)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ReactNode } from 'react'
import styles from '../styles.module.css'

export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<body className={styles.foo}>{children}</body>
</html>
)
}
3 changes: 3 additions & 0 deletions test/e2e/app-dir/initial-css-not-found/app/(default)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p>hello world</p>
}
5 changes: 5 additions & 0 deletions test/e2e/app-dir/initial-css-not-found/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { ReactNode } from 'react'

export default function Layout({ children }: { children: ReactNode }) {
return children
}
18 changes: 18 additions & 0 deletions test/e2e/app-dir/initial-css-not-found/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import styles from './styles.module.css'

/**
* The mere existence of a not found page importing the same css as a layout used to prevent it from being served.
*
* See https://github.com/vercel/next.js/issues/77861 and https://github.com/vercel/next.js/issues/79535
*/
export default function NotFoundPage() {
return (
<html lang="en">
<body className={styles.foo}>
<main>
<h1>Page not found</h1>
</main>
</body>
</html>
)
}
3 changes: 3 additions & 0 deletions test/e2e/app-dir/initial-css-not-found/app/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.foo {
color: red;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { nextTestSetup } from 'e2e-utils'

describe('initial-css-not-found', () => {
const { next } = nextTestSetup({
files: __dirname,
})

// Regression test for a bug where the existence of a not-found page would prevent the css from being discovered.
// See https://github.com/vercel/next.js/issues/77861 and https://github.com/vercel/next.js/issues/79535
it('should serve styles', async () => {
const browser = await next.browser('/')

expect(
await browser.eval(
`window.getComputedStyle(document.querySelector('body')).color`
)
).toBe(
// This only fails in production turbopack builds
process.env.IS_TURBOPACK_TEST && process.env.NEXT_TEST_MODE !== 'dev'
? 'rgb(0, 0, 0)'
: 'rgb(255, 0, 0)'
)
})
})
6 changes: 6 additions & 0 deletions test/e2e/app-dir/initial-css-not-found/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}

module.exports = nextConfig
Loading