fix(api): сохранять каталог speed-проб атомарно
This commit is contained in:
1 parent
d4f2961f76
commit
908974302e
9 files changed
+204
-86
No files matched your search
@@ -688,3 +688,39 @@ for (const active of [false, true]) test(`Speed interfaces: загрузка и
|
||||
}
|
||||
expect(interfaceCalls).toBe(2)
|
||||
})
|
||||
|
||||
for (const invalid of ["2", "10junk", "3.5"]) test("Speed draft rejects invalid duration without PUT/" + invalid, async ({ page }) => {
|
||||
const control = await setup(page, "/uptime", 0, false, "mm:uptime:write")
|
||||
await page.getByRole("button", { name: "Пауза", exact: true }).click()
|
||||
await page.getByRole("button", { name: /Скорость/ }).click()
|
||||
await page.getByRole("button", { name: "Редактировать speed-пробу", exact: true }).click()
|
||||
const dialog = page.getByRole("dialog"), input = dialog.locator("input").filter({ visible: true }).last()
|
||||
await input.fill(invalid)
|
||||
await dialog.getByRole("button", { name: "Сохранить", exact: true }).click()
|
||||
await expect(dialog.getByRole("alert")).toContainText("Проверьте speed-пробы")
|
||||
await expect(dialog).toBeVisible(); expect(control.writes).toEqual([])
|
||||
})
|
||||
for (const malformed of [false, true]) test("Speed save requires confirmation and shows scheduler warning/" + malformed, async ({ page }) => {
|
||||
await setup(page, "/uptime", 0, false, "mm:uptime:write")
|
||||
await page.getByRole("button", { name: "Пауза", exact: true }).click()
|
||||
await page.getByRole("button", { name: /Скорость/ }).click()
|
||||
let calls = 0
|
||||
await page.route("**/api/uptime/speed-probes", route => {
|
||||
if (route.request().method() !== "PUT") return route.fallback()
|
||||
calls++; const body = route.request().postDataJSON()
|
||||
expect(body.probes[0]).not.toHaveProperty("lastRunAt")
|
||||
return route.fulfill({ json: malformed ? {} : { ok: true, warning: "Пробы сохранены, но расписание не обновлено. Проверьте состояние сборщика данных." } })
|
||||
})
|
||||
await page.getByRole("button", { name: "Редактировать speed-пробу", exact: true }).click()
|
||||
const dialog = page.getByRole("dialog"), input = dialog.locator("input").filter({ visible: true }).last()
|
||||
await input.fill("17")
|
||||
await dialog.getByRole("button", { name: "Сохранить", exact: true }).click()
|
||||
if (malformed) {
|
||||
await expect(dialog.getByRole("alert")).toContainText("Ответ о сохранении speed-проб не подтверждён")
|
||||
await expect(input).toHaveValue("17")
|
||||
} else {
|
||||
await expect(dialog).toBeHidden()
|
||||
await expect(page.getByRole("status").filter({ hasText: "Пробы сохранены, но расписание" })).toBeVisible()
|
||||
}
|
||||
expect(calls).toBe(1)
|
||||
})
|
||||
Reference in new issue
Block a user