Unverified Commit 7e34b4cf authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Tweak flakey metadata error tests (#66060)

Seems we weren't grabbing the latest cli output inside of `check` so if
it wasn't ready by the time the first check successive checks wouldn't
have it either.

x-ref:
https://github.com/vercel/next.js/actions/runs/9182806177/job/25253023758
x-ref:
https://github.com/vercel/next.js/actions/runs/9182324607/job/25254072867
parent d299bbf4
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
describe('css-client-side-nav-parallel-routes', () => { describe('css-client-side-nav-parallel-routes', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
...@@ -9,6 +10,9 @@ describe('css-client-side-nav-parallel-routes', () => { ...@@ -9,6 +10,9 @@ describe('css-client-side-nav-parallel-routes', () => {
it('should apply styles after navigation', async () => { it('should apply styles after navigation', async () => {
const browser = await next.browser('/source') const browser = await next.browser('/source')
await browser.elementByCss('a').click() await browser.elementByCss('a').click()
// transition might not be instant so we wrap in retry
retry(async () => {
expect( expect(
await browser.elementByCss('#global').getComputedCss('background-color') await browser.elementByCss('#global').getComputedCss('background-color')
).toBe('rgb(0, 255, 0)') ).toBe('rgb(0, 255, 0)')
...@@ -16,4 +20,5 @@ describe('css-client-side-nav-parallel-routes', () => { ...@@ -16,4 +20,5 @@ describe('css-client-side-nav-parallel-routes', () => {
await browser.elementByCss('#module').getComputedCss('background-color') await browser.elementByCss('#module').getComputedCss('background-color')
).toBe('rgb(0, 255, 0)') ).toBe('rgb(0, 255, 0)')
}) })
})
}) })
...@@ -463,17 +463,14 @@ describe('app dir - metadata dynamic routes', () => { ...@@ -463,17 +463,14 @@ describe('app dir - metadata dynamic routes', () => {
} }
` `
const outputBeforeFetch = next.cliOutput + '' const originalOutputIndex = next.cliOutput.length
await next.patchFile(iconFilePath, contentMissingIdProperty) await next.patchFile(iconFilePath, contentMissingIdProperty)
await next.fetch('/metadata-base/unset/icon/100') await next.fetch('/metadata-base/unset/icon/100')
const outputAfterFetch = next.cliOutput + ''
const output = outputAfterFetch.replace(outputBeforeFetch, '')
try { try {
await check(async () => { await check(async () => {
expect(output).toContain( expect(next.cliOutput.substring(originalOutputIndex)).toContain(
`id property is required for every item returned from generateImageMetadata` `id property is required for every item returned from generateImageMetadata`
) )
return 'success' return 'success'
...@@ -504,17 +501,14 @@ describe('app dir - metadata dynamic routes', () => { ...@@ -504,17 +501,14 @@ describe('app dir - metadata dynamic routes', () => {
] ]
}` }`
const outputBeforeFetch = next.cliOutput + '' const originalOutputIndex = next.cliOutput.length
await next.patchFile(sitemapFilePath, contentMissingIdProperty) await next.patchFile(sitemapFilePath, contentMissingIdProperty)
await next.fetch('/metadata-base/unset/sitemap/0') await next.fetch('/metadata-base/unset/sitemap/0')
const outputAfterFetch = next.cliOutput + ''
const output = outputAfterFetch.replace(outputBeforeFetch, '')
try { try {
await check(async () => { await check(async () => {
expect(output).toContain( expect(next.cliOutput.substring(originalOutputIndex)).toContain(
`id property is required for every item returned from generateSitemaps` `id property is required for every item returned from generateSitemaps`
) )
return 'success' return 'success'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment