fix(ui): использовать серверное время и не подменять отсутствующий Ping

This commit is contained in:
Denozordec committed 2026-10-07 17:52:33 +07:00
1 parent 7f18fcb6db
commit 30cc99c68e
9 files changed
+60 -11

No files matched your search

+20
View File
@@ -903,3 +903,23 @@ test("Speed snapshot: смена длительности сбрасывает
await expect(history).toContainText("80")
expect(writes).toBe(3)
})
for (const ping of [false, true]) test("Speed receipt: серверное время и отсутствие старого Ping/" + ping, async ({ page }) => {
await setup(page, "/uptime?probe=p1", 0, false, "mm:uptime:write")
await page.getByRole("button", { name: "Пауза", exact: true }).click()
await page.route("**/api/uptime/speed-probes", route => route.fulfill({ json: { probes: [{ id: "s1", srcServerId: "1", dstServerId: "2", srcInterface: "", dstInterface: "", protocol: "tcp", direction: "both", durationSec: "10", enabled: true, lastRunAt: "2026-10-05T00:00:00Z", lastTxAvgMbps: 12, lastRxAvgMbps: 20, lastStatus: "done", lastError: null, lastPingRttMs: 99, lastPingLossPct: 0, lastPingAt: "2026-10-05T00:00:00Z", lastPingError: null }] } }))
await page.getByRole("button", { name: /Скорость/ }).click()
await page.getByRole("button", { name: "Обновить данные", exact: true }).click()
const launch = page.getByRole("button", { name: "Запустить", exact: true })
const probe = launch.locator("xpath=../../..")
await expect(probe).toContainText("99 мс")
const createdAt = "2026-10-06T00:00:00Z"
await page.route("**/api/uptime/speed-test", route => route.fulfill({ json: { ok: true, result: { runId: route.request().postDataJSON().runId, createdAt, txAvgMbps: 30, rxAvgMbps: 80, ...(ping ? { afterBtPing: { rttMs: 0, lossPct: 0, error: null } } : {}) } } }))
await launch.click()
await expect(probe).toContainText("80 Мбит/с")
await expect(probe).not.toContainText("99 мс")
if (ping) await expect(probe).toContainText("0 мс")
else await expect(probe.getByText("Ping", { exact: true })).toHaveCount(0)
const expectedTime = await page.evaluate(value => new Date(value).toLocaleString("ru-RU", { hour: "2-digit", minute: "2-digit", second: "2-digit", day: "2-digit", month: "2-digit" }), createdAt)
await expect(page.getByRole("table")).toContainText(expectedTime)
})