fix(ui): обозначить расчёт и симуляцию оптимизатора

This commit is contained in:
Denozordec committed 2026-09-30 22:29:46 +07:00
1 parent e58604c3c0
commit 59f0f82176
7 files changed
+104 -62

No files matched your search

+2 -2
View File
@@ -41,8 +41,8 @@ test("Оптимизатор: 12 WAN, все комбинации и закре
await expect(routes.locator("tr[data-row-id]")).toHaveCount(5)
await page.getByRole("button", { name: "Показать все 12 комбинаций", exact: true }).click()
await expect(routes.locator("tr[data-row-id]")).toHaveCount(12)
await routes.getByRole("button", { name: "P(opt)", exact: true }).click()
await routes.getByRole("button", { name: "P(opt)", exact: true }).click()
await routes.getByRole("button", { name: "Индекс", exact: true }).click()
await routes.getByRole("button", { name: "Индекс", exact: true }).click()
await expect(routes.locator("tr[data-row-id]").first()).toHaveAttribute("data-row-id", "1-wan12-2-3")
await page.getByRole("button", { name: "Свернуть", exact: true }).click()
await expect(routes.locator("tr[data-row-id]")).toHaveCount(5)
+35
View File
@@ -0,0 +1,35 @@
import {test,expect} from "@playwright/test"
const hosts=(["home-router","jump-host","exit-node"] as const).map((type,index)=>({id:index+1,name:"Роутер "+(index+1),host:"192.0.2."+(index+1),type,site:"TEST",country:"RU",enabled:true,status:"online",latency:10,model:"CHR",...(index===0?{wanUplinks:[{id:"wan",name:"WAN",isp:"ISP",iface:"ether1",ip:"198.51.100.1",maxDl:100,maxUl:100}]}:{})}))
test("Оптимизатор: live рекомендации не подтверждают фиктивную запись",async({page})=>{
let writes=0
await page.route("**/health",r=>r.fulfill({json:{ok:true}}))
await page.route("**/api/**",r=>{
const p=new URL(r.request().url()).pathname
if(r.request().method()!=="GET"&&!p.endsWith("/preview"))writes++
return r.fulfill({json:p==="/api/auth/config"?{required:false}:p==="/api/servers"?hosts:p==="/api/filters/rules"?{rulesets:[{serverId:"1",rules:[{id:"r",community:"65001:1",communityName:"Сервис",gateway:"192.0.2.2",gatewayTunnelId:"",description:""}]}]}:p==="/api/uptime/speed-probes"?{probes:[]}:p.endsWith("/preview")?{interfaces:[],changes:[],changedCount:0,interfacesTotal:0}:p.endsWith("/ospf")?{interfaces:[],instances:[],neighbors:[],bfdSessions:[]}:{}})
})
await page.goto("/route-optimizer")
await page.getByRole("button",{name:"BGP community (1)",exact:true}).click()
const grid=page.getByRole("table").filter({hasText:"Community"})
await expect(grid.locator("tr[data-row-id]")).toHaveCount(1)
await expect(grid.getByRole("columnheader",{name:"Базовый расчёт (WAN → JH → Exit)",exact:true})).toBeVisible()
await expect(grid.getByRole("button",{name:"Применить",exact:true})).toHaveCount(0)
await expect(grid.getByRole("button",{name:"Симулировать",exact:true})).toHaveCount(0)
await expect(page.getByRole("button",{name:/Симулировать все/})).toHaveCount(0)
await expect(page.getByText("✓ применено",{exact:true})).toHaveCount(0)
await expect(page.getByText(/Применение Community к устройству недоступно/)).toBeVisible()
await page.getByRole("button",{name:/Настройки оптимизатора/}).click()
await expect(page.getByText("Автоприменение Community недоступно",{exact:true})).toBeVisible()
await expect(page.getByText("Применять автоматически",{exact:true})).toHaveCount(0)
expect(writes).toBe(0)
})
test("Оптимизатор: демо подтверждает только симуляцию",async({page})=>{
await page.addInitScript(()=>localStorage.setItem("routerlists:data-source","mock"))
await page.route("**/health",r=>r.fulfill({json:{ok:true}}));await page.route("**/api/**",r=>r.fulfill({json:new URL(r.request().url()).pathname==="/api/auth/config"?{required:false}:{}}))
await page.goto("/route-optimizer")
await page.getByRole("button",{name:/^BGP community/}).last().click()
const simulate=page.getByRole("button",{name:"Симулировать",exact:true}).first()
await expect(simulate).toBeVisible();await simulate.click()
await expect(page.getByText("✓ симуляция завершена",{exact:true}).first()).toBeVisible()
await expect(page.getByText("✓ применено",{exact:true})).toHaveCount(0)
})