fix(ui): сохранять точный выбор пира при экспорте WireGuard

This commit is contained in:
Denozordec committed 2026-09-29 08:40:36 +07:00
1 parent 4aa4726c6b
commit 425a77a1ca
8 files changed
+68 -10

No files matched your search

+24
View File
@@ -415,3 +415,27 @@ test("WireGuard: экспорт отклоняет повреждённый от
await dialog.getByRole("button", { name: "Подтянуть конфиг с роутера с private-key", exact: true }).click()
await expect(dialog.locator("pre")).toContainText("VALID_EXPORT")
})
test("WireGuard: экспорт второго пира использует его RouterOS ID", async ({ page }) => {
await setup(page, "/wireguard?server=1")
const fixture = wgListResponseSchema.parse({ interfaces: [{ id: "iface", rosId: "*I", serverId: "1", serverName: "Источник", name: "wg-peers", publicKey: "fixture-server-key", listenPort: 13231, mtu: 1420, enabled: true, status: "up", comment: "", peers: [
{ id: "first", rosId: "*P1", publicKey: "fixture-peer-one", allowedIps: ["10.0.1.1/32"] },
{ id: "second", rosId: "*P2", publicKey: "fixture-peer-two", allowedIps: ["10.0.2.1/32"] },
] }] })
await page.route("**/api/wireguard", route => route.fulfill({ json: fixture }))
let body: Record<string, unknown> | undefined
await page.route("**/api/wireguard/export", route => {
body = route.request().postDataJSON()
return route.fulfill({ json: { format: "peer-conf", filename: "peer.conf", content: "SECOND_PEER_EXPORT" } })
})
await page.reload()
await page.getByRole("tab", { name: /Пиры/ }).click()
await expect(page.locator("tr[data-row-id]")).toHaveCount(2)
await page.locator("tr[data-row-id]").filter({ hasText: "10.0.2.1/32" }).getByRole("button", { name: "Экспорт peer .conf" }).click()
const dialog = page.getByRole("dialog", { name: "Экспорт WireGuard" })
await expect(dialog.locator("pre")).toContainText("10.0.2.1/32")
await expect(dialog.locator("pre")).not.toContainText("10.0.1.1/32")
await dialog.getByRole("button", { name: "Подтянуть конфиг с роутера с private-key" }).click()
await expect(dialog.locator("pre")).toContainText("SECOND_PEER_EXPORT")
expect(body).toMatchObject({ serverId: "1", interfaceName: "wg-peers", peerId: "*P2", format: "peer-conf", includePrivateKey: false })
})