Files

9 lines
2.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import {test,expect} from '@playwright/test'
for(const width of [1440,320])test(`GRE: неверный keepalive сохраняет форму без запроса ${width}`,async({page})=>{
let writes=0;const tunnel={id:'*1',serverId:'1',name:'own210-gre',localAddress:'192.0.2.1',remoteAddress:'192.0.2.2',localInnerIp:'',remoteInnerIp:'',poolId:'live',ipsec:null,mtu:1476,keepaliveInterval:60,keepaliveRetries:3,dscp:'inherit',clampTcpMss:true,allowFastPath:false,comment:'own210',enabled:false,status:'down'}
await page.route('**/health',r=>r.fulfill({json:{ok:true}}));await page.route('**/api/**',r=>{if(r.request().method()!=='GET')writes++;const p=new URL(r.request().url()).pathname;return r.fulfill({json:p==='/api/auth/config'?{required:false}:p==='/api/servers'?[{id:1,name:'Own210 router',host:'192.0.2.1',enabled:true,country:'RU'}]:p==='/api/gre/tunnels'?{tunnels:[tunnel]}:{}})})
await page.setViewportSize({width,height:1000});await page.goto('/gre?server=1');await page.getByRole('button',{name:'Действия: own210-gre',exact:true}).click();await page.getByRole('menuitem',{name:'Редактировать',exact:true}).click();const form=page.getByRole('dialog');await form.getByRole('button',{name:'Дополнительно',exact:true}).click();await expect(form.getByLabel('Keepalive, с')).toHaveValue('60');await expect(form).not.toContainText('0 = откл.');await form.getByLabel('Комментарий').fill('сохранённый ввод');
for(const field of ['Keepalive, с','Попытки']){await form.getByLabel(field).fill('0');await form.getByRole('button',{name:'Сохранить',exact:true}).click();await expect(form.getByRole('alert')).toContainText('целые значения от 1');await expect(form.getByLabel('Комментарий')).toHaveValue('сохранённый ввод');await form.getByLabel(field).fill(field==='Попытки'?'3':'60')}
expect(writes).toBe(0);expect(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1)).toBe(true)
})