fix(ui): проверять подтверждение восстановления WireGuard
This commit is contained in:
1 parent
425a77a1ca
commit
221d6db10c
5 files changed
+51
-6
No files matched your search
@@ -439,3 +439,33 @@ test("WireGuard: экспорт второго пира использует е
|
||||
await expect(dialog.locator("pre")).toContainText("SECOND_PEER_EXPORT")
|
||||
expect(body).toMatchObject({ serverId: "1", interfaceName: "wg-peers", peerId: "*P2", format: "peer-conf", includePrivateKey: false })
|
||||
})
|
||||
|
||||
test("WireGuard: восстановление требует подтверждения API", async ({ page }) => {
|
||||
await setup(page, "/wireguard?server=1")
|
||||
await page.route("**/api/wireguard/revisions?**", route => route.fulfill({ json: { revisions: [{ id: "rev/1", serverId: "1", section: "wireguard", source: "apply", fingerprint: "fixture", createdAt: "2026-09-29T00:00:00Z", note: null, itemCount: 1 }] } }))
|
||||
let attempts = 0
|
||||
let release: (() => void) | undefined
|
||||
const gate = new Promise<void>(resolve => { release = resolve })
|
||||
await page.route("**/api/wireguard/revisions/*/restore", async route => {
|
||||
expect(decodeURIComponent(new URL(route.request().url()).pathname)).toBe("/api/wireguard/revisions/rev/1/restore")
|
||||
expect(route.request().postDataJSON()).toEqual({ serverId: "1" })
|
||||
attempts++
|
||||
if (attempts === 1) await gate
|
||||
return route.fulfill({ json: { ok: attempts > 1 } })
|
||||
})
|
||||
await page.getByRole("button", { name: "История", exact: true }).click()
|
||||
const sheet = page.getByRole("dialog", { name: "История WireGuard" })
|
||||
await sheet.getByRole("button", { name: "Откатить", exact: true }).click()
|
||||
const confirm = page.getByRole("alertdialog")
|
||||
await confirm.getByRole("button", { name: "Откатить", exact: true }).evaluate(button => { (button as HTMLButtonElement).click(); (button as HTMLButtonElement).click() })
|
||||
await expect.poll(() => attempts).toBe(1)
|
||||
await expect(confirm.getByRole("button", { name: "Откатить", exact: true })).toBeDisabled()
|
||||
release!()
|
||||
await expect(page.getByText("Не удалось откатить", { exact: true })).toBeVisible()
|
||||
await expect(page.getByText("Версия применена на роутер", { exact: true })).toHaveCount(0)
|
||||
await expect(confirm).toHaveCount(0)
|
||||
await sheet.getByRole("button", { name: "Откатить", exact: true }).click()
|
||||
await confirm.getByRole("button", { name: "Откатить", exact: true }).click()
|
||||
await expect(page.getByText("Версия применена на роутер", { exact: true })).toBeVisible()
|
||||
expect(attempts).toBe(2)
|
||||
})
|
||||
Reference in new issue
Block a user