fix(settings): убрать фиктивные операции и подключить реальные параметры

This commit is contained in:
Denozordec committed 2026-10-03 14:21:17 +07:00
1 parent 2b6d3ab2e0
commit b6f1b72500
14 files changed
+76 -320

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
import {test,expect,type Page} from "@playwright/test"
import {evoSettings,evoCatalog} from "./fixtures/evobgp"
const headers={"access-control-allow-origin":"*","access-control-allow-methods":"GET,POST,PUT,OPTIONS","access-control-allow-headers":"Content-Type,Authorization"}
async function setup(page:Page){await page.route("**/health",r=>r.fulfill({headers,json:{ok:true}}));await page.route("**/api/**",r=>{const path=new URL(r.request().url()).pathname;return r.fulfill(path==="/api/auth/config"?{headers,json:{required:false}}:path==="/api/evobgp/settings"?{headers,json:evoSettings}:path==="/api/evobgp/catalog"?{headers,json:evoCatalog}:{headers,status:503,json:{error:"outside source fixture"}})});await page.goto("/settings");await expect(page.getByRole("textbox",{name:"URL бекенда",exact:true})).toHaveValue("http://localhost:8000")}
test("Settings source: invalid backend URL stays draft without changing active source",async({page})=>{await setup(page);const input=page.getByRole("textbox",{name:"URL бекенда",exact:true});for(const value of ["bad","ftp://host.test","https://user:secret@host.test","https://host.test?token=secret"]){await input.fill(value);await input.press("Enter");await expect(page.locator("#main-content").getByRole("alert")).toContainText("Укажите HTTP(S) адрес");expect(await page.evaluate(()=>localStorage.getItem("routerlists:backend-url"))).toBeNull();await expect(input).toHaveValue(value)}})
test("Settings source: URL canonicalizes and persists after Enter",async({page})=>{await setup(page);const input=page.getByRole("textbox",{name:"URL бекенда",exact:true});await input.fill(" http://LOCALHOST:8101/ ");await input.press("Enter");await expect(input).toHaveValue("http://localhost:8101");expect(await page.evaluate(()=>localStorage.getItem("routerlists:backend-url"))).toBe("http://localhost:8101");await page.reload();await expect(input).toHaveValue("http://localhost:8101")})
test("Settings source: explicit demo/live mode persists",async({page})=>{await setup(page);await page.getByRole("button",{name:"Моковые",exact:true}).click();expect(await page.evaluate(()=>localStorage.getItem("routerlists:data-source"))).toBe("mock");await page.reload();await expect(page.getByRole("button",{name:"Моковые",exact:true})).toBeVisible();await page.getByRole("button",{name:"Живые",exact:true}).click();expect(await page.evaluate(()=>localStorage.getItem("routerlists:data-source"))).toBe("live")})