mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
test: 14-mapping tests migration (#18858)
This commit is contained in:
48
packages/testing/playwright/pages/InteractionsPage.ts
Normal file
48
packages/testing/playwright/pages/InteractionsPage.ts
Normal file
@@ -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