-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: when metadatabase is set we should not warn (#74840)
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 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
File renamed without changes.
73 changes: 73 additions & 0 deletions
73
test/e2e/app-dir/metadata-warnings/metadata-warnings-with-metadatabase.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,73 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
const METADATA_BASE_WARN_STRING = | ||
'metadataBase property in metadata export is not set for resolving social open graph or twitter images,' | ||
|
||
describe('app dir - metadata missing metadataBase', () => { | ||
const { next, isNextDev, skipped } = nextTestSetup({ | ||
files: __dirname, | ||
skipDeployment: true, | ||
overrideFiles: { | ||
'app/layout.js': ` | ||
export default function Layout({ children }) { | ||
return ( | ||
<div> | ||
{children} | ||
</div> | ||
) | ||
} | ||
export const metadata = { | ||
metadataBase: new URL('https://example.com'), | ||
} | ||
`, | ||
}, | ||
}) | ||
|
||
if (skipped) { | ||
return | ||
} | ||
|
||
// If it's start mode, we get the whole logs since they're from build process. | ||
// If it's development mode, we get the logs after request | ||
function getCliOutput(logStartPosition: number) { | ||
return isNextDev ? next.cliOutput.slice(logStartPosition) : next.cliOutput | ||
} | ||
|
||
it('should not show warning in vercel deployment output in default build output mode', async () => { | ||
const logStartPosition = next.cliOutput.length | ||
await next.fetch('/og-image-convention') | ||
const output = getCliOutput(logStartPosition) | ||
|
||
expect(output).not.toInclude(METADATA_BASE_WARN_STRING) | ||
}) | ||
|
||
it('should not warn metadataBase is missing and a relative URL is used', async () => { | ||
const logStartPosition = next.cliOutput.length | ||
await next.fetch('/relative-url-og') | ||
const output = getCliOutput(logStartPosition) | ||
|
||
expect(output).not.toInclude(METADATA_BASE_WARN_STRING) | ||
}) | ||
|
||
it('should warn for unsupported metadata properties', async () => { | ||
const logStartPosition = next.cliOutput.length | ||
await next.fetch('/unsupported-metadata') | ||
const output = getCliOutput(logStartPosition) | ||
expect(output).toInclude( | ||
'Unsupported metadata themeColor is configured in metadata export in /unsupported-metadata. Please move it to viewport' | ||
) | ||
expect(output).toInclude( | ||
'Read more: https://nextjs.org/docs/app/api-reference/functions/generate-viewport' | ||
) | ||
}) | ||
|
||
it('should not warn for viewport properties during manually merging metadata', async () => { | ||
const outputLength = next.cliOutput.length | ||
await next.fetch('/merge') | ||
// Should not log the unsupported metadata viewport warning in the output | ||
// during merging the metadata, if the value is still nullable. | ||
const output = next.cliOutput.slice(outputLength) | ||
expect(output).not.toContain('Unsupported metadata viewport') | ||
}) | ||
}) |