mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
test(assets): strengthen pagination E2E assertions (#10773)
## Summary The existing pagination smoke test only asserts `count >= 1`, which passes even if the sidebar eagerly loads all items or ignores page boundaries entirely. ### What changed **Before:** - Created 30 mock jobs (less than BATCH_SIZE of 200) — all loaded in one request, `has_more: false` - Asserted `count >= 1` — redundant with the grid-render smoke test **After — two targeted assertions:** 1. **Initial batch < total**: Mock 250 jobs (> BATCH_SIZE 200). First `/api/jobs?limit=200&offset=0` returns 200 items with `has_more: true`. Assert `initialCount < 250`. 2. **Scroll triggers second fetch**: Scroll `VirtualGrid` container to bottom → `approach-end` event → `handleApproachEnd()` → `assetsStore.loadMoreHistory()` → `/api/jobs?limit=200&offset=200` fetches remaining 50. Assert `finalCount > initialCount` via `expect.poll()`. ### Types Mock data uses `RawJobListItem` from `src/platform/remote/comfyui/jobs/jobTypes.ts` (Zod-inferred). This is the correct source-of-truth per `docs/guidance/playwright.md` — `/api/jobs` is a Python backend endpoint not covered by `@comfyorg/ingest-types`. ## Test plan - [ ] CI E2E tests pass - [ ] `initial batch is smaller than total job count` validates pagination boundary - [ ] `scrolling to the end loads additional items` triggers actual second API call Fixes #10649 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -624,21 +624,30 @@ test.describe('Assets sidebar - pagination', () => {
|
||||
await comfyPage.assets.clearMocks()
|
||||
})
|
||||
|
||||
test('Initially loads a batch of assets with has_more pagination', async ({
|
||||
test('initial load fetches first batch with offset 0', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
// Create a large set of jobs to trigger pagination
|
||||
const manyJobs = createMockJobs(30)
|
||||
const manyJobs = createMockJobs(250)
|
||||
await comfyPage.assets.mockOutputHistory(manyJobs)
|
||||
await comfyPage.setup()
|
||||
|
||||
// Capture the first history fetch (terminal statuses only).
|
||||
// Queue polling also hits /jobs but with status=in_progress,pending.
|
||||
const firstRequest = comfyPage.page.waitForRequest((req) => {
|
||||
if (!/\/api\/jobs\?/.test(req.url())) return false
|
||||
const url = new URL(req.url())
|
||||
const status = url.searchParams.get('status') ?? ''
|
||||
return status.includes('completed')
|
||||
})
|
||||
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
await tab.open()
|
||||
await tab.waitForAssets()
|
||||
|
||||
// Should load at least the first batch
|
||||
const count = await tab.assetCards.count()
|
||||
expect(count).toBeGreaterThanOrEqual(1)
|
||||
const req = await firstRequest
|
||||
const url = new URL(req.url())
|
||||
expect(url.searchParams.get('offset')).toBe('0')
|
||||
expect(Number(url.searchParams.get('limit'))).toBeGreaterThan(0)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user