diff --git a/test/e2e/app-dir/metadata-dynamic-routes/index.test.ts b/test/e2e/app-dir/metadata-dynamic-routes/index.test.ts index 64657c14fad35..0f30efe5a11e6 100644 --- a/test/e2e/app-dir/metadata-dynamic-routes/index.test.ts +++ b/test/e2e/app-dir/metadata-dynamic-routes/index.test.ts @@ -276,21 +276,23 @@ createNextDescribe( expect(twitterDescription).toBe('Twitter - This is a Next.js App') // Should prefer to pick up deployment url for metadata routes + let ogImageUrlPattern + let twitterImageUrlPattern if (isNextDeploy) { // absolute urls - expect(ogImageUrl).toMatch( - /https:\/\/\w+.vercel.app\/opengraph-image\?/ - ) - expect(twitterImageUrl).toMatch( - /https:\/\/\w+.vercel.app\/twitter-image\?/ - ) + ogImageUrlPattern = /https:\/\/\w+.vercel.app\/opengraph-image\?/ + twitterImageUrlPattern = /https:\/\/\w+.vercel.app\/twitter-image\?/ + } else if (isNextStart) { + // configured metadataBase for next start + ogImageUrlPattern = /https:\/\/mydomain.com\/opengraph-image\?/ + twitterImageUrlPattern = /https:\/\/mydomain.com\/twitter-image\?/ } else { - // absolute urls - expect(ogImageUrl).toMatch(/http:\/\/localhost:\d+\/opengraph-image\?/) - expect(twitterImageUrl).toMatch( - /http:\/\/localhost:\d+\/twitter-image\?/ - ) + // localhost for dev + ogImageUrlPattern = /http:\/\/localhost:\d+\/opengraph-image\?/ + twitterImageUrlPattern = /http:\/\/localhost:\d+\/twitter-image\?/ } + expect(ogImageUrl).toMatch(ogImageUrlPattern) + expect(twitterImageUrl).toMatch(twitterImageUrlPattern) expect(ogImageUrl).toMatch(hashRegex) expect(twitterImageUrl).toMatch(hashRegex) diff --git a/test/e2e/app-dir/metadata/metadata.test.ts b/test/e2e/app-dir/metadata/metadata.test.ts index ef759b0555b00..c9095777a7ffe 100644 --- a/test/e2e/app-dir/metadata/metadata.test.ts +++ b/test/e2e/app-dir/metadata/metadata.test.ts @@ -487,8 +487,11 @@ createNextDescribe( 'og:image:height': '114', 'og:image:type': 'image/png', 'og:image:alt': 'A alt txt for og', - 'og:image': - 'https://example.com/opengraph/static/opengraph-image.png?b76e8f0282c93c8e', + 'og:image': isNextDev + ? expect.stringMatching( + /http:\/\/localhost:\d+\/opengraph\/static\/opengraph-image.png\?b76e8f0282c93c8e/ + ) + : 'https://example.com/opengraph/static/opengraph-image.png?b76e8f0282c93c8e', }) await match('meta', 'name', 'content', {