fix(ui): снимать статус live при отсутствии обновлений
This commit is contained in:
1 parent
5734340db2
commit
f50a29f116
8 files changed
+103
-5
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { installOpenLiveStream, resumeLiveStream } from "./live-stream-fixture"
|
||||
import { test, expect } from '@playwright/test'
|
||||
|
||||
for (const variant of ['closed', 'invalid', 'http-error'] as const) {
|
||||
for (const variant of ['closed', 'invalid', 'http-error', 'silent'] as const) {
|
||||
test(`Трафик: SSE ${variant} не выдаёт старое измерение за live`, async ({ page }) => {
|
||||
const server = { id: '1', name: 'Тестовый сервер', site: 'TEST', country: 'RU', status: 'online', rxNow: 2, txNow: 3, rxPeak: 5, txPeak: 6, rxTotal: 100, txTotal: 200, sessions: 1, rxSeries: [1, 2], txSeries: [2, 3] }
|
||||
await page.route('**/health', route => route.fulfill({ json: { ok: true } }))
|
||||
@@ -22,11 +23,26 @@ for (const variant of ['closed', 'invalid', 'http-error'] as const) {
|
||||
: path === '/api/servers' ? [] : {}
|
||||
return route.fulfill({ json })
|
||||
})
|
||||
if (variant === 'silent') await installOpenLiveStream(page, '/api/traffic/servers/1/live', { rxMbps: 17, txMbps: 19, at: '2026-09-23T12:00:00Z' })
|
||||
const received = new Date('2026-09-28T06:00:00Z')
|
||||
await page.clock.setFixedTime(received)
|
||||
await page.goto('/traffic')
|
||||
const summary = page.getByLabel('Скорость выбранного сервера')
|
||||
await expect(summary).toBeVisible()
|
||||
if (variant === 'silent') {
|
||||
await expect(summary.getByText('live', { exact: true }).filter({ visible: true })).toHaveCount(2)
|
||||
const stamp = await page.getByLabel('Последнее измерение сервера').locator('time').first().getAttribute('datetime')
|
||||
await page.clock.fastForward(15_001)
|
||||
await expect(summary.getByText('live', { exact: true })).toHaveCount(0)
|
||||
await expect(summary).toContainText('17.0')
|
||||
await expect(page.getByLabel('Последнее измерение сервера').locator('time').first()).toHaveAttribute('datetime', stamp!)
|
||||
await resumeLiveStream(page)
|
||||
await expect(summary.getByText('live', { exact: true }).filter({ visible: true })).toHaveCount(2)
|
||||
await page.getByRole('group', { name: 'Разделы трафика' }).getByRole('button', { name: 'Клиенты', exact: true }).click()
|
||||
await page.clock.fastForward(15_001)
|
||||
await expect(page.getByLabel('Последнее измерение сервера')).toHaveCount(0)
|
||||
return
|
||||
}
|
||||
const hint = variant === 'http-error' ? 'История · live недоступен' : 'Последнее live-измерение · поток недоступен'
|
||||
await expect(summary.getByText(hint, { exact: true }).filter({ visible: true })).toHaveCount(2)
|
||||
await expect(summary.getByText('live', { exact: true })).toHaveCount(0)
|
||||
|
||||
Reference in new issue
Block a user