fix(ui): отличать неизвестный RTT от отсутствия ответов Ping
This commit is contained in:
1 parent
30cc99c68e
commit
9680a6422b
6 files changed
+55
-10
No files matched your search
@@ -54,3 +54,31 @@ test("Speed-пробы: malformed каталог, cache/freshness и блоки
|
||||
await page.addStyleTag({content:"nextjs-portal{display:none!important}"});await page.screenshot({path:"docs/ux-ui/screens/speed-probes-error-320.png",fullPage:true,animations:"disabled"})
|
||||
raw={probes:[probe]};await refresh.click();await expect(alert).toHaveCount(0);await expect(toggle).toBeEnabled();expect(writes).toEqual([])
|
||||
})
|
||||
|
||||
const pingCases = [
|
||||
{ name: "missing", value: undefined, label: "Нет данных" },
|
||||
{ name: "unknown", value: { rttMs: null, lossPct: null, error: null }, label: "RTT неизвестен" },
|
||||
{ name: "loss100", value: { rttMs: null, lossPct: 100, error: null }, label: "Нет ответов" },
|
||||
{ name: "zero", value: { rttMs: 0, lossPct: 0, error: null }, label: "0 мс" },
|
||||
{ name: "error", value: { rttMs: null, lossPct: null, error: "Ошибка Ping" }, label: "ошибка" },
|
||||
]
|
||||
for (const sample of pingCases) test("Ping после BT: данные, неизвестный RTT, отсутствие ответов и ошибка/" + sample.name, async ({ page }) => {
|
||||
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
|
||||
await page.route("**/api/**", route => {
|
||||
const path = new URL(route.request().url()).pathname
|
||||
return route.fulfill({ json: path === "/api/auth/config" ? { required: false } : path === "/api/servers" ? [server] : path === "/api/uptime/overview" ? { probes: [], resources: [] } : path === "/api/uptime/speed-probes" ? { probes: [{ id: "probe-1", srcServerId: "1", dstServerId: "2", srcInterface: "ether1", dstInterface: "ether1", protocol: "tcp", direction: "both", durationSec: "10", enabled: true, lastStatus: "done", lastRunAt: "2026-10-03T00:00:00Z", lastTxAvgMbps: 999, lastRxAvgMbps: 0, lastError: null, lastPingRttMs: 99, lastPingLossPct: 0, lastPingAt: "2026-10-03T00:00:00Z", lastPingError: null }] } : path === "/api/uptime/speed-test/runs" ? { runs: [{ ...run, afterBtPing: sample.value }] } : {} })
|
||||
})
|
||||
await page.goto("/uptime?tab=speed")
|
||||
await page.getByRole("button", { name: "Пауза", exact: true }).click()
|
||||
const history = page.locator('tr[data-row-id="history-1"]')
|
||||
await expect(history).toContainText(sample.label)
|
||||
const probe = page.getByRole("button", { name: "Запустить", exact: true }).locator("xpath=../../..")
|
||||
await expect(probe).not.toContainText("99 мс")
|
||||
if (sample.name === "missing") await expect(probe.getByText("Ping", { exact: true })).toHaveCount(0)
|
||||
else await expect(probe).toContainText(sample.name === "error" ? "Ошибка Ping" : sample.label)
|
||||
await expect(history).not.toContainText("timeout")
|
||||
await expect(probe).not.toContainText("timeout")
|
||||
if (sample.name === "loss100") await expect(history).toContainText("100%")
|
||||
await page.setViewportSize({ width: 320, height: 1000 })
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
|
||||
})
|
||||
Reference in new issue
Block a user