test: fix webkit test on Darwin (#27029)

This commit is contained in:
Andrey Lushnikov 2023-09-12 15:01:44 -07:00 committed by GitHub
parent fac4560a82
commit 64bf2a624f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,6 @@
*/
import { browserTest as it, expect } from '../config/browserTest';
import os from 'os';
it.describe('mobile viewport', () => {
it.skip(({ browserName }) => browserName === 'firefox');
@ -191,7 +190,7 @@ it.describe('mobile viewport', () => {
await context.close();
});
it('view scale should reset after navigation', async ({ browser, browserName, isLinux, isWindows, isMac, headless }) => {
it('view scale should reset after navigation', async ({ browser, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/26876' });
const context = await browser.newContext({
viewport: { width: 390, height: 664 },
@ -225,23 +224,12 @@ it.describe('mobile viewport', () => {
});
await page.goto('http://localhost/button.html');
await page.getByText('Click me').click({ force: true });
let expected = [{ x: 41, y: 18 }];
if (browserName === 'webkit') {
if (isLinux) {
if (headless)
expected = [{ x: 50, y: 20 }];
else
expected = [{ x: 45, y: 20 }];
} else if (isWindows) {
expected = [{ x: 40, y: 20 }];
} else if (isMac) {
if (parseInt(os.release(), 10) === 21)
expected = [{ x: 40, y: 17 }];
else
expected = [{ x: 37, y: 15 }];
}
}
expect(await page.evaluate(() => (window as any).clicks)).toEqual(expected);
const box = await page.locator('button').boundingBox();
const clicks = await page.evaluate(() => (window as any).clicks);
expect(clicks.length).toBe(1);
const [{ x, y }] = clicks;
const isClickInsideButton = box.x <= x && x <= box.x + box.width && box.y <= y && y <= box.y + box.height;
expect(isClickInsideButton).toBe(true);
await context.close();
});
});