Skip to content

Commit

Permalink
Add failing test for vercel#45956
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Feb 18, 2023
1 parent 4487abd commit 4b935b4
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/e2e/app-dir/route-page-manifest-bug/app/abc/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { NextResponse } from 'next/server'

export async function GET() {
return NextResponse.json({ url: 'https://www.example.com' })
}
8 changes: 8 additions & 0 deletions test/e2e/app-dir/route-page-manifest-bug/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function RootLayout({ children }) {
return (
<html>
<head />
<body>{children}</body>
</html>
)
}
5 changes: 5 additions & 0 deletions test/e2e/app-dir/route-page-manifest-bug/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use client'

export default function Home() {
return <h1 id="page-title">Page that would break</h1>
}
8 changes: 8 additions & 0 deletions test/e2e/app-dir/route-page-manifest-bug/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
experimental: { appDir: true },
}

module.exports = nextConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'

createNextDescribe(
'route-page-manifest-bug',
{
files: __dirname,
},
({ next }) => {
// Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API.
it('should work when requesting route handler after page', async () => {
const browser = await next.browser('/')
expect(await browser.elementByCss('#page-title').text()).toBe(
'Page that would break'
)
await browser.eval('window.location.href = "/abc"')
await check(
() => browser.eval('document.body.textContent'),
'{"url":"https://www.example.com"}'
)
await browser.refresh()
await check(
() => browser.eval('document.body.textContent'),
'{"url":"https://www.example.com"}'
)
await browser.refresh()
await check(
() => browser.eval('document.body.textContent'),
'{"url":"https://www.example.com"}'
)
await browser.refresh()
await check(
() => browser.eval('document.body.textContent'),
'{"url":"https://www.example.com"}'
)

await browser.back()
expect(await browser.waitForElementByCss('#page-title').text()).toBe(
'Page that would break'
)
await browser.refresh()
expect(await browser.waitForElementByCss('#page-title').text()).toBe(
'Page that would break'
)
await browser.refresh()
expect(await browser.waitForElementByCss('#page-title').text()).toBe(
'Page that would break'
)
})
}
)

0 comments on commit 4b935b4

Please sign in to comment.