fix(optimizer): правильно сопоставить направления DL и UL

This commit is contained in:
Denozordec committed 2026-10-07 13:44:36 +07:00
1 parent 7d331aff41
commit 4ba7f82ccf
6 files changed
+74 -17

No files matched your search

+17 -1
View File
@@ -7,7 +7,7 @@ for(const hasProbe of [true,false])test("Оптимизатор: исходны
const matrix=page.getByRole("table").filter({hasText:"WAN-аплинк"})
await expect(matrix.locator("tr[data-row-id]")).toHaveCount(1)
await expect(matrix).toContainText(hasProbe?"0 мс":"— мс")
await expect(matrix).toContainText(hasProbe?"↓150.25 ↑—":"↓— ↑—")
await expect(matrix).toContainText(hasProbe?"↓— ↑150.25":"↓— ↑—")
await expect(matrix).toContainText(hasProbe?"Скорость: дата неизвестна":"Измерения отсутствуют")
if(hasProbe)await expect(matrix.locator("time")).toHaveAttribute("datetime","2020-01-01T00:00:00Z")
await page.getByRole("button",{name:"Маршруты (1)",exact:true}).click()
@@ -36,3 +36,19 @@ test("Оптимизатор: WAN не подставляется из демо"
await expect(page.getByRole("table").filter({hasText:"WAN-аплинк"}).locator("tr[data-row-id]")).toHaveCount(0)
await expect(page.getByRole("link",{name:"Настроить сервер",exact:true})).toHaveAttribute("href","/servers?server=1")
})
for(const reversed of [false,true])test("Оптимизатор: направление peer и асимметричные лимиты/"+reversed,async({page})=>{
const common={host:"192.0.2.1",country:"RU",enabled:true,status:"online",latency:10}
const devices=[{...common,id:1,name:"Home",type:"home-router",wanUplinks:[{id:"w",name:"WAN",iface:"ether1",isp:"ISP",ip:"198.51.100.1",maxDl:100,maxUl:20}]},{...common,id:2,name:"Jump",type:"jump-host"},{...common,id:3,name:"Exit",type:"exit-node"}]
const base={srcInterface:"",dstInterface:"",enabled:true,lastPingRttMs:5,lastPingLossPct:0,lastPingAt:"2026-10-07T00:00:00Z"}
const probes=[{...base,id:"home",srcServerId:"1",dstServerId:"2",srcInterface:"ether1",lastTxAvgMbps:30,lastRxAvgMbps:80},{...base,id:"peer",srcServerId:reversed?"3":"2",dstServerId:reversed?"2":"3",lastTxAvgMbps:reversed?90:40,lastRxAvgMbps:reversed?40:90}]
const writes:string[]=[]
await page.route("**/health",r=>r.fulfill({json:{ok:true}}))
await page.route("**/api/**",r=>{const path=new URL(r.request().url()).pathname;if(r.request().method()!=="GET"&&!path.endsWith("/preview"))writes.push(path);return r.fulfill({json:path==="/api/auth/config"?{required:false}:path==="/api/servers"?devices:path==="/api/filters/rules"?{rulesets:[]}:path==="/api/uptime/speed-probes"?{probes}:path==="/api/ospf/catalog"?{interfaces:[],instances:[],neighbors:[],bfdSessions:[],routes:[],failures:[]}:path.endsWith("/preview")?{serverId:1,serverName:"Home",pingWeight:60,interfacesTotal:0,changedCount:0,unchangedCount:0,interfaces:[],changes:[]}: {}})})
await page.goto("/route-optimizer")
await expect(page.getByRole("table").filter({hasText:"WAN-аплинк"})).toContainText("↓80 ↑30")
await page.getByRole("button",{name:"Маршруты (1)",exact:true}).click()
const routes=page.getByRole("table").filter({hasText:"# Маршрут"})
await expect(routes).toContainText("Модель: 5 мс · ↓80 ↑20")
await expect(routes).toContainText("Модель: 5 мс · ↓90 ↑40")
expect(writes).toEqual([])
})