Open History to see the last commit
1import { expect, test } from '@playwright/test'
2
3test('ChatClient time-slices a large buffered stream', async ({ page }) => {
4 await page.goto('/chat-client-stream-processing')
5
6 await page.getByTestId('run').click()
7 await expect(page.getByTestId('complete')).toHaveText('true')
8
9 const result = JSON.parse(
10 (await page.getByTestId('result').textContent()) ?? '{}',
11 )
12 expect(result).toEqual({
13 contentChunkCount: 2_000,
14 firstContentBeforeUserBlockingTask: true,
15 longTaskObserverSupported: true,
16 longTaskCount: expect.any(Number),
17 ordered: true,
18 userBlockingTaskBeforeRunFinished: true,
19 })
20 // Allow one long task for slow CI runners (GC, a slow render). A drain with
21 // no yield still fails `userBlockingTaskBeforeRunFinished` above.
22 expect(result.longTaskCount).toBeLessThanOrEqual(1)
23 await expect(page.getByTestId('assistant-text')).toHaveText(
24 Array.from({ length: 2_000 }, (_, index) => String(index)).join(''),
25 )
26 await expect(page.getByTestId('loading')).toHaveText('false')
27 await expect(page.getByTestId('error')).toHaveCount(0)
28})