68f328f920
Should fill dynamic routes url with params when generate the metadata image urls. For `/(group)`, we need to normalize the path first; For dynamic routes `/[slug]`, we need to fill the params. Change the image module from `() => image` to `(prop) => image(proop)` so we can fill the runtime `params` into url Closes NEXT-932 ---------
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { createNext, FileRef } from 'e2e-utils'
|
|
import { NextInstance } from 'test/lib/next-modes/base'
|
|
import { fetchViaHTTP } from 'next-test-utils'
|
|
|
|
describe('app dir - metadata missing metadataBase', () => {
|
|
let next: NextInstance
|
|
|
|
if ((global as any).isNextDeploy) {
|
|
return it('should skip for deploy', () => {})
|
|
}
|
|
|
|
beforeAll(async () => {
|
|
next = await createNext({
|
|
skipStart: true,
|
|
dependencies: {
|
|
'@vercel/og': 'latest',
|
|
},
|
|
files: new FileRef(__dirname),
|
|
})
|
|
})
|
|
afterAll(() => next.destroy())
|
|
|
|
if (globalThis.isNextDev) {
|
|
it('should warning in development', async () => {
|
|
await next.start()
|
|
await fetchViaHTTP(next.url, '/blog')
|
|
expect(next.cliOutput).toInclude(
|
|
'metadata.metadataBase is not set and fallbacks to "http://localhost:'
|
|
)
|
|
expect(next.cliOutput).toInclude(
|
|
'please specify it in root layout to resolve absolute urls.'
|
|
)
|
|
})
|
|
} else {
|
|
it('should error in production', async () => {
|
|
await expect(next.start()).rejects.toThrow('next build failed')
|
|
expect(next.cliOutput).toInclude(
|
|
'metadata.metadataBase needs to be provided for resolving absolute URL: /blog/opengraph-image?'
|
|
)
|
|
})
|
|
}
|
|
})
|