fix(ui): проверить терминал и мобильный выбор устройства

This commit is contained in:
Denozordec committed 2026-10-01 03:59:47 +07:00
1 parent ea4095d1f1
commit 8bda85129f
23 files changed
+102 -9

No files matched your search

+18
View File
@@ -46,3 +46,21 @@ test("Терминал: reader видит устройство, выполнен
await page.route("**/api/auth/config",r=>r.fulfill({json:{required:true}}))
await page.goto("/terminal?server=1");await expect(command(page)).toBeDisabled();await expect(page.getByRole("status").filter({hasText:"Для выполнения требуется mm:servers:write"})).toBeVisible()
})
for(const q of ["server=1&server=2","server=1&host=192.0.2.1","server=bad%20id"])test("Терминал: неверный URL не читает каталог "+q,async({page})=>{
let reads=0;await page.route("**/api/servers",r=>{reads++;return r.fulfill({json:devices})})
await page.goto("/terminal?"+q);await expect(page.getByRole("alert").filter({hasText:"Некорректная ссылка"})).toBeVisible();expect(reads).toBe(0)
await page.getByRole("button",{name:"Сбросить контекст терминала"}).click();await expect(page.getByRole("option",{name:/Первый/})).toBeVisible();expect(reads).toBe(1)
})
test("Терминал: disabled и известный пустой каталог",async({page})=>{
await page.route("**/api/servers",r=>r.fulfill({json:[{...devices[0],enabled:false}]}));await page.goto("/terminal?server=1")
await expect(command(page)).toBeDisabled();await expect(page.getByRole("status").filter({hasText:"Устройство отключено"})).toBeVisible()
await page.route("**/api/servers",r=>r.fulfill({json:[]}));await page.goto("/terminal");await expect(page.getByText("Устройств пока нет",{exact:true})).toBeVisible();await expect(command(page)).toHaveCount(0)
})
test("Терминал: таймаут сохраняет команду и не повторяет автоматически",async({page})=>{
let calls=0,release!:()=>void;const gate=new Promise<void>(resolve=>release=resolve)
await page.route("**/api/servers/1/exec",async r=>{calls++;await gate;await r.fulfill({json:{output:"запоздалый ответ"}}).catch(()=>{})})
await page.clock.install();await page.goto("/terminal?server=1");await command(page).fill("interface print");await command(page).press("Enter");await expect.poll(()=>calls).toBe(1)
await page.clock.fastForward(60010);await expect(page.getByRole("alert").filter({hasText:"Время ожидания истекло"})).toBeVisible();await expect(command(page)).toHaveValue("interface print");await expect(command(page)).toBeEnabled();expect(calls).toBe(1)
release();await expect(page.getByRole("region",{name:"Вывод терминала"})).not.toContainText("запоздалый ответ")
})