mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-23 20:18:42 +08:00
feat(core): add editor commanads (#4514)
Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
@@ -67,6 +67,7 @@ test('Show collections items in sidebar', async ({ page }) => {
|
||||
.getByTestId('collection-page-option')
|
||||
.getByText('Delete');
|
||||
await deletePage.click();
|
||||
await page.getByTestId('confirm-delete-page').click();
|
||||
expect(await collections.getByTestId('collection-page').count()).toBe(0);
|
||||
await first.hover();
|
||||
await first.getByTestId('collection-options').click();
|
||||
|
||||
@@ -27,6 +27,12 @@ const keyboardDownAndSelect = async (page: Page, label: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const commandsIsVisible = async (page: Page, label: string) => {
|
||||
const locators = page.locator('[cmdk-item] [data-testid="cmdk-label"]');
|
||||
const actual = (await locators.allInnerTexts()).find(text => text === label);
|
||||
return !!actual;
|
||||
};
|
||||
|
||||
async function assertTitle(page: Page, text: string) {
|
||||
const edgeless = page.locator('affine-edgeless-page');
|
||||
if (!edgeless) {
|
||||
@@ -280,3 +286,49 @@ test('assert the recent browse pages are on the recent list', async ({
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('can use cmdk to export pdf', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to export');
|
||||
await openQuickSearchByShortcut(page);
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
keyboardDownAndSelect(page, 'Export to PDF'),
|
||||
]);
|
||||
expect(download.suggestedFilename()).toBe('this is a new page to export.pdf');
|
||||
});
|
||||
test('can use cmdk to export png', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to export');
|
||||
await openQuickSearchByShortcut(page);
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
keyboardDownAndSelect(page, 'Export to PNG'),
|
||||
]);
|
||||
expect(download.suggestedFilename()).toBe('this is a new page to export.png');
|
||||
});
|
||||
|
||||
test('can use cmdk to delete page and restore it', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page);
|
||||
await getBlockSuiteEditorTitle(page).click();
|
||||
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
|
||||
await openQuickSearchByShortcut(page);
|
||||
await keyboardDownAndSelect(page, 'Move to Trash');
|
||||
await page.getByTestId('confirm-delete-page').click();
|
||||
const restoreButton = page.getByTestId('page-restore-button');
|
||||
await expect(restoreButton).toBeVisible();
|
||||
await openQuickSearchByShortcut(page);
|
||||
expect(await commandsIsVisible(page, 'Move to Trash')).toBe(false);
|
||||
expect(await commandsIsVisible(page, 'Export to PDF')).toBe(false);
|
||||
expect(await commandsIsVisible(page, 'Restore from Trash')).toBe(true);
|
||||
await keyboardDownAndSelect(page, 'Restore from Trash');
|
||||
await expect(restoreButton).not.toBeVisible();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user