Skip to content

Commit c503663

Browse files
committed
chore: added test for basePath w/ grouping
1 parent a5857d6 commit c503663

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/templates/server.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jest.mock(
6868
jest.mock(
6969
'routes-manifest.json',
7070
() => ({
71+
basePath: '',
7172
dynamicRoutes: [
7273
{
7374
page: '/posts/[title]',
@@ -88,6 +89,12 @@ jest.mock(
8889
},
8990
],
9091
staticRoutes: [
92+
{
93+
namedRegex: '^/(?:/)?$',
94+
page: '/',
95+
regex: '^/(?:/)?$',
96+
routeKeys: {},
97+
},
9198
{
9299
page: '/non-i18n/with-revalidate',
93100
regex: '^/non-i18n/with-revalidate(?:/)?$',
@@ -101,11 +108,23 @@ jest.mock(
101108
namedRegex: '^/i18n/with-revalidate(?:/)?$',
102109
},
103110
],
111+
redirects: [
112+
{
113+
basePath: false,
114+
destination: '/docs/',
115+
internal: true,
116+
locale: false,
117+
regex: '^/docs$',
118+
source: '/docs',
119+
statusCode: 308,
120+
},
121+
],
104122
}),
105123
{ virtual: true },
106124
)
107125

108126
const appPathsManifest = {
127+
'/(group)/page': 'app/(group)/page.js',
109128
'/blog/(test)/[author]/[slug]/page': 'app/blog/[author]/[slug]/page.js',
110129
}
111130

@@ -312,4 +331,19 @@ describe('the netlify next server', () => {
312331
// eslint-disable-next-line no-underscore-dangle
313332
expect(process.env.__NEXT_PRIVATE_PREBUNDLED_REACT).toBe('experimental')
314333
})
334+
335+
it('assigns correct prebundled react with basePath config using appdir', async () => {
336+
const netlifyNextServer = new NetlifyNextServer({ conf: { experimental: { appDir: true }, basePath: '/docs' } }, {})
337+
const requestHandler = netlifyNextServer.getRequestHandler()
338+
339+
const { req: mockReq, res: mockRes } = createRequestResponseMocks({
340+
url: '/docs',
341+
})
342+
343+
// @ts-expect-error - Types are incorrect for `MockedResponse`
344+
await requestHandler(new NodeNextRequest(mockReq), new NodeNextResponse(mockRes))
345+
346+
// eslint-disable-next-line no-underscore-dangle
347+
expect(process.env.__NEXT_PRIVATE_PREBUNDLED_REACT).toBe('next')
348+
})
315349
})

0 commit comments

Comments
 (0)