fix(settings): убрать фиктивные операции и подключить реальные параметры
This commit is contained in:
1 parent
2b6d3ab2e0
commit
b6f1b72500
14 files changed
+76
-320
No files matched your search
@@ -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")})
|
||||
@@ -0,0 +1,10 @@
|
||||
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("admin@routerlists.io",{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"})})
|
||||
Reference in new issue
Block a user