mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 10:41:13 +08:00

- Migrates Angular test app tests from Cypress to Playwright - Resolves test TODOs with Angular 18 - Resolves nav TODO by adding in standalone components - Updates browserslist to remove warnings --------- Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import type { Locator, Page } from '@playwright/test';
|
|
|
|
// Drag an element by a given amount of pixels
|
|
export const dragElementBy = async (
|
|
element: Locator,
|
|
page: Page,
|
|
dragByX = 0,
|
|
dragByY = 0
|
|
) => {
|
|
const boundingBox = await element.boundingBox();
|
|
if (!boundingBox) {
|
|
throw new Error('Element not visible');
|
|
}
|
|
|
|
const startX = boundingBox.x + boundingBox.width / 2;
|
|
const startY = boundingBox.y + boundingBox.height / 2;
|
|
const endX = startX + dragByX;
|
|
const endY = startY + dragByY;
|
|
|
|
await page.mouse.move(startX, startY);
|
|
await page.mouse.down();
|
|
await page.mouse.move(endX, endY);
|
|
await page.mouse.up();
|
|
};
|
|
|
|
// Simulate swipe gesture for going back
|
|
export const ionSwipeToGoBack = async (page: Page, shouldGoBack = false) => {
|
|
const viewport = page.viewportSize();
|
|
if (!viewport) return;
|
|
|
|
const startX = 50;
|
|
const endX = shouldGoBack ? viewport.width - 50 : 50;
|
|
const y = viewport.height / 2;
|
|
|
|
await page.mouse.move(startX, y);
|
|
await page.mouse.down();
|
|
await page.mouse.move(endX, y);
|
|
await page.mouse.up();
|
|
}
|