feat(core): init organize (#7456)

This commit is contained in:
EYHN
2024-07-26 04:35:31 +00:00
parent b26b0c3a22
commit 54da85ec62
140 changed files with 6257 additions and 2804 deletions

View File

@@ -12,7 +12,7 @@ export async function clickEdgelessModeButton(page: Page) {
}
export async function clickPageModeButton(page: Page) {
page.getByTestId('switch-page-mode-button').click({
await page.getByTestId('switch-page-mode-button').click({
delay: 50,
});
await expect(

View File

@@ -71,16 +71,36 @@ export const getPageByTitle = (page: Page, title: string) => {
return page.getByTestId('page-list-item').getByText(title);
};
export const dragTo = async (page: Page, locator: Locator, target: Locator) => {
export const dragTo = async (
page: Page,
locator: Locator,
target: Locator,
location: 'top-left' | 'top' | 'bottom' | 'center' = 'center'
) => {
await locator.hover();
await page.mouse.down();
await page.waitForTimeout(1000);
await page.mouse.move(1, 1);
const targetElement = await target.boundingBox();
if (!targetElement) {
throw new Error('target element not found');
}
await page.mouse.move(targetElement.x, targetElement.y);
await target.hover();
const position =
location === 'center'
? {
x: targetElement.width / 2,
y: targetElement.height / 2,
}
: location === 'top-left'
? { x: 1, y: 1 }
: location === 'top'
? { x: targetElement.width / 2, y: 1 }
: location === 'bottom'
? { x: targetElement.width / 2, y: targetElement.height - 1 }
: { x: 1, y: 1 };
await target.hover({
position: position,
});
await page.mouse.up();
};