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

Turbopack: Update app-dir tests #76145

Merged
merged 3 commits into from
Feb 20, 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
53 changes: 24 additions & 29 deletions test/e2e/app-dir/app/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,6 @@ describe('app dir - basic', () => {
}

if (isNextStart && !process.env.NEXT_EXPERIMENTAL_COMPILE) {
it('should not have loader generated function for edge runtime', async () => {
expect(
await next.readFile('.next/server/app/dashboard/page.js')
).not.toContain('_stringifiedConfig')
expect(await next.readFile('.next/server/middleware.js')).not.toContain(
'_middlewareConfig'
)
})

if (!process.env.NEXT_EXPERIMENTAL_COMPILE) {
it('should have correct size in build output', async () => {
expect(next.cliOutput).toMatch(
Expand Down Expand Up @@ -172,28 +163,32 @@ describe('app dir - basic', () => {
})
}

it('should encode chunk path correctly', async () => {
await next.fetch('/dynamic-client/first/second')
const browser = await next.browser('/')
const requests = []
browser.on('request', (req) => {
requests.push(req.url())
})

await browser.eval('window.location.href = "/dynamic-client/first/second"')
// Turbopack has different chunking in dev/production which results in the entrypoint name not being included in the outputs.
if (!process.env.TURBOPACK) {
it('should encode chunk path correctly', async () => {
await next.fetch('/dynamic-client/first/second')
const browser = await next.browser('/')
const requests = []
browser.on('request', (req) => {
requests.push(req.url())
})

await check(async () => {
return requests.some(
(req) =>
req.includes(
encodeURI(isTurbopack ? '[category]_[id]' : '/[category]/[id]')
) && req.includes('.js')
await browser.eval(
'window.location.href = "/dynamic-client/first/second"'
)
? 'found'
: // When it fails will log out the paths.
JSON.stringify(requests)
}, 'found')
})

await browser.waitForElementByCss('#id-page-params')

expect(
requests.some(
(req) =>
req.includes(
encodeURI(isTurbopack ? '[category]_[id]' : '/[category]/[id]')
) && req.includes('.js')
)
).toBe(true)
})
}

it.each([
{ pathname: '/redirect-1' },
Expand Down
8 changes: 3 additions & 5 deletions test/turbopack-build-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1236,13 +1236,11 @@
"app dir - basic should use text/x-component for flight with edge runtime",
"app dir - basic should work for catch-all edge page",
"app dir - basic template component should render the template that holds state in a client component and reset on navigation",
"app dir - basic template component should render the template that is a server component and rerender on navigation"
],
"failed": [
"app dir - basic should encode chunk path correctly",
"app dir - basic template component should render the template that is a server component and rerender on navigation",
"app dir - basic should generate build traces correctly",
"app dir - basic should not have loader generated function for edge runtime"
"app dir - basic should encode chunk path correctly"
],
"failed": [],
"pending": [
"app dir - basic known bugs should support React fetch instrumentation client component",
"app dir - basic known bugs should support React fetch instrumentation client component client-navigation",
Expand Down
Loading