first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { BasePage } from './BasePage';
|
||||
|
||||
export class InteractionsPage extends BasePage {
|
||||
constructor(page: Page) {
|
||||
super(page);
|
||||
}
|
||||
|
||||
async precisionDragToTarget(
|
||||
sourceLocator: Locator,
|
||||
targetLocator: Locator,
|
||||
position: 'top' | 'center' | 'bottom' = 'bottom',
|
||||
): Promise<void> {
|
||||
await expect(sourceLocator).toBeVisible();
|
||||
await expect(targetLocator).toBeVisible();
|
||||
|
||||
const targetBox = await targetLocator.boundingBox();
|
||||
if (!targetBox) {
|
||||
throw new Error('Could not get bounding box for target element');
|
||||
}
|
||||
|
||||
let dropPosition: { x: number; y: number };
|
||||
switch (position) {
|
||||
case 'top':
|
||||
dropPosition = { x: targetBox.x + targetBox.width / 2, y: targetBox.y + 2 };
|
||||
break;
|
||||
case 'center':
|
||||
dropPosition = {
|
||||
x: targetBox.x + targetBox.width / 2,
|
||||
y: targetBox.y + targetBox.height / 2,
|
||||
};
|
||||
break;
|
||||
case 'bottom':
|
||||
dropPosition = {
|
||||
x: targetBox.x + targetBox.width / 2,
|
||||
y: targetBox.y + targetBox.height - 2,
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
await sourceLocator.hover();
|
||||
await this.page.mouse.down();
|
||||
await this.page.mouse.move(dropPosition.x, dropPosition.y);
|
||||
await this.page.mouse.up();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user