Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Apr 19, 2023
1 parent 1249bd1 commit d7b2f66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
24 changes: 13 additions & 11 deletions test/e2e/app-dir/metadata-dynamic-routes/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions test/e2e/app-dir/metadata/metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down

0 comments on commit d7b2f66

Please sign in to comment.