DFiP_Budget_planing/perf/e2e/tests/scroll-lib.spec.ts
Andrey Epifancev a1251436c3 perf: исправления сценариев скролла (ревью, раунд 1)
no_overflow вместо пустого complete, узкий catch по строкам, таймаут свода 2,
подписка на мутации до ввода фильтра и проверка эффекта фильтра, traced=1.

Refs #202

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 23:03:28 +04:00

45 lines
1.8 KiB
TypeScript

import { test, expect } from '@playwright/test';
import path from 'node:path';
import { scrollThrough } from '../lib/scroll';
const fx = (n: string) => 'file://' + path.resolve(__dirname, '../fixtures', n);
test('scrollThrough: длинный список y проходится до конца', async ({ page }) => {
await page.goto(fx('long-list.html'));
const r = await scrollThrough(page, '#box', 'y');
expect(r.complete).toBe(true);
expect(r.steps).toBeGreaterThanOrEqual(100);
// вернулись к началу
expect(await page.evaluate(() => document.querySelector('#box')!.scrollTop)).toBeLessThanOrEqual(2);
});
test('scrollThrough: ось x', async ({ page }) => {
await page.goto(fx('long-list.html'));
const r = await scrollThrough(page, '#box', 'x');
expect(r.complete).toBe(true);
});
test('scrollThrough: при исчерпании maxSteps complete === false', async ({ page }) => {
await page.goto(fx('clipped-list.html'));
const r = await scrollThrough(page, '#box', 'y', 200, 10);
expect(r.complete).toBe(false);
expect(r.steps).toBeLessThanOrEqual(10);
});
test('scrollThrough: контейнер без переполнения - complete === false, reason no_overflow, 0 шагов', async ({ page }) => {
await page.goto(fx('no-overflow.html'));
for (const axis of ['y', 'x'] as const) {
const r = await scrollThrough(page, '#box', axis);
expect(r.complete).toBe(false);
expect(r.steps).toBe(0);
expect(r.reason).toBe('no_overflow');
}
});
test('scrollThrough: ось x на длинном по высоте, но не по ширине контейнере - no_overflow', async ({ page }) => {
await page.goto(fx('clipped-list.html'));
const r = await scrollThrough(page, '#box', 'x');
expect(r.complete).toBe(false);
expect(r.reason).toBe('no_overflow');
});