Explorar o código

test(web): pin expanded snapshots to bottom

Dudu-0223 hai 1 mes
pai
achega
ff34b6c28e
Modificáronse 1 ficheiros con 8 adicións e 4 borrados
  1. 8 4
      apps/web/tests/scaffold.ts

+ 8 - 4
apps/web/tests/scaffold.ts

@@ -1196,10 +1196,14 @@ export async function captureExpandedTurnProcessAria(
   try {
   try {
     if (options.scrollToBottom === true) {
     if (options.scrollToBottom === true) {
       const backToBottom = page.getByRole('button', { name: 'Back to bottom', exact: true })
       const backToBottom = page.getByRole('button', { name: 'Back to bottom', exact: true })
-      if (await backToBottom.isVisible()) {
-        await backToBottom.click()
-        await expect.poll(() => backToBottom.count(), { timeout: 10_000 }).toBe(0)
-      }
+      const scroll = page.locator('[data-conversation-scroll]')
+      await expect.poll(async () => {
+        const distanceFromBottom = await scroll.evaluate((host) => {
+          host.scrollTop = host.scrollHeight
+          return host.scrollHeight - host.clientHeight - host.scrollTop
+        })
+        return Math.abs(distanceFromBottom) <= 1 && await backToBottom.count() === 0
+      }, { timeout: 10_000 }).toBe(true)
     }
     }
     return await captureStableAria(page, selector, workspaceCwd)
     return await captureStableAria(page, selector, workspaceCwd)
   } finally {
   } finally {