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

This commit is contained in:
Denozordec committed 2026-10-07 14:15:56 +07:00
1 parent 1904c86657
commit 9d5959601f
10 files changed
+160 -58

No files matched your search

+33
View File
@@ -763,3 +763,36 @@ test("Ping catalog: malformed initial/refresh disables replacement, recovery and
await page.getByRole("alertdialog").getByRole("button", { name: "Отмена", exact: true }).click()
expect(control.writes).toEqual([])
})
for (const invalid of [false, true]) {
test(`Speed-test: nullable POST, ноль и ${invalid ? "чужой runId" : "невалидная скорость"}`, async ({ page }) => {
await setup(page, "/uptime?probe=p1", 0, false, "mm:uptime:write")
await page.getByRole("button", { name: "Пауза", exact: true }).click()
await page.getByRole("button", { name: /Скорость/ }).click()
let calls = 0
let release!: () => void
const pending = new Promise<void>(resolve => { release = resolve })
await page.route("**/api/uptime/speed-test", async route => {
calls++
const { runId } = route.request().postDataJSON()
if (calls === 1) await pending
await route.fulfill({ json: { ok: true, result: { runId: calls === 2 && invalid ? "foreign-run" : runId, txAvgMbps: calls === 2 && !invalid ? "999" : null, rxAvgMbps: calls === 2 ? 999 : 0 } } })
})
const run = page.getByRole("button", { name: "Запустить", exact: true })
const summary = page.locator('[aria-label="Сводка speed-проб"]')
await run.click()
await expect(page.getByText("Тест выполняется…", { exact: true })).toBeVisible()
await expect(summary).not.toContainText("0 Мбит/с")
release()
await expect(run).toBeEnabled()
await expect(run.locator("xpath=../../..").getByText("Неизвестно", { exact: true })).toBeVisible()
await expect(run.locator("xpath=../../..").getByText("0 Мбит/с", { exact: true })).toBeVisible()
await expect(summary).toContainText("1 run")
await run.click()
await expect(page.getByRole("alert").filter({ hasText: "Некорректное подтверждение speed-test" })).toBeVisible()
await expect(run).toBeEnabled()
await expect(summary).toContainText("1 run")
await expect(summary).not.toContainText("999 Мбит/с")
expect(calls).toBe(2)
})
}