improve playwright update test

This commit is contained in:
Rene Haas
2022-08-19 12:57:49 +02:00
parent d35bb4920c
commit a6b40e0231
3 changed files with 28 additions and 11 deletions
+2
View File
@@ -5,7 +5,9 @@ module.exports = {
timeout: 10 * 60 * 2000, timeout: 10 * 60 * 2000,
navigationTimeout: 1000, navigationTimeout: 1000,
retries: 0, retries: 0,
maxFailures: 0,
workers: 4, workers: 4,
fullyParallel: true,
projects: [ projects: [
{ {
name: 'Chromium', name: 'Chromium',
@@ -131,7 +131,7 @@ const initObj = hasClass(document.body, 'vpt')
? { ? {
target: target!, target: target!,
elements: { elements: {
viewport: target!, viewport: OverlayScrollbars.env().scrollbarsHiding && target!,
content: useContentElement, content: useContentElement,
}, },
} }
@@ -844,6 +844,8 @@ const start = async () => {
setTestResult(true); setTestResult(true);
} catch (e: any) { } catch (e: any) {
const { scrollbarsSize, scrollbarsOverlaid, scrollbarsHiding, rtlScrollBehavior, flexboxGlue } =
OverlayScrollbars.env();
console.error( console.error(
e.message, e.message,
{ {
@@ -853,7 +855,16 @@ const start = async () => {
}, },
{ {
updateCount, updateCount,
info: targetOptionsSlot!.textContent, env: {
scrollbarsSize,
scrollbarsOverlaid,
scrollbarsHiding,
rtlScrollBehavior,
flexboxGlue,
},
opts: targetOptionsSlot!.textContent,
flags: document.body.getAttribute('class'),
devicePixelRatio: window.devicePixelRatio,
} }
); );
} }
@@ -3,38 +3,42 @@ import { test, Page } from '@playwright/test';
playwrightRollup(); playwrightRollup();
test.describe.configure({ mode: 'parallel' });
const createTests = (fast?: boolean) => { const createTests = (fast?: boolean) => {
[false, true].forEach((targetIsViewport) => { [false, true].forEach((viewportIsTarget) => {
const isOrIsNot = targetIsViewport ? 'is' : 'is not'; const isOrIsNot = viewportIsTarget ? 'is' : 'is not';
const setTargetIsVp = async (page: Page) => { const setTargetIsVp = async (page: Page) => {
if (targetIsViewport) { if (viewportIsTarget) {
await page.click('#vpt'); await page.click('#vpt');
} }
}; };
const setFast = async (page: Page) => { const setFast = async (page: Page) => {
if (fast || targetIsViewport) { if (fast || viewportIsTarget) {
await page.click('#fast'); await page.click('#fast');
} }
}; };
test.describe(`target ${isOrIsNot} viewport`, () => { test.describe(`target ${isOrIsNot} viewport`, () => {
[false, true].forEach((nativeScrollbarStyling) => { [false, true].forEach((nativeScrollbarHiding) => {
const withText = nativeScrollbarStyling ? 'with' : 'without'; const withText = nativeScrollbarHiding ? 'with' : 'without';
const nsh = async (page: Page) => { const nsh = async (page: Page) => {
if (!nativeScrollbarStyling) { if (!nativeScrollbarHiding) {
await page.click('#nsh'); await page.click('#nsh');
} }
}; };
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
test.skip(
!nativeScrollbarHiding && viewportIsTarget,
'Viewport is target should only be initialized when nativeScrollbarHiding is supported.'
);
await setFast(page); await setFast(page);
await setTargetIsVp(page); await setTargetIsVp(page);
await nsh(page); await nsh(page);
}); });
test.describe(`${withText} native scrollbar styling`, () => { test.describe(`${withText} native scrollbar styling`, () => {
// test.describe.configure({ mode: 'parallel' });
test('default', async ({ page }) => { test('default', async ({ page }) => {
await expectSuccess(page); await expectSuccess(page);
}); });