mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
fix(core): should focus when clicking sidebar button (#9339)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { test } from '@affine-test/kit/playwright';
|
||||
import { clickEdgelessModeButton } from '@affine-test/kit/utils/editor';
|
||||
import {
|
||||
copyByKeyboard,
|
||||
pasteByKeyboard,
|
||||
selectAllByKeyboard,
|
||||
withCtrlOrMeta,
|
||||
writeTextToClipboard,
|
||||
} from '@affine-test/kit/utils/keyboard';
|
||||
@@ -587,3 +590,30 @@ test('can use slash menu to insert an external link', async ({ page }) => {
|
||||
link
|
||||
);
|
||||
});
|
||||
|
||||
test('Paste content with keyboard', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page, 'Test');
|
||||
|
||||
// goto main content
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
// input hello world to editor
|
||||
await page.keyboard.type('hello world', {
|
||||
delay: 50,
|
||||
});
|
||||
|
||||
await selectAllByKeyboard(page);
|
||||
await copyByKeyboard(page);
|
||||
|
||||
const quickSearchButton = page.locator(
|
||||
'[data-testid=slider-bar-quick-search-button]'
|
||||
);
|
||||
await quickSearchButton.click();
|
||||
const quickSearch = page.locator('[data-testid=cmdk-quick-search]');
|
||||
await expect(quickSearch).toBeVisible();
|
||||
|
||||
await pasteByKeyboard(page);
|
||||
await expect(page.locator('[cmdk-input]')).toHaveValue('hello world');
|
||||
});
|
||||
|
||||
@@ -64,6 +64,12 @@ export async function pasteByKeyboard(page: Page) {
|
||||
await keyUpCtrlOrMeta(page);
|
||||
}
|
||||
|
||||
export async function selectAllByKeyboard(page: Page) {
|
||||
await keyDownCtrlOrMeta(page);
|
||||
await page.keyboard.press('a', { delay: 50 });
|
||||
await keyUpCtrlOrMeta(page);
|
||||
}
|
||||
|
||||
export async function writeTextToClipboard(page: Page, text: string) {
|
||||
// paste the url
|
||||
await page.evaluate(
|
||||
|
||||
Reference in New Issue
Block a user