Skip to content

Commit

Permalink
Turbopack build: Skip CSS test that checks webpack behavior (#68935)
Browse files Browse the repository at this point in the history
## What?

Skips a test that checks webpack specific behavior.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
  • Loading branch information
timneutkens authored Aug 15, 2024
1 parent a4438fe commit bb0ed86
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 67 deletions.
132 changes: 68 additions & 64 deletions test/integration/css/test/css-rendering.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,88 +228,92 @@ module.exports = {
)
})

describe('CSS Cleanup on Render Failure', () => {
const appDir = join(fixturesDir, 'transition-cleanup')
const nextConfig = new File(join(appDir, 'next.config.js'))
// Turbopack keeps styles which mirrors development with webpack. This test only checks a behavior for webpack.
;(process.env.TURBOPACK ? describe.skip : describe)(
'CSS Cleanup on Render Failure',
() => {
const appDir = join(fixturesDir, 'transition-cleanup')
const nextConfig = new File(join(appDir, 'next.config.js'))

describe.each([true, false])(`useLightnincsss(%s)`, (useLightningcss) => {
beforeAll(async () => {
nextConfig.write(
`
describe.each([true, false])(`useLightnincsss(%s)`, (useLightningcss) => {
beforeAll(async () => {
nextConfig.write(
`
const config = require('../next.config.js');
module.exports = {
...config,
experimental: {
useLightningcss: ${useLightningcss}
}
}`
)
})

let app, appPort

function tests() {
async function checkBlackTitle(browser) {
await browser.waitForElementByCss('#black-title')
const titleColor = await browser.eval(
`window.getComputedStyle(document.querySelector('#black-title')).color`
)
expect(titleColor).toBe('rgb(17, 17, 17)')
}
})

it('not have intermediary page styles on error rendering', async () => {
const browser = await webdriver(appPort, '/')
try {
await checkBlackTitle(browser)
let app, appPort

const currentPageStyles = await browser.eval(
`document.querySelector('link[rel=stylesheet][data-n-p]')`
function tests() {
async function checkBlackTitle(browser) {
await browser.waitForElementByCss('#black-title')
const titleColor = await browser.eval(
`window.getComputedStyle(document.querySelector('#black-title')).color`
)
expect(currentPageStyles).toBeDefined()
expect(titleColor).toBe('rgb(17, 17, 17)')
}

// Navigate to other:
await browser.waitForElementByCss('#link-other').click()
await check(
() => browser.eval(`document.body.innerText`),
'Application error: a client-side exception has occurred (see the browser console for more information).',
true
)
it('not have intermediary page styles on error rendering', async () => {
const browser = await webdriver(appPort, '/')
try {
await checkBlackTitle(browser)

const newPageStyles = await browser.eval(
`document.querySelector('link[rel=stylesheet][data-n-p]')`
)
expect(newPageStyles).toBeFalsy()
const currentPageStyles = await browser.eval(
`document.querySelector('link[rel=stylesheet][data-n-p]')`
)
expect(currentPageStyles).toBeDefined()

// Navigate to other:
await browser.waitForElementByCss('#link-other').click()
await check(
() => browser.eval(`document.body.innerText`),
'Application error: a client-side exception has occurred (see the browser console for more information).',
true
)

const allPageStyles = await browser.eval(
`document.querySelector('link[rel=stylesheet]')`
)
expect(allPageStyles).toBeFalsy()
} finally {
await browser.close()
}
})
}
const newPageStyles = await browser.eval(
`document.querySelector('link[rel=stylesheet][data-n-p]')`
)
expect(newPageStyles).toBeFalsy()

;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
beforeAll(async () => {
await nextBuild(appDir, [], {})
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
const allPageStyles = await browser.eval(
`document.querySelector('link[rel=stylesheet]')`
)
expect(allPageStyles).toBeFalsy()
} finally {
await browser.close()
}
})

tests()
}
)
})
})

;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
beforeAll(async () => {
await nextBuild(appDir, [], {})
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})

tests()
}
)
})
}
)

describe('Page reload on CSS missing', () => {
const appDir = join(fixturesDir, 'transition-reload')
Expand Down
7 changes: 4 additions & 3 deletions test/turbopack-build-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7952,12 +7952,13 @@
"CSS Support production mode CSS Import from node_modules useLightnincsss(true) should fail the build"
],
"failed": [
"CSS Support CSS Cleanup on Render Failure useLightnincsss(false) production mode not have intermediary page styles on error rendering",
"CSS Support CSS Cleanup on Render Failure useLightnincsss(true) production mode not have intermediary page styles on error rendering",
"CSS Support Page reload on CSS missing useLightnincsss(false) production mode should fall back to server-side transition on missing CSS",
"CSS Support Page reload on CSS missing useLightnincsss(true) production mode should fall back to server-side transition on missing CSS"
],
"pending": [],
"pending": [
"CSS Support CSS Cleanup on Render Failure useLightnincsss(false) production mode not have intermediary page styles on error rendering",
"CSS Support CSS Cleanup on Render Failure useLightnincsss(true) production mode not have intermediary page styles on error rendering"
],
"flakey": [],
"runtimeError": false
},
Expand Down

0 comments on commit bb0ed86

Please sign in to comment.