fix(ui): проверять период статистики до запроса
This commit is contained in:
1 parent
167e19cd91
commit
94ad73212b
6 files changed
+109
-19
No files matched your search
@@ -69,3 +69,29 @@ test('Статистика: ошибка pivot не показывает мет
|
||||
await expect(page.getByText('Данные 2026-09-01', { exact: true })).toHaveCount(0)
|
||||
await page.screenshot({ path: 'test-results/statistics-error.png', animations: 'disabled' })
|
||||
})
|
||||
|
||||
for (const query of [
|
||||
'from=2026-02-30&to=2026-03-02',
|
||||
'from=2026-09-01',
|
||||
'from=2026-09-01&from=2026-09-02&to=2026-09-03',
|
||||
'from=2026-09-03&to=2026-09-01',
|
||||
]) {
|
||||
test(`Статистика: некорректный период ${query} не запрашивает API`, async ({ page }) => {
|
||||
const requests: string[] = []
|
||||
page.on('request', r => { if (new URL(r.url()).pathname === '/api/statistics') requests.push(r.url()) })
|
||||
await setup(page)
|
||||
await expect(page.getByText('Данные 2026-09-01', { exact: true })).toBeVisible()
|
||||
const before = requests.length
|
||||
await page.goto('/statistics?' + query + '&country=RU&keep=1')
|
||||
await expect(page.getByRole('alert').filter({ hasText: 'Некорректный период' })).toBeVisible()
|
||||
await expect(page.getByLabel('Сводка трафика')).toHaveCount(0)
|
||||
expect(requests).toHaveLength(before)
|
||||
await page.getByRole('button', { name: 'Выбрать последние 7 дней', exact: true }).click()
|
||||
await expect(page.getByLabel('Сводка трафика')).toBeVisible()
|
||||
await expect(page.getByText('Некорректный период', { exact: true })).toHaveCount(0)
|
||||
const params = new URL(page.url()).searchParams
|
||||
expect(params.getAll('from')).toHaveLength(1)
|
||||
expect(params.get('country')).toBe('RU')
|
||||
expect(params.get('keep')).toBe('1')
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user