fix(uptime): сбросить снимок при смене пары и сохранить историю
This commit is contained in:
1 parent
8627459bfa
commit
e4f951175c
12 files changed
+142
-20
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { test, expect, type Page } from "@playwright/test"
|
||||
|
||||
async function setup(page: Page, url: string, failed = 0, longNames = false, permission?: string, isAdmin = false) {
|
||||
async function setup(page: Page, url: string, failed = 0, longNames = false, permission?: string, isAdmin = false, thirdServer = false) {
|
||||
const control = { writes: [] as { method: string; path: string; body: unknown }[], failed, posts: [] as { path: string; body: unknown }[] }
|
||||
const servers = [{ id: 1, name: "Источник", host: "192.0.2.1", type: "exit-node", enabled: true, country: "RU", site: "TEST", asn: "64512", status: "online", latency: 1, os: "7", model: "CHR", sessions:0, wanUplinks: [] }]
|
||||
const probes = ["p1", "p/2"].map(id => ({ id, srcServerId: "1", name: "Проверка сети", target: "192.0.2.10", filter: "main", rtt: null, loss: 100, status: "down", series: [0], enabled: true, showOnDashboard: false }))
|
||||
@@ -8,6 +8,7 @@ async function setup(page: Page, url: string, failed = 0, longNames = false, per
|
||||
await page.addInitScript(token => localStorage.setItem("mmapp_token", token), uptimeToken(permission, isAdmin))
|
||||
servers.push({ ...servers[0], id: 2, name: "Назначение", host: "192.0.2.2" })
|
||||
}
|
||||
if (thirdServer) servers.push({ ...servers[0], id: 3, name: "Новое назначение", host: "192.0.2.3" })
|
||||
if (longNames) {
|
||||
servers[0].name = "Источник-с-длинным-названием-площадки-для-проверки-переноса"
|
||||
probes.forEach(p => { p.name = "Проверка-доступности-длинного-имени-сетевого-узла"; p.target = "router-with-a-long-hostname.example.test"; p.filter = "Фильтр-с-длинным-названием" })
|
||||
@@ -818,3 +819,45 @@ test("Speed-test: конфликт пары устройств сохраняе
|
||||
await expect(run.locator("xpath=../../..")).toContainText("Назначение")
|
||||
expect(calls).toBe(1)
|
||||
})
|
||||
|
||||
test("Speed snapshot: смена пары сбрасывает снимок после подтверждения, история сохраняется", async ({ page }) => {
|
||||
await setup(page, "/uptime?probe=p1", 0, false, "mm:uptime:write", false, true)
|
||||
await page.getByRole("button", { name: "Пауза", exact: true }).click()
|
||||
await page.getByRole("button", { name: /Скорость/ }).click()
|
||||
await page.route("**/api/uptime/speed-test", route => route.fulfill({ json: { ok: true, result: { runId: route.request().postDataJSON().runId, txAvgMbps: 30, rxAvgMbps: 80 } } }))
|
||||
let fail = true, writes = 0
|
||||
await page.route("**/api/uptime/speed-probes", route => {
|
||||
if (route.request().method() !== "PUT") return route.fallback()
|
||||
writes++
|
||||
return route.fulfill(fail ? { status: 500, json: { error: "Пара не сохранена" } } : { json: { ok: true } })
|
||||
})
|
||||
const run = page.getByRole("button", { name: "Запустить", exact: true })
|
||||
const row = () => page.getByRole("button", { name: "Запустить", exact: true, includeHidden: true }).locator("xpath=../../..")
|
||||
await run.click()
|
||||
await expect(row().getByText("80 Мбит/с", { exact: true })).toBeVisible()
|
||||
const history = page.getByRole("table")
|
||||
await expect(history).toContainText("80")
|
||||
const summary = page.locator('[aria-label="Сводка speed-проб"]')
|
||||
await expect(summary).toContainText("1 run")
|
||||
await page.getByRole("button", { name: "Редактировать speed-пробу", exact: true }).click()
|
||||
const dialog = page.getByRole("dialog")
|
||||
const destination = () => dialog.locator('[data-slot="field"]').filter({ has: page.locator('[data-slot="field-label"]').filter({ hasText: /^Назначение$/ }) })
|
||||
await destination().getByRole("button", { name: /Новое назначение/ }).click()
|
||||
await dialog.getByRole("button", { name: "Сохранить", exact: true }).click()
|
||||
await expect(dialog.getByRole("alert")).toContainText("Пара не сохранена")
|
||||
await expect(row()).toContainText("80 Мбит/с")
|
||||
fail = false
|
||||
await dialog.getByRole("button", { name: "Сохранить", exact: true }).click()
|
||||
await expect(dialog).toBeHidden()
|
||||
await expect(row()).toContainText("Новое назначение")
|
||||
await expect(row()).not.toContainText("80 Мбит/с")
|
||||
await expect(summary).toContainText("1 run")
|
||||
await expect(history).toContainText("80")
|
||||
await page.getByRole("button", { name: "Редактировать speed-пробу", exact: true }).click()
|
||||
await destination().getByRole("button", { name: /Назначение / }).click()
|
||||
await dialog.getByRole("button", { name: "Сохранить", exact: true }).click()
|
||||
await expect(dialog).toBeHidden()
|
||||
await expect(row()).not.toContainText("80 Мбит/с")
|
||||
await expect(history).toContainText("80")
|
||||
expect(writes).toBe(3)
|
||||
})
|
||||
Reference in new issue
Block a user