fix(ui): сохранять и проверять контекст отчёта статистики
This commit is contained in:
1 parent
94ad73212b
commit
e05b3a38c8
5 files changed
+117
-20
No files matched your search
@@ -95,3 +95,52 @@ for (const query of [
|
||||
expect(params.get('keep')).toBe('1')
|
||||
})
|
||||
}
|
||||
|
||||
for (const query of ['serverId=bad', 'planes=unknown', 'country=RU&country=DE']) {
|
||||
test(`Статистика: неверный контекст ${query} блокирует запрос до сброса`, 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?from=2026-09-01&to=2026-09-03&keep=1&' + query + '#report')
|
||||
await expect(page.getByRole('alert').filter({ hasText: 'Параметры отчёта требуют внимания' })).toBeVisible()
|
||||
await expect(page.getByLabel('Сводка трафика')).toHaveCount(0)
|
||||
expect(requests).toHaveLength(before)
|
||||
await page.getByRole('button', { name: 'Сбросить параметры отчёта', exact: true }).click()
|
||||
await expect(page.getByText('Данные 2026-09-01', { exact: true })).toBeVisible()
|
||||
const url = new URL(page.url())
|
||||
expect(url.searchParams.get('from')).toBe('2026-09-01')
|
||||
expect(url.searchParams.get('keep')).toBe('1')
|
||||
expect(url.hash).toBe('#report')
|
||||
await page.goBack()
|
||||
await expect(page.getByRole('alert').filter({ hasText: 'Параметры отчёта требуют внимания' })).toBeVisible()
|
||||
})
|
||||
}
|
||||
|
||||
test('Статистика: история периода и выбранного среза восстанавливается без записи', async ({ page }) => {
|
||||
const writes: string[] = []
|
||||
page.on('request', r => { if (!['GET', 'HEAD', 'OPTIONS'].includes(r.method())) writes.push(r.url()) })
|
||||
await setup(page)
|
||||
await expect(page.getByText('Данные 2026-09-01', { exact: true })).toBeVisible()
|
||||
const original = page.url()
|
||||
await page.getByRole('button', { name: '30 д', exact: true }).click()
|
||||
await expect(page).not.toHaveURL(original)
|
||||
await expect(page.locator('tr[data-row-id]')).toHaveCount(1)
|
||||
const period = page.url()
|
||||
await page.locator('tr[data-row-id]').click()
|
||||
await expect(page).toHaveURL(/userId=/)
|
||||
const slice = page.url()
|
||||
await page.goBack()
|
||||
await expect(page).toHaveURL(period)
|
||||
await page.goBack()
|
||||
await expect(page).toHaveURL(original)
|
||||
await expect(page.getByText('Данные 2026-09-01', { exact: true })).toBeVisible()
|
||||
await page.goForward()
|
||||
await page.goForward()
|
||||
await expect(page).toHaveURL(slice)
|
||||
await page.reload()
|
||||
await expect(page).toHaveURL(slice)
|
||||
await expect(page.getByRole('button', { name: 'Применить срез', exact: true })).toBeVisible()
|
||||
expect(writes).toEqual([])
|
||||
})
|
||||
Reference in new issue
Block a user