-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0d951b
commit 9fe323a
Showing
6 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
test/e2e/html-extension-navigation-bug/html-extension-navigation-bug.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
for (const item of ['trailing-slash', 'no-trailing-slash']) { | ||
createNextDescribe( | ||
`html-extension-navigation-bug-${item}`, | ||
{ | ||
files: __dirname, | ||
nextConfig: { | ||
trailingSlash: item === 'trailing-slash', | ||
}, | ||
}, | ||
({ next }) => { | ||
describe('with .html extension', () => { | ||
it('should work when requesting the page directly', async () => { | ||
const $ = await next.render$( | ||
'/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037.html' | ||
) | ||
expect($('#text').text()).toBe( | ||
'Param found: shirts_and_tops, mens_ua_playoff_polo_2.0, 1327037.html' | ||
) | ||
}) | ||
|
||
it('should work using browser', async () => { | ||
const browser = await next.browser( | ||
'/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037.html' | ||
) | ||
expect(await browser.elementByCss('#text').text()).toBe( | ||
'Param found: shirts_and_tops, mens_ua_playoff_polo_2.0, 1327037.html' | ||
) | ||
}) | ||
|
||
it('should work when navigating', async () => { | ||
const browser = await next.browser('/') | ||
await browser.elementByCss('#with-html').click() | ||
expect(await browser.waitForElementByCss('#text').text()).toBe( | ||
'Param found: shirts_and_tops, mens_ua_playoff_polo_2.0, 1327037.html' | ||
) | ||
}) | ||
}) | ||
|
||
describe('without .html extension', () => { | ||
it('should work when requesting the page directly', async () => { | ||
const $ = await next.render$( | ||
'/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037' | ||
) | ||
expect($('#text').text()).toBe( | ||
'Param found: shirts_and_tops, mens_ua_playoff_polo_2.0, 1327037' | ||
) | ||
}) | ||
|
||
it('should work using browser', async () => { | ||
const browser = await next.browser( | ||
'/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037' | ||
) | ||
expect(await browser.elementByCss('#text').text()).toBe( | ||
'Param found: shirts_and_tops, mens_ua_playoff_polo_2.0, 1327037' | ||
) | ||
}) | ||
|
||
it('should work when navigating', async () => { | ||
const browser = await next.browser('/') | ||
await browser.elementByCss('#without-html').click() | ||
expect(await browser.waitForElementByCss('#text').text()).toBe( | ||
'Param found: shirts_and_tops, mens_ua_playoff_polo_2.0, 1327037' | ||
) | ||
}) | ||
}) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { NextRequest, NextResponse } from 'next/server' | ||
|
||
export default async function middleware(req: NextRequest) { | ||
return NextResponse.next() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { AppProps } from 'next/app' | ||
|
||
export default function App({ Component, pageProps }: AppProps) { | ||
return <Component {...pageProps} /> | ||
} |
13 changes: 13 additions & 0 deletions
13
test/e2e/html-extension-navigation-bug/pages/_document.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Html, Head, Main, NextScript } from 'next/document' | ||
|
||
export default function Document() { | ||
return ( | ||
<Html lang="en"> | ||
<Head /> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable no-console */ | ||
/* eslint-disable no-param-reassign */ | ||
|
||
import Link from 'next/link' | ||
|
||
export default function Test() { | ||
return ( | ||
<> | ||
<ul> | ||
<li> | ||
<Link | ||
id="with-html" | ||
href="/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037.html" | ||
> | ||
Does not work | ||
</Link> | ||
</li> | ||
<li> | ||
<Link | ||
id="without-html" | ||
href="/product/shirts_and_tops/mens_ua_playoff_polo_2.0/1327037" | ||
> | ||
Works | ||
</Link> | ||
</li> | ||
</ul> | ||
</> | ||
) | ||
} |
27 changes: 27 additions & 0 deletions
27
test/e2e/html-extension-navigation-bug/pages/product/[...product-params].tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { GetServerSideProps } from 'next' | ||
import React from 'react' | ||
|
||
export interface ProductPageProps { | ||
test: string | ||
} | ||
|
||
const ProductPage = (params: ProductPageProps) => { | ||
return ( | ||
<> | ||
<h1 id="text">Param found: {params.test}</h1> | ||
</> | ||
) | ||
} | ||
|
||
export const getServerSideProps: GetServerSideProps = async ({ params }) => { | ||
const joined = Array.isArray(params['product-params']) | ||
? params['product-params'].join(', ') | ||
: params['product-params'] | ||
return { | ||
props: { | ||
test: joined ? joined : 'Not Found', | ||
}, | ||
} | ||
} | ||
|
||
export default ProductPage |