11 lines
4.3 KiB
TypeScript
11 lines
4.3 KiB
TypeScript
import {test,expect,type Page} from "@playwright/test"
|
|
import {evoSettings,evoCatalog} from "./fixtures/evobgp"
|
|
async function setup(page:Page){await page.route("**/health",r=>r.fulfill({json:{ok:true}}));await page.route("**/api/**",r=>{const path=new URL(r.request().url()).pathname;return r.fulfill(path==="/api/auth/config"?{json:{required:false}}:path==="/api/evobgp/settings"?{json:evoSettings}:path==="/api/evobgp/catalog"?{json:evoCatalog}:{status:503,json:{error:"outside settings fixture"}})});await page.goto("/settings")}
|
|
|
|
test("Settings: general does not claim unsupported saving and links actual tools",async({page})=>{await setup(page);await expect(page.getByRole("button",{name:"Сохранить",exact:true})).toHaveCount(0);await expect(page.locator("#main-content").getByRole("link",{name:"Сбор данных",exact:true})).toHaveAttribute("href","/data-collection");await expect(page.locator("#main-content").getByRole("link",{name:"Диагностика",exact:true})).toHaveAttribute("href","/probes");await expect(page.locator("#main-content").getByRole("link",{name:"Открыть оптимизатор",exact:true})).toHaveAttribute("href","/route-optimizer");await expect(page.getByText("Мин. выигрыш (переключение)",{exact:true})).toHaveCount(0)})
|
|
test("Settings: theme applies to document and survives reload",async({page})=>{await setup(page);await page.getByRole("button",{name:"Светлая",exact:true}).click();await expect(page.locator("html")).toHaveClass(/light/);expect(await page.evaluate(()=>localStorage.getItem("rl-theme"))).toBe("light");await page.reload();await expect(page.getByRole("button",{name:"Светлая",exact:true})).toHaveAttribute("aria-pressed","true");await expect(page.locator("html")).toHaveClass(/light/)})
|
|
test("Settings: notifications lead to rules without invented channels",async({page})=>{await setup(page);await page.getByRole("button",{name:"Уведомления",exact:true}).click();await expect(page.locator("#main-content").getByRole("link",{name:"Открыть оповещения",exact:true})).toHaveAttribute("href","/alerts");await expect(page.getByRole("switch")).toHaveCount(0);await expect(page.getByText("[email protected]",{exact:true})).toHaveCount(0);await expect(page.getByRole("button",{name:"Сохранить",exact:true})).toHaveCount(0)})
|
|
test("Settings: API keys and security do not masquerade as configured features",async({page})=>{await setup(page);await page.getByRole("button",{name:"API-ключи",exact:true}).click();await expect(page.getByText("Создание и управление отдельными API-ключами в приложении пока недоступны.",{exact:true})).toBeVisible();await expect(page.getByText("Monitoring Script",{exact:true})).toHaveCount(0);await expect(page.getByRole("button",{name:"Создать ключ",exact:true})).toHaveCount(0);await page.getByRole("button",{name:"Безопасность",exact:true}).click();await expect(page.getByRole("status").filter({hasText:/Состояние MFA/})).toBeVisible();await expect(page.getByRole("switch")).toHaveCount(0);await expect(page.getByRole("textbox")).toHaveCount(0);await expect(page.getByRole("button",{name:"Сбросить",exact:true})).toHaveCount(0);await expect(page.locator("#main-content").getByRole("link",{name:"Управление пользователями",exact:true})).toHaveAttribute("href","/users")})
|
|
test("Settings: configured backend URL remains read only",async({page})=>{await setup(page);await expect(page.getByRole("textbox",{name:"URL бекенда",exact:true})).toHaveAttribute("readonly","")})
|
|
for(const width of [1440,390,320])test("Settings: adaptive general/"+width,async({page})=>{await page.setViewportSize({width,height:1000});await setup(page);await expect(page.getByRole("button",{name:"Тёмная",exact:true})).toBeEnabled();expect(await page.evaluate(()=>document.documentElement.scrollWidth<=window.innerWidth)).toBe(true);await page.screenshot({path:"docs/ux-ui/screens/settings-general-"+width+".png",fullPage:true,animations:"disabled"});await page.getByRole("button",{name:"Безопасность",exact:true}).click();expect(await page.evaluate(()=>document.documentElement.scrollWidth<=window.innerWidth)).toBe(true);await page.screenshot({path:"docs/ux-ui/screens/settings-security-"+width+".png",fullPage:true,animations:"disabled"})})
|