import { test, expect } from "@playwright/test" for (const missing of ["cost", "disabled", "inactive"]) test("OSPF: запись недоступна при неизвестном " + missing, async ({ page }) => { const host={ serverId:1, serverName:"Роутер", serverSite:"", serverCountry:"RU" } const iface={ ...host, id:"*1", instance:"default", area:"backbone", areaId:"0.0.0.0", interface:"ether1", cost:20, type:null, disabled:false, inactive:false, priority:null, helloInterval:null, deadInterval:null, useBfd:null } let phase=0, writes=0 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()==="POST")writes++;return r.fulfill({json:path==="/api/servers"?[{id:1,name:"Роутер",host:"192.0.2.1",enabled:true,country:"RU",status:null}]:path==="/api/ospf/catalog"?{neighbors:[],interfaces:[{...iface,...(phase===0?{[missing]:null}:phase===2?{cost:0}:{})}],instances:[],bfdSessions:[],routes:[{...host,id:"r",destination:"192.0.2.0/24",type:"O",cost:phase===0?null:0,nextHop:"192.0.2.2",via:"ether1",area:"backbone"}],failures:[]}:path==="/api/auth/config"?{required:false}:{}})}) await page.goto("/ospf") await page.getByRole("option").filter({hasText:"Роутер"}).click() const optimize=page.getByRole("button",{name:"Оптимизировать OSPF",exact:true}) await expect(optimize).toBeDisabled() await expect(page.getByRole("status").filter({hasText:"Оптимизация недоступна"})).toBeVisible() if(missing==="cost")await expect(page.getByText("cur —",{exact:true})).toBeVisible() await page.getByRole("button",{name:"Маршруты",exact:true}).click() await expect(page.locator("tr[data-row-id]").locator("td").nth(2)).toHaveText("—") phase=1 await page.getByRole("button",{name:"Обновить",exact:true}).click() await expect(page.locator("tr[data-row-id]").locator("td").nth(2)).toHaveText("0") await page.getByRole("button",{name:"Интерфейсы",exact:true}).click() await expect(optimize).toBeEnabled() phase=2 await page.getByRole("button",{name:"Обновить",exact:true}).click() await expect(page.getByText("cur 0",{exact:true})).toBeVisible() await expect(optimize).toBeDisabled() expect(writes).toBe(0) })