Unverified Commit e1e64e07 authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Test for unused css modules with layout (#41018)

Similar to #40996.

This PR only adds a failing test that should pass. Also updates wrong url of previous test.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent 5162b64c
export default function Inner() {
return <p>Inner Page</p>
}
import { layout } from './styles'
export default function ServerLayout({ children }) {
return (
<>
<p className={layout.mod}>Layout</p>
{children}
</>
)
}
.this_should_not_be_included_in_inner_path {
color: wheat;
}
import { page } from './styles'
export default function Page() {
return <p className={page.this_should_not_be_included_in_inner_path}>Page</p>
}
import layout from './only-used-in-layout.module.css'
import page from './only-used-in-first-page.module.css'
export { layout, page }
...@@ -1261,13 +1261,26 @@ describe('app dir', () => { ...@@ -1261,13 +1261,26 @@ describe('app dir', () => {
if (!isDev) { if (!isDev) {
it('should not include unused css modules in the page in prod', async () => { 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( expect(
await browser.eval( await browser.eval(
`[...document.styleSheets].some(({ rules }) => [...rules].some(rule => rule.selectorText.includes('this_should_not_be_included')))` `[...document.styleSheets].some(({ rules }) => [...rules].some(rule => rule.selectorText.includes('this_should_not_be_included')))`
) )
).toBe(false) ).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 () => {
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)
})
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment