Jelajahi Sumber

test(web): pin expanded snapshots to bottom

Dudu-0223 3 minggu lalu
induk
melakukan
ff34b6c28e
1 mengubah file dengan 8 tambahan dan 4 penghapusan
  1. 8 4
      apps/web/tests/scaffold.ts

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

@@ -1196,10 +1196,14 @@ export async function captureExpandedTurnProcessAria(
   try {
     if (options.scrollToBottom === 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)
   } finally {