test(app): deflake cached tab paint probe (#41965)

This commit is contained in:
Luke Parker
2026-08-12 20:21:27 +10:00
committed by GitHub
parent 01cbdcb8e4
commit c8dffb6893
@@ -189,7 +189,12 @@ test.describe("smoke: session timeline", () => {
.querySelector<HTMLElement>('[data-timeline-row="bottom-spacer"]')
?.getBoundingClientRect()
samples.push({ ids: visible, last: visible.includes(last), bottomError: bottom?.bottom - view.bottom })
if (!firstPaint && visible.includes(last) && Math.abs((bottom?.bottom ?? Infinity) - view.bottom) <= 1) {
if (
!firstPaint &&
visible.includes(last) &&
Math.abs((bottom?.bottom ?? Infinity) - view.bottom) <= 1 &&
!root.querySelector('[data-markdown-key="initial"]')
) {
firstPaint = true
root.querySelectorAll<HTMLElement>("[data-timeline-key]").forEach((row) => {
const rect = row.getBoundingClientRect()
@@ -204,10 +209,16 @@ test.describe("smoke: session timeline", () => {
}
;(
window as Window & {
__sessionTabPaint?: { samples: typeof samples; removed: () => number; stop: () => void }
__sessionTabPaint?: {
samples: typeof samples
painted: () => boolean
removed: () => number
stop: () => void
}
}
).__sessionTabPaint = {
samples,
painted: () => firstPaint,
removed: () => removedFirstPaintNodes,
stop: () => {
running = false
@@ -219,17 +230,19 @@ test.describe("smoke: session timeline", () => {
)
await switchTitlebarSession(page, fixture.targetID, fixture.expected.targetTitle)
await page.waitForFunction(() =>
(
window as Window & { __sessionTabPaint?: { samples: Array<{ ids: string[] }> } }
).__sessionTabPaint?.samples.some((sample) => sample.ids.length > 0),
)
await page.waitForFunction(() => {
const probe = (
window as Window & { __sessionTabPaint?: { samples: Array<{ ids: string[] }>; painted: () => boolean } }
).__sessionTabPaint
return probe?.painted() && probe.samples.some((sample) => sample.ids.length > 0)
})
await page.waitForTimeout(200)
const first = await page.evaluate(() => {
const probe = (
window as Window & {
__sessionTabPaint?: {
samples: Array<{ ids: string[]; last: boolean; bottomError?: number }>
painted: () => boolean
removed: () => number
stop: () => void
}