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
Showing
3 changed files
with
35 additions
and
34 deletions.
There are no files selected for viewing
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
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
49 changes: 20 additions & 29 deletions
49
test/e2e/app-dir/metadata-missing-metadata-base/index.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 |
---|---|---|
@@ -1,31 +1,22 @@ | ||
import { createNext, FileRef } from 'e2e-utils' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
import { fetchViaHTTP } from 'next-test-utils' | ||
import { createNextDescribe } from 'e2e-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, | ||
files: new FileRef(__dirname), | ||
createNextDescribe( | ||
'app dir - metadata missing metadataBase', | ||
{ | ||
files: __dirname, | ||
skipStart: true, | ||
skipDeployment: true, | ||
}, | ||
({ next }) => { | ||
it('should fallback to localhost if metadataBase is missing for absolute urls resolving', async () => { | ||
await next.fetch('/blog') | ||
expect(next.cliOutput).toInclude( | ||
'metadata.metadataBase is not set for resolving url "/blog/opengraph-image?' | ||
) | ||
expect(next.cliOutput).toInclude(', fallbacks to "http://localhost:') | ||
expect(next.cliOutput).toInclude( | ||
'. See https://beta.nextjs.org/docs/api-reference/metadata#metadatabase' | ||
) | ||
}) | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should fallback to localhost if metadataBase is missing for absolute urls resolving', async () => { | ||
await next.start() | ||
await fetchViaHTTP(next.url, '/blog') | ||
expect(next.cliOutput).toInclude( | ||
'metadata.metadataBase is not set for resolving url "/blog/opengraph-image?' | ||
) | ||
expect(next.cliOutput).toInclude(', fallbacks to "http://localhost:') | ||
expect(next.cliOutput).toInclude( | ||
'. See https://beta.nextjs.org/docs/api-reference/metadata#metadatabase' | ||
) | ||
}) | ||
}) | ||
} | ||
) |