fix(core): should focus when clicking sidebar button (#9339)

This commit is contained in:
donteatfriedrice
2025-01-06 04:09:01 +00:00
parent fc863e484c
commit 09c7a597be
4 changed files with 38 additions and 0 deletions

View File

@@ -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');
});

View File

@@ -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(