fix(ui): ограничить карточки оптимизатора с сохранением URL
This commit is contained in:
1 parent
7265709b1c
commit
059fd93520
10 files changed
+123
-11
No files matched your search
@@ -8,7 +8,7 @@ const servers: OptimizerApiServer[] = (["home-router", "jump-host", "exit-node"]
|
||||
...(i === 0 ? { wanUplinks: ids.map(id => ({ id: `wan${id}`, name: `WAN${id}`, isp: "ISP", iface: `ether${id}`, ip: `198.51.100.${id}`, maxDl: 100, maxUl: 100 })) } : {}),
|
||||
}))
|
||||
|
||||
async function setup(page: Page, preview: "ok" | "empty" | "error" = "ok", missingExit = false) {
|
||||
async function setup(page: Page, preview: "ok" | "empty" | "error" = "ok", missingExit = false, manyHomes = false) {
|
||||
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
|
||||
await page.route("**/api/**", route => {
|
||||
const path = new URL(route.request().url()).pathname
|
||||
@@ -17,7 +17,7 @@ async function setup(page: Page, preview: "ok" | "empty" | "error" = "ok", missi
|
||||
const interfaces = preview === "empty" ? [] : ids.map(i => ({ id: String(i), interface: `ether${i}`, currentCost: i, optimalCost: 20, score: i, pingMs: i, dlMbps: 100, ulMbps: 50 }))
|
||||
return route.fulfill({ json: {serverId:1,serverName:"Роутер 1",pingWeight:60,unchangedCount:0, interfaces, changes: interfaces, changedCount: interfaces.length, interfacesTotal: interfaces.length } })
|
||||
}
|
||||
return route.fulfill({ json: path === "/api/servers" ? servers.filter(server => !missingExit || server.type !== "exit-node")
|
||||
return route.fulfill({ json: path === "/api/servers" ? [...servers.filter(server => !missingExit || server.type !== "exit-node"), ...(manyHomes ? Array.from({ length: 5 }, (_, i) => ({ ...servers[0], id: i+4, name: `Другой дом ${i+4}`, wanUplinks: [] })) : [])]
|
||||
: path === "/api/auth/config" ? { required: false }
|
||||
: path === "/api/evobgp/settings" ? { enabled: false, baseUrl: "", secretConfigured: false }
|
||||
: path === "/api/filters/rules" ? { rulesets: [{ serverId: "1", rules: ids.map(i => ({ id: String(i), community: `65001:${i}`, communityName: `Сервис ${i}`, gateway: "192.0.2.2", gatewayTunnelId: "", description: "" })) }] }
|
||||
@@ -84,3 +84,19 @@ test("Оптимизатор: без ExitNode отсутствующие инд
|
||||
await expect(grid).not.toContainText("0 б.")
|
||||
await expect(grid.getByRole("button",{name:"Симулировать",exact:true})).toHaveCount(0)
|
||||
})
|
||||
|
||||
|
||||
test("Оптимизатор: закрепление Community сохраняется между страницами устройств", async ({ page }) => {
|
||||
await setup(page, "ok", false, true)
|
||||
const scope = page.getByRole("region", { name: "Домашние устройства оптимизатора" })
|
||||
await page.getByRole("button", { name: "BGP community (12)", exact: true }).click()
|
||||
const rec = scope.getByRole("table").filter({ hasText: "Community" }).locator('tr[data-row-id="1::65001:1::0"]')
|
||||
await rec.getByRole("button", { name: "Закрепить", exact: true }).click()
|
||||
await expect(rec.getByRole("button", { name: "Открепить", exact: true })).toBeVisible()
|
||||
await scope.getByRole("button", { name: "Следующая страница домашних устройств" }).click()
|
||||
await expect(scope.getByRole("status")).toContainText("6–6 из 6")
|
||||
await expect(scope.getByText("Другой дом 8", { exact: true })).toBeVisible()
|
||||
await scope.getByRole("button", { name: "Предыдущая страница домашних устройств" }).click()
|
||||
await page.getByRole("button", { name: "BGP community (12)", exact: true }).click()
|
||||
await expect(rec.getByRole("button", { name: "Открепить", exact: true })).toBeVisible()
|
||||
})
|
||||
Reference in new issue
Block a user