fix(traffic): сохранять историю и показывать достоверную свежесть
This commit is contained in:
1 parent
ebe62ae2ef
commit
1275dd7b9b
48 files changed
+1899
-187
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { observedTrafficFixturePayload } from "./traffic-observation-fixture"
|
||||
import { test, expect } from '@playwright/test'
|
||||
|
||||
for (const variant of ['missing-sessions', 'negative-series', 'monthly-missing', 'monthly-mismatch'] as const) {
|
||||
@@ -9,7 +10,7 @@ for (const variant of ['missing-sessions', 'negative-series', 'monthly-missing',
|
||||
const stats = { bpsNow: 1000000, bytes: 200, packets: 2, conversations: 1, uniqueSrc: 1, uniqueDst: 1, topProto: 'TCP', topCategory: 'Восстановлено', rxSeries: [1], txSeries: [2], applications: [], protocols: [], sources: [], destinations: [], interfaces: [], conversationsList: [], ifaces: [], live: false }
|
||||
const card = { id: '1', name: 'Экспортёр DTO', subtitle: '', site: 'TEST', country: 'RU', status: 'online', rxNow: 2, txNow: 3, sessions: 1, bytes: 200, rxSeries: [1], txSeries: [2] }
|
||||
page.on('pageerror', error => errors.push(error.message))
|
||||
await page.route('**/health', route => route.fulfill({ json: { ok: true } }))
|
||||
await page.route('**/health', route => route.fulfill({ json: observedTrafficFixturePayload({ ok: true }) }))
|
||||
await page.route('**/api/**', route => {
|
||||
const url = new URL(route.request().url()), path = url.pathname
|
||||
if (path === '/api/traffic/flow/analytics' || path === '/api/traffic/flow/monthly') {
|
||||
@@ -18,13 +19,13 @@ for (const variant of ['missing-sessions', 'negative-series', 'monthly-missing',
|
||||
const month = url.searchParams.get('month')!
|
||||
const data = bad && variant === 'monthly-missing' ? { month, bytes: 1500 }
|
||||
: { month: bad && variant === 'monthly-mismatch' ? (month === '2026-01' ? '2026-02' : '2026-01') : month, bytes: 1500, countries: [], services: [], asns: [] }
|
||||
return route.fulfill({ json: data })
|
||||
return route.fulfill({ json: observedTrafficFixturePayload(data) })
|
||||
}
|
||||
const data = bad && variant === 'missing-sessions' ? { ...stats, conversationsList: undefined }
|
||||
: bad && variant === 'negative-series' ? { ...stats, rxSeries: [-1] } : stats
|
||||
return route.fulfill({ json: data })
|
||||
return route.fulfill({ json: observedTrafficFixturePayload(data) })
|
||||
}
|
||||
if (path.endsWith('/live')) return route.fulfill({ status: 503, json: {} })
|
||||
if (path.endsWith('/live')) return route.fulfill({ status: 503, json: observedTrafficFixturePayload({}) })
|
||||
const json = path === '/api/auth/config' ? { required: false }
|
||||
: path === '/api/traffic/flow/exporters' ? { exporters: [card] }
|
||||
: path === '/api/traffic/flows' ? { exportersOnline: 1, bytesPerMin: 200, uniqueSrc: 1, uniqueDst: 1, topProto: 'TCP', talkers: [], listenerBound: true }
|
||||
@@ -33,7 +34,7 @@ for (const variant of ['missing-sessions', 'negative-series', 'monthly-missing',
|
||||
: path === '/api/traffic/flow/clients' ? { clients: [] }
|
||||
: path.endsWith('/interfaces') ? { interfaces: [] }
|
||||
: path === '/api/servers' ? [{ id: 1, name: card.name, host: '127.0.0.1', port: 80, useSsl: false, verifySsl: false, username: 'admin', password: '', type: 'jump-host', site: 'TEST', country: 'RU', asn: '', comment: '', enabled: true, lanSubnet: '', wanUplinks: [], createdAt: '', updatedAt: '', status: null, latency: null, os: null, model: null, uptime: null, cpuLoad: null, freeMemory: null, totalMemory: null, identityName: null, sessions: 0, polledAt: null }] : {}
|
||||
return route.fulfill({ json })
|
||||
return route.fulfill({ json: observedTrafficFixturePayload(json) })
|
||||
})
|
||||
await page.goto('/traffic')
|
||||
await page.getByRole('group', { name: 'Разделы трафика' }).getByRole('button', { name: 'Потоки', exact: true }).click()
|
||||
|
||||
Reference in new issue
Block a user