Skip to content

Commit

Permalink
Use existing test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Feb 26, 2025
1 parent 5efc77e commit 70d8b08
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 48 deletions.
13 changes: 0 additions & 13 deletions test/e2e/as-path-with-rewrites/as-path-with-rewrites.test.ts

This file was deleted.

19 changes: 0 additions & 19 deletions test/e2e/as-path-with-rewrites/next.config.js

This file was deleted.

13 changes: 0 additions & 13 deletions test/e2e/as-path-with-rewrites/pages/index.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions test/e2e/getserversideprops/app/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ module.exports = {
source: '/blog-:param',
destination: '/blog/post-3',
},
{
source: '/rewrite-source/:path+',
destination: '/rewrite-target',
},
]
},
}
2 changes: 2 additions & 0 deletions test/e2e/getserversideprops/app/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ const Page = ({ world, time, url }) => {
</Link>
<br />
<Link href="/redirect-page">to redirect-page</Link>
<br />
<Link href="/rewrite-source/foo">to rewrite-source/foo</Link>
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { GetServerSidePropsContext } from 'next'
import { useRouter } from 'next/router'

export async function getServerSideProps({ req }: GetServerSidePropsContext) {
export async function getServerSideProps({ req }) {
return { props: { url: req.url } }
}

export default function RewriteTarget({ url }: { url: string }) {
export default function RewriteTarget({ url }) {
const router = useRouter()

return (
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/getserversideprops/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,13 @@ const runTests = (isDev = false, isDeploy = false) => {
expect($('#as-path').text()).toBe('/something')
})

it('should not include rewrite query params in `asPath` and `req.url`', async () => {
const $ = await next.render$('/rewrite-source/foo')
expect($('h1').text()).toBe('rewrite-target')
expect($('#as-path').text()).toBe('/rewrite-source/foo')
expect($('#req-url').text()).toBe('/rewrite-source/foo')
})

it('should return data correctly', async () => {
const data = JSON.parse(
await renderViaHTTP(next.url, `/_next/data/${buildId}/something.json`)
Expand Down

0 comments on commit 70d8b08

Please sign in to comment.