Unverified Commit 9f181bd1 authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

[test] Unflake rendering indicator test & skip building indicator tests (#91650)

[Flakiness
metric](https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.name%3A%28%22Build%20Activity%20Indicator%20Enabled%20-%20%28app%29%20Shows%20build%20indicator%20when%20page%20is%20built%20from%20modifying%22%20OR%20%22Build%20Activity%20Indicator%20Enabled%20-%20%28pages%29%20Shows%20build%20indicator%20when%20page%20is%20built%20from%20modifying%22%20OR%20%22Dev%20Rendering%20Indicator%20Shows%20build%20indicator%20when%20page%20is%20built%20from%20modifying%22%29%20%40test.status%3Afail&agg_m=count&agg_m_source=base&agg_t=count&fromUser=false&index=citest&start=1773322068865&end=1773926868865&paused=false)

In #85083 we introduced a delay of 400 ms before showing the
building/rendering indicator, to avoid flashing it for fast operations.
For now, we skip the building indicator tests because our simple test
apps usually compile much faster than that, and we haven't found a good
way to reliably test the indicator without flakiness. We do keep the
rendering indicator test, but increase the timeout in the pages to
ensure the indicator is shown for long enough to be detected by the
test.
parent 8e9f9514
...@@ -4,7 +4,7 @@ import { setTimeout } from 'timers/promises' ...@@ -4,7 +4,7 @@ import { setTimeout } from 'timers/promises'
export default async function Page() { export default async function Page() {
await connection() await connection()
await setTimeout(100) await setTimeout(1000)
return ( return (
<> <>
......
...@@ -4,7 +4,7 @@ import { setTimeout } from 'timers/promises' ...@@ -4,7 +4,7 @@ import { setTimeout } from 'timers/promises'
export default async function Page() { export default async function Page() {
await connection() await connection()
await setTimeout(100) await setTimeout(1000)
return ( return (
<> <>
<Link href="/app/rendering/a" id="to-a"> <Link href="/app/rendering/a" id="to-a">
......
...@@ -12,10 +12,10 @@ const installCheckVisible = (browser) => { ...@@ -12,10 +12,10 @@ const installCheckVisible = (browser) => {
const status = badge ? badge.getAttribute('data-status') : null const status = badge ? badge.getAttribute('data-status') : null
// Check if we're showing any status (rendering, compiling, etc.) // Check if we're showing any status (rendering, compiling, etc.)
window.showedBuilder = window.showedBuilder || ( window.showedIndicator = window.showedIndicator || (
statusElement !== null || (status && status !== 'none') statusElement !== null || (status && status !== 'none')
) )
if (window.showedBuilder) clearInterval(window.checkInterval) if (window.showedIndicator) clearInterval(window.checkInterval)
}, 5) }, 5)
})()`) })()`)
} }
...@@ -25,7 +25,7 @@ describe('Dev Rendering Indicator', () => { ...@@ -25,7 +25,7 @@ describe('Dev Rendering Indicator', () => {
files: __dirname, files: __dirname,
}) })
it('Shows build indicator when page is built from modifying', async () => { it('Shows rendering indicator when navigating between pages', async () => {
// Ensure both pages are built first so that we don't confuse it with build indicator // Ensure both pages are built first so that we don't confuse it with build indicator
await Promise.all([ await Promise.all([
next.fetch('/app/rendering/a'), next.fetch('/app/rendering/a'),
...@@ -33,14 +33,16 @@ describe('Dev Rendering Indicator', () => { ...@@ -33,14 +33,16 @@ describe('Dev Rendering Indicator', () => {
]) ])
const browser = await next.browser('/app/rendering/a') const browser = await next.browser('/app/rendering/a')
await installCheckVisible(browser) await installCheckVisible(browser)
await browser.eval('window.showedBuilder = false') await browser.eval('window.showedIndicator = false')
await browser.elementByCss('[href="/app/rendering/b"]').click() await browser.elementByCss('[href="/app/rendering/b"]').click()
await retry(async () => { await retry(async () => {
await browser.elementByCss('[href="/app/rendering/a"]') await browser.elementByCss('[href="/app/rendering/a"]')
}) })
const showedRenderingIndicator = await browser.eval('window.showedBuilder') const showedRenderingIndicator = await browser.eval(
'window.showedIndicator'
)
expect({ showedRenderingIndicator }).toEqual({ expect({ showedRenderingIndicator }).toEqual({
showedRenderingIndicator: true, showedRenderingIndicator: true,
}) })
......
...@@ -58,42 +58,42 @@ describe('Build Activity Indicator', () => { ...@@ -58,42 +58,42 @@ describe('Build Activity Indicator', () => {
}) })
if (isNextDev) { if (isNextDev) {
describe.each(['pages', 'app'])('Enabled - (%s)', (pagesOrApp) => { // A 400 ms delay was introduced to avoid flashing the indicator for fast
const { next } = nextTestSetup({ // builds. A simple test app like this usually compiles much faster, so we
files: join(__dirname, '..'), // skip this test for now, until we find a better way to test the indicator.
}) describe.skip('build indicator', () => {
describe.each(['pages', 'app'])('Enabled - (%s)', (pagesOrApp) => {
const { next } = nextTestSetup({
files: join(__dirname, '..'),
})
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)( it('Shows the build indicator when a page is built during navigation', async () => {
'webpack only', const browser = await next.browser(
() => { pagesOrApp === 'pages' ? '/' : '/app'
it('Shows the build indicator when a page is built during navigation', async () => { )
const browser = await next.browser( await installCheckVisible(browser)
pagesOrApp === 'pages' ? '/' : '/app' await browser.elementByCss('#to-a').click()
) await retry(async () => {
await installCheckVisible(browser) const wasVisible = await browser.eval('window.showedBuilder')
await browser.elementByCss('#to-a').click() expect(wasVisible).toBe(true)
await retry(async () => {
const wasVisible = await browser.eval('window.showedBuilder')
expect(wasVisible).toBe(true)
})
}) })
} })
)
it('Shows build indicator when page is built from modifying', async () => { it('Shows build indicator when page is built from modifying', async () => {
const browser = await next.browser( const browser = await next.browser(
pagesOrApp === 'pages' ? '/b' : '/app/b' pagesOrApp === 'pages' ? '/b' : '/app/b'
) )
await installCheckVisible(browser) await installCheckVisible(browser)
const pagePath = const pagePath =
pagesOrApp === 'pages' ? 'pages/b.js' : 'app/app/b/page.js' pagesOrApp === 'pages' ? 'pages/b.js' : 'app/app/b/page.js'
await next.patchFile(pagePath, (content) => content.replace('b', 'c')) await next.patchFile(pagePath, (content) => content.replace('b', 'c'))
await retry(async () => { await retry(async () => {
const wasVisible = await browser.eval('window.showedBuilder') const wasVisible = await browser.eval('window.showedBuilder')
expect(wasVisible).toBe(true) expect(wasVisible).toBe(true)
})
}) })
}) })
}) })
......
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