Files
MikrotikManager/tests/e2e/traffic-ipv6-labels.spec.ts
T

43 lines
3.8 KiB
TypeScript

import { observedTrafficFixturePayload } from "./traffic-observation-fixture"
import { test, expect } from '@playwright/test'
for (const width of [1440, 320]) {
test(`Потоки IPv6: адрес с портом однозначен, ICMPv6 подписан/${width}`, async ({ page }) => {
await page.setViewportSize({ width, height: 1000 })
const rows = [
{ src: 'fd00::10', dst: '2001:4860:4860::8888', srcPort: 50000, dstPort: 443, internetPeer: '2001:4860:4860::8888', internetPeerPort: 443, proto: 6, protoName: 'TCP', application: 'HTTPS' },
{ src: 'fd00::11', dst: '2606:4700:4700::1111', srcPort: 50001, dstPort: 53, internetPeer: '2606:4700:4700::1111', internetPeerPort: 53, proto: 17, protoName: 'UDP', application: 'DNS' },
{ src: 'fd00::12', dst: '2001:4860:4860::8844', srcPort: 0, dstPort: 0, internetPeer: '2001:4860:4860::8844', internetPeerPort: 0, proto: 58, protoName: 'ICMPv6', application: 'ICMPv6' },
{ 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: 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: 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: [] }] }
: path === '/api/traffic/flows' ? { exportersOnline: 1, bytesPerMin: 4000, uniqueSrc: 4, uniqueDst: 4, topProto: 'ICMPv6', talkers: rows, listenerBound: true }
: path === '/api/traffic/servers' ? { servers: [] }
: path === '/api/traffic/users' ? { users: [] }
: path === '/api/traffic/flow/clients' ? { clients: [] }
: path.endsWith('/interfaces') ? { interfaces: [] }
: path === '/api/servers' ? [] : {}
return route.fulfill({ json: observedTrafficFixturePayload(json) })
})
await page.goto('/traffic')
await page.getByRole('group', { name: 'Разделы трафика' }).getByRole('button', { name: 'Потоки', exact: true }).click()
await page.getByRole('tab', { name: 'Сессии', exact: true }).click()
const ipv6 = page.getByText('[2001:4860:4860::8888]:443', { exact: true })
await ipv6.scrollIntoViewIfNeeded()
await expect(ipv6).toBeVisible()
await expect(ipv6).toHaveAttribute('title', '[fd00::10]:50000 → [2001:4860:4860::8888]:443')
await expect(page.getByText('[2606:4700:4700::1111]:53', { exact: true })).toBeVisible()
await expect(page.getByText('2001:4860:4860::8844', { exact: true })).toBeVisible()
await expect(page.getByText('8.8.8.8:443', { exact: true })).toBeVisible()
await expect(page.getByRole('cell', { name: 'ICMPv6', exact: true }).first()).toBeVisible()
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
})
}