fix(traffic): сохранять историю и показывать достоверную свежесть

This commit is contained in:
Denozordec committed 2026-10-12 20:23:07 +07:00
1 parent ebe62ae2ef
commit 1275dd7b9b
48 files changed
+1899 -187

No files matched your search

+4 -3
View File
@@ -1,3 +1,4 @@
import { observedTrafficFixturePayload } from "./traffic-observation-fixture"
import { test, expect } from '@playwright/test'
for (const width of [1440, 320]) {
@@ -10,10 +11,10 @@ for (const width of [1440, 320]) {
{ src: '10.0.0.1', dst: '8.8.8.8', srcPort: 50002, dstPort: 443, internetPeer: '8.8.8.8', internetPeerPort: 443, proto: 6, protoName: 'TCP', application: 'HTTPS' },
].map(row => ({ ...row, serverId: '1', serverName: 'IPv6 exporter', clientIp: row.src, inIface: 'ether1', bps: 1000, bytes: 1000, packets: 10 }))
const stats = { bpsNow: 0, bytes: 4000, packets: 40, conversations: 4, uniqueSrc: 4, uniqueDst: 4, topCategory: 'Прочее', topProto: 'ICMPv6', rxSeries: [], txSeries: [], interfaces: [], ifaces: [], live: false, timeline: [], applications: [], categories: [], services: [], countries: [], asns: [], protocols: [], sources: [], destinations: [], conversationsList: rows, dedupApplied: false }
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 path = new URL(route.request().url()).pathname
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/analytics' ? stats
: path === '/api/traffic/flow/exporters' ? { exporters: [{ id: '1', name: 'IPv6 exporter', subtitle: '', site: 'TEST', country: '', status: 'online', rxNow: 0, txNow: 0, sessions: 4, bytes: 4000, rxSeries: [], txSeries: [] }] }
@@ -23,7 +24,7 @@ for (const width of [1440, 320]) {
: path === '/api/traffic/flow/clients' ? { clients: [] }
: path.endsWith('/interfaces') ? { interfaces: [] }
: path === '/api/servers' ? [] : {}
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()