Skip to content
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

Test for unused css modules with layout #41018

Merged
merged 4 commits into from Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,3 @@
export default function Inner() {
return <p>Inner Page</p>
}
10 changes: 10 additions & 0 deletions test/e2e/app-dir/app/app/css/css-page/unused-nested/layout.js
@@ -0,0 +1,10 @@
import { layout } from './styles'

export default function ServerLayout({ children }) {
return (
<>
<p className={layout.mod}>Layout</p>
{children}
</>
)
}
@@ -0,0 +1,3 @@
.this_should_not_be_included_in_inner_path {
color: wheat;
}
@@ -0,0 +1,3 @@
.mod {
color: tomato;
}
5 changes: 5 additions & 0 deletions test/e2e/app-dir/app/app/css/css-page/unused-nested/page.js
@@ -0,0 +1,5 @@
import { page } from './styles'

export default function Page() {
return <p className={page.this_should_not_be_included_in_inner_path}>Page</p>
}
@@ -0,0 +1,4 @@
import layout from './only-used-in-layout.module.css'
import page from './only-used-in-first-page.module.css'

export { layout, page }
15 changes: 14 additions & 1 deletion test/e2e/app-dir/index.test.ts
Expand Up @@ -1189,13 +1189,26 @@ describe('app dir', () => {

if (!isDev) {
it('should not include unused css modules in the page in prod', async () => {
const browser = await webdriver(next.url, '/css/css-page')
const browser = await webdriver(next.url, '/css/css-page/unused')
expect(
await browser.eval(
`[...document.styleSheets].some(({ rules }) => [...rules].some(rule => rule.selectorText.includes('this_should_not_be_included')))`
)
).toBe(false)
})

// TODO-APP: Should not include unused css modules in pages
it.skip('should not include unused css modules in nested pages in prod', async () => {
hanneslund marked this conversation as resolved.
Show resolved Hide resolved
const browser = await webdriver(
next.url,
'/css/css-page/unused-nested/inner'
)
expect(
await browser.eval(
`[...document.styleSheets].some(({ rules }) => [...rules].some(rule => rule.selectorText.includes('this_should_not_be_included_in_inner_path')))`
)
).toBe(false)
})
}
})

Expand Down