27 lines
3.7 KiB
JavaScript
27 lines
3.7 KiB
JavaScript
async page => {
|
||
const base='http://127.0.0.1:50541';
|
||
const errors=[];page.on('pageerror', e=>errors.push(e.message));
|
||
const checks=[];
|
||
function check(name,ok,actual){checks.push({name,passed:!!ok,actual});if(!ok) throw new Error(name+': '+JSON.stringify(actual));}
|
||
await page.setViewportSize({width:360,height:800});
|
||
await page.goto(base+'/library');
|
||
await page.locator('#library-query').fill('GPS');
|
||
let count=await page.locator('.search-results>a').count();check('full body search GPS',count>0,count);
|
||
await page.locator('#library-query').fill('невозможныйзапрос98765');check('unknown search empty',await page.locator('.empty').isVisible(),await page.locator('.result-count').innerText());
|
||
await page.getByRole('button',{name:'Показать все материалы'}).click();count=await page.locator('.search-results>a').count();check('reset all articles',count>=27,count);
|
||
const category=await page.locator('#library-category option').nth(1).textContent();await page.locator('#library-category').selectOption({label:category});const kinds=await page.locator('.search-kind').allTextContents();check('category filter',kinds.length>0&&kinds.every(k=>k.includes(category)),{category,kinds});
|
||
await page.getByRole('button',{name:'Сбросить',exact:true}).click();
|
||
await page.locator('#library-query').focus();await page.keyboard.press('Tab');check('keyboard search reset',await page.evaluate(()=>document.activeElement?.textContent?.trim()==='Сбросить'),await page.evaluate(()=>document.activeElement?.outerHTML));
|
||
await page.goto(base+'/tools/recording-time');
|
||
await page.getByLabel('Ёмкость носителя, ГБ').fill('1');await page.getByLabel('Средний размер одного JPEG, КБ').fill('100');await page.getByLabel('Кадров/с на камеру').fill('5');await page.getByLabel('Число камер').fill('2');await page.getByLabel('Резерв места, %').fill('0');
|
||
let result=await page.locator('.time-result strong').innerText();check('JPEG known result',result==='0 ч 16 мин 40 с',result);
|
||
await page.getByLabel('Число камер').fill('1.5');result=await page.locator('.time-result strong').innerText();check('fractional cameras rejected',result==='Проверьте значения',result);
|
||
await page.getByLabel('Число камер').fill('2');await page.getByLabel('Ёмкость носителя, ГБ').fill('');check('empty capacity rejected',(await page.locator('.time-result strong').innerText())==='Проверьте значения');
|
||
await page.getByLabel('Видеопоток',{exact:true}).check();await page.getByLabel('Ёмкость носителя, ГБ').fill('128');await page.getByLabel('Суммарный битрейт, Мбит/с').fill('40');await page.getByLabel('Резерв места, %').fill('10');result=await page.locator('.time-result strong').innerText();check('stream known result',result==='6 ч 24 мин 0 с',result);
|
||
await page.getByLabel('Резерв места, %').fill('100');check('full reserve rejected',(await page.locator('.time-result strong').innerText())==='Проверьте значения');
|
||
await page.goto(base+'/samples/rain');const before=await page.locator('.frame-gallery img').count();const show=page.getByRole('button',{name:/Показать/});await show.click();const after=await page.locator('.frame-gallery img').count();check('gallery expands actual recovered frames',before===6&&after>before,{before,after});
|
||
const missing=await page.goto(base+'/this-original-page-does-not-exist');check('real404',missing.status()===404,missing.status());
|
||
check('no browser runtime errors',errors.length===0,errors);
|
||
return {base,viewport:{width:360,height:800},checks,errors};
|
||
}
|