fix(ui): завершить локальную приёмку трафика и статистики

This commit is contained in:
Denozordec committed 2026-09-28 23:45:48 +07:00
1 parent 48b7a061c1
commit 165f40acd7
10 files changed
+130 -28

No files matched your search

+36
View File
@@ -144,3 +144,39 @@ test('Статистика: история периода и выбранног
await expect(page.getByRole('button', { name: 'Применить срез', exact: true })).toBeVisible()
expect(writes).toEqual([])
})
test('Статистика: клавиатурный выбор среза и доступные состояния вида', async ({ page }) => {
await setup(page)
const criterion = page.getByRole('combobox', { name: 'Критерий', exact: true })
await criterion.focus()
await page.keyboard.press('ArrowDown')
await expect(page.getByRole('listbox')).toBeVisible()
await page.keyboard.press('Escape')
await expect(page.getByRole('listbox')).toHaveCount(0)
await expect(criterion).toBeFocused()
await page.route('**/api/statistics/pivot?**', route => route.fulfill({ json: { rowDim: 'country', colDim: 'service', metric: 'bytes', columns: [], rows: [], otherBytes: 0 } }))
const pivot = page.getByRole('button', { name: 'Сводка', exact: true })
await pivot.focus()
await page.keyboard.press('Enter')
await expect(pivot).toHaveAttribute('aria-pressed', 'true')
await expect(page.getByRole('button', { name: 'Разрез', exact: true })).toHaveAttribute('aria-pressed', 'false')
await expect(page.getByRole('combobox', { name: 'Строки', exact: true })).toBeVisible()
await expect(page.getByRole('combobox', { name: 'Колонки', exact: true })).toBeVisible()
})
for (const pivot of [false, true]) {
test('Статистика: повреждённый успешный ответ не обрушает страницу ' + (pivot ? 'pivot' : 'основной'), async ({ page }) => {
await setup(page)
const crashes: string[] = []
page.on('pageerror', error => crashes.push(error.message))
await page.route(pivot ? '**/api/statistics/pivot?**' : '**/api/statistics?**', route => route.fulfill({ json: {} }))
if (pivot) await page.getByRole('button', { name: 'Сводка', exact: true }).click()
else await page.reload()
await expect(page.getByRole('alert').filter({ hasText: 'Ошибка загрузки' })).toContainText(pivot ? 'Некорректный ответ сводной статистики' : 'Некорректный ответ статистики')
await expect(page.getByRole('button', { name: 'Повторить загрузку', exact: true })).toBeVisible()
await expect(page.getByLabel('Сводка трафика')).toHaveCount(0)
expect(crashes).toHaveLength(0)
})
}