mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-28 09:43:42 +03:00
6c2c7dcd48
- document folder - full-text search - blob storage - basic edgeless support Co-authored-by: tzhangchi <terry.zhangchi@outlook.com> Co-authored-by: QiShaoXuan <qishaoxuan777@gmail.com> Co-authored-by: DiamondThree <diamond.shx@gmail.com> Co-authored-by: MingLiang Wang <mingliangwang0o0@gmail.com> Co-authored-by: JimmFly <yangjinfei001@gmail.com> Co-authored-by: Yifeng Wang <doodlewind@toeverything.info> Co-authored-by: Himself65 <himself65@outlook.com> Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com> Co-authored-by: Qi <474021214@qq.com>
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import type { Page } from '@playwright/test';
|
|
|
|
const IS_MAC = process.platform === 'darwin';
|
|
|
|
async function keyDownCtrlOrMeta(page: Page) {
|
|
if (IS_MAC) {
|
|
await page.keyboard.down('Meta');
|
|
} else {
|
|
await page.keyboard.down('Control');
|
|
}
|
|
}
|
|
|
|
async function keyUpCtrlOrMeta(page: Page) {
|
|
if (IS_MAC) {
|
|
await page.keyboard.up('Meta');
|
|
} else {
|
|
await page.keyboard.up('Control');
|
|
}
|
|
}
|
|
|
|
// It's not good enough, but better than calling keyDownCtrlOrMeta and keyUpCtrlOrMeta separately
|
|
export const withCtrlOrMeta = async (page: Page, fn: () => Promise<void>) => {
|
|
await keyDownCtrlOrMeta(page);
|
|
await fn();
|
|
await keyUpCtrlOrMeta(page);
|
|
};
|
|
|
|
export async function pressEnter(page: Page) {
|
|
// avoid flaky test by simulate real user input
|
|
await page.keyboard.press('Enter', { delay: 50 });
|
|
}
|
|
|
|
export async function pressTab(page: Page) {
|
|
await page.keyboard.press('Tab', { delay: 50 });
|
|
}
|
|
|
|
export async function pressShiftTab(page: Page) {
|
|
await page.keyboard.down('Shift');
|
|
await page.keyboard.press('Tab', { delay: 50 });
|
|
await page.keyboard.up('Shift');
|
|
}
|
|
|
|
export async function pressShiftEnter(page: Page) {
|
|
await page.keyboard.down('Shift');
|
|
await page.keyboard.press('Enter', { delay: 50 });
|
|
await page.keyboard.up('Shift');
|
|
}
|
|
|
|
export async function copyByKeyboard(page: Page) {
|
|
await keyDownCtrlOrMeta(page);
|
|
await page.keyboard.press('c', { delay: 50 });
|
|
await keyUpCtrlOrMeta(page);
|
|
}
|
|
|
|
export async function cutByKeyboard(page: Page) {
|
|
await keyDownCtrlOrMeta(page);
|
|
await page.keyboard.press('x', { delay: 50 });
|
|
await keyUpCtrlOrMeta(page);
|
|
}
|
|
|
|
export async function pasteByKeyboard(page: Page) {
|
|
await keyDownCtrlOrMeta(page);
|
|
await page.keyboard.press('v', { delay: 50 });
|
|
await keyUpCtrlOrMeta(page);
|
|
}
|