fix lint snippets
This commit is contained in:
parent
a41f8c3627
commit
029dc5ef6c
|
|
@ -48,14 +48,16 @@ async function pan(locator: Locator, deltaX?: number, deltaY?: number, steps?: n
|
||||||
clientX: centerX + deltaX * i / steps,
|
clientX: centerX + deltaX * i / steps,
|
||||||
clientY: centerY + deltaY * i / steps,
|
clientY: centerY + deltaY * i / steps,
|
||||||
}];
|
}];
|
||||||
await locator.dispatchEvent('touchmove', { touches, changedTouches: touches, targetTouches: touches });
|
await locator.dispatchEvent('touchmove',
|
||||||
|
{ touches, changedTouches: touches, targetTouches: touches });
|
||||||
}
|
}
|
||||||
|
|
||||||
await locator.dispatchEvent('touchend');
|
await locator.dispatchEvent('touchend');
|
||||||
}
|
}
|
||||||
|
|
||||||
test(`pan gesture to move the map`, async ({ page }) => {
|
test(`pan gesture to move the map`, async ({ page }) => {
|
||||||
await page.goto('https://www.google.com/maps/place/@37.4117722,-122.0713234,15z', { waitUntil: 'commit' });
|
await page.goto('https://www.google.com/maps/place/@37.4117722,-122.0713234,15z',
|
||||||
|
{ waitUntil: 'commit' });
|
||||||
await page.getByRole('button', { name: 'Keep using web' }).click();
|
await page.getByRole('button', { name: 'Keep using web' }).click();
|
||||||
await expect(page.getByRole('button', { name: 'Keep using web' })).not.toBeVisible();
|
await expect(page.getByRole('button', { name: 'Keep using web' })).not.toBeVisible();
|
||||||
// Get the map element.
|
// Get the map element.
|
||||||
|
|
@ -77,7 +79,7 @@ import { test, expect, devices, type Locator } from '@playwright/test';
|
||||||
test.use({ ...devices['Pixel 7'] });
|
test.use({ ...devices['Pixel 7'] });
|
||||||
|
|
||||||
async function pinch(locator: Locator,
|
async function pinch(locator: Locator,
|
||||||
arg: { deltaX?: number, deltaY?: number, steps?: number, direction?: 'in' | 'out' }) {
|
arg: { deltaX?: number, deltaY?: number, steps?: number, direction?: 'in' | 'out' }) {
|
||||||
const { centerX, centerY } = await locator.evaluate((target: HTMLElement) => {
|
const { centerX, centerY } = await locator.evaluate((target: HTMLElement) => {
|
||||||
const bounds = target.getBoundingClientRect();
|
const bounds = target.getBoundingClientRect();
|
||||||
const centerX = bounds.left + bounds.width / 2;
|
const centerX = bounds.left + bounds.width / 2;
|
||||||
|
|
@ -102,23 +104,26 @@ async function pinch(locator: Locator,
|
||||||
clientY: centerY,
|
clientY: centerY,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
await locator.dispatchEvent('touchstart', { touches, changedTouches: touches, targetTouches: touches });
|
await locator.dispatchEvent('touchstart',
|
||||||
|
{ touches, changedTouches: touches, targetTouches: touches });
|
||||||
|
|
||||||
// Move the touch points towards or away from each other.
|
// Move the touch points towards or away from each other.
|
||||||
for (let i = 1; i <= steps; i++) {
|
for (let i = 1; i <= steps; i++) {
|
||||||
|
const offset = (arg.direction === 'in' ? (deltaX - i * stepDeltaX) : (stepDeltaX * (i + 1)));
|
||||||
const touches = [
|
const touches = [
|
||||||
{
|
{
|
||||||
identifier: 0,
|
identifier: 0,
|
||||||
clientX: centerX - (arg.direction === 'in' ? (deltaX - i * stepDeltaX) : (stepDeltaX * (i + 1))),
|
clientX:centerX - offset,
|
||||||
clientY: centerY,
|
clientY: centerY,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
identifier: 0,
|
identifier: 0,
|
||||||
clientX: centerX + (arg.direction === 'in' ? (deltaX - i * stepDeltaX) : (stepDeltaX * (i + 1))),
|
clientX: centerX + offset,
|
||||||
clientY: centerY,
|
clientY: centerY,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
await locator.dispatchEvent('touchmove', { touches, changedTouches: touches, targetTouches: touches });
|
await locator.dispatchEvent('touchmove',
|
||||||
|
{ touches, changedTouches: touches, targetTouches: touches });
|
||||||
}
|
}
|
||||||
|
|
||||||
await locator.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] });
|
await locator.dispatchEvent('touchend', { touches: [], changedTouches: [], targetTouches: [] });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue