test(ui): проверить опрос сервера из очереди проблем

This commit is contained in:
Denozordec committed 2026-09-23 14:50:16 +07:00
1 parent ca9474ac83
commit 27f8323624
3 files changed
+43 -1

No files matched your search

+36
View File
@@ -167,3 +167,39 @@ test("Internet path: поздний дополнительный запрос н
await expect(source.locator("time").first()).toHaveAttribute("datetime", timestamp!)
await expect(source.locator("time").last()).toHaveAttribute("datetime", "2026-09-20T00:00:00Z")
})
test('Сквозная приёмка: проблема → опрос сервера с отказом и повтором → возврат', async ({ page }) => {
const writes: string[] = []
page.on('request', request => {
if (!['GET', 'HEAD', 'OPTIONS'].includes(request.method())) writes.push(new URL(request.url()).pathname)
})
await setup(page, false, 2)
let fail = true
await page.route('**/api/servers/2/poll', route => route.fulfill({
status: fail ? 403 : 200,
json: fail ? { error: 'Опрос запрещён политикой сервера' } : {},
}))
const queue = page.getByRole('region', { name: 'Требует внимания', exact: true })
await queue.getByRole('link', { name: /^Узел 2/ }).click()
await expect(page).toHaveURL(/\/servers\?server=2$/)
const context = page.getByRole('status', { name: 'Сервер по ссылке' })
await expect(context).toContainText('Узел 2')
await expect(page.locator('tr[data-row-id]')).toHaveCount(1)
expect(writes).toEqual([])
const poll = page.getByRole('button', { name: 'Проверить сервер', exact: true })
await poll.click()
await expect(page.getByText('Опрос: успешно 0 из 1', { exact: true })).toBeVisible()
await expect(context).toContainText('Узел 2')
fail = false
await poll.click()
await expect(page.getByText('Опрос: успешно 1 из 1', { exact: true })).toBeVisible()
expect(writes).toEqual(['/api/servers/2/poll', '/api/servers/2/poll'])
await page.goBack()
await expect(page).toHaveURL(/\/dashboard$/)
await expect(queue.getByRole('link', { name: /^Узел 2/ })).toBeVisible()
await page.goForward()
await expect(context).toContainText('Узел 2')
await expect(page.locator('tr[data-row-id]')).toHaveCount(1)
await expect(poll).toBeEnabled()
expect(writes).toEqual(['/api/servers/2/poll', '/api/servers/2/poll'])
})