Add mobile catalog layout regression test
This commit is contained in:
parent
893de0e726
commit
6066bf17f2
@ -37,6 +37,29 @@ test('chat photo guard compresses a large camera image', async ({ page }) => {
|
||||
});
|
||||
expect(Math.max(result.width,result.height)).toBeLessThanOrEqual(2048);expect(result.size).toBeLessThan(result.original);expect(result.size).toBeLessThanOrEqual(15*1024*1024);expect(result.type).toBe('image/jpeg');expect(result.name.endsWith('.jpg')).toBeTruthy();
|
||||
});
|
||||
test('mobile catalog header keeps search and actions aligned', async ({ page }, testInfo) => {
|
||||
test.skip(testInfo.project.name!=='mobile-390');
|
||||
await page.goto('/index.html', { waitUntil:'domcontentloaded' });
|
||||
await page.waitForFunction(()=>document.getElementById('sunCatalogSearch')&&document.getElementById('sunCatalogTabsButton')&&document.getElementById('sunLiveCatalogPdfButton')&&document.querySelector('.sun-catalog-menu-button'),null,{timeout:10000});
|
||||
const state=await page.evaluate(()=>{
|
||||
const r=el=>el.getBoundingClientRect();
|
||||
const tools=document.querySelector('header>.sun-side-tools');
|
||||
const search=document.getElementById('sunCatalogSearch');
|
||||
const pdf=document.getElementById('sunLiveCatalogPdfButton');
|
||||
const tabs=document.getElementById('sunCatalogTabsButton');
|
||||
const menu=document.querySelector('.sun-catalog-menu-button');
|
||||
const cats=document.querySelector('#new .cats');
|
||||
const rects=[pdf,tabs,menu].map(r);
|
||||
return {toolsDisplay:tools?getComputedStyle(tools).display:'missing',searchWidth:r(search).width,viewport:innerWidth,tops:rects.map(x=>x.top),heights:rects.map(x=>x.height),bodyWidth:document.body.scrollWidth,docWidth:document.documentElement.scrollWidth,catsNowrap:cats?getComputedStyle(cats).flexWrap:null};
|
||||
});
|
||||
expect(state.toolsDisplay).toBe('none');
|
||||
expect(state.searchWidth).toBeGreaterThan(state.viewport*.78);
|
||||
expect(Math.max(...state.tops)-Math.min(...state.tops)).toBeLessThanOrEqual(2);
|
||||
expect(Math.max(...state.heights)-Math.min(...state.heights)).toBeLessThanOrEqual(2);
|
||||
expect(state.bodyWidth).toBeLessThanOrEqual(state.viewport+2);
|
||||
expect(state.docWidth).toBeLessThanOrEqual(state.viewport+2);
|
||||
expect(state.catsNowrap).toBe('nowrap');
|
||||
});
|
||||
test('mobile body does not overflow viewport', async ({ page }, testInfo) => {
|
||||
test.skip(testInfo.project.name!=='mobile-390'); await page.goto('/index.html', { waitUntil:'domcontentloaded' }); await page.waitForTimeout(500);
|
||||
const dims=await page.evaluate(()=>({innerWidth,scrollWidth:document.documentElement.scrollWidth,bodyWidth:document.body.scrollWidth}));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user