refactor: header options menu (#3615)

This commit is contained in:
JimmFly
2023-08-09 01:14:24 +08:00
committed by GitHub
parent 7d16a8348c
commit 4e84b9a121
21 changed files with 183 additions and 128 deletions

View File

@@ -70,7 +70,7 @@ test('Able to insert the title of an untitled page', async ({ page }) => {
await titleBarTextContent.click({ delay: 100 });
const titleContent = await page.getByTestId('title-content');
await titleContent.fill('test');
await page.getByTestId('save-edit-button').click({ delay: 100 });
await titleContent.blur();
expect(await titleBarTextContent.textContent()).toBe('test');
});
@@ -81,11 +81,11 @@ test('Able to edit the title of an existing page', async ({ page }) => {
await titleBarTextContent.click({ delay: 100 });
const titleContent = await page.getByTestId('title-content');
await titleContent.fill('test');
await page.getByTestId('save-edit-button').click({ delay: 100 });
await titleContent.blur();
expect(await titleBarTextContent.textContent()).toBe('test');
await titleBarTextContent.click({ delay: 100 });
await titleContent.fill('Sample text 2');
await page.getByTestId('save-edit-button').click({ delay: 100 });
await titleContent.blur();
expect(await titleBarTextContent.textContent()).toBe('Sample text 2');
});
@@ -98,10 +98,28 @@ test('Clearing out the title bar will remove the page title', async ({
await titleBarTextContent.click({ delay: 100 });
const titleContent = await page.getByTestId('title-content');
await titleContent.fill('test');
await page.getByTestId('save-edit-button').click({ delay: 100 });
await titleContent.blur();
expect(await titleBarTextContent.textContent()).toBe('test');
await titleBarTextContent.click({ delay: 100 });
await titleContent.fill('');
await page.getByTestId('save-edit-button').click({ delay: 100 });
await titleContent.blur();
expect(await titleBarTextContent.textContent()).toBe('Untitled');
});
test('Rename by editor header items, save with shortcut', async ({ page }) => {
await openHomePage(page);
await waitEditorLoad(page);
await clickPageMoreActions(page);
const menusRenameItem = page.getByTestId('editor-option-menu-rename');
await menusRenameItem.click({ delay: 100 });
const titleBarTextContent = page.getByTestId('title-edit-button');
const titleContent = page.getByTestId('title-content');
await titleContent.fill('test');
await page.keyboard.press('Enter');
expect(await titleBarTextContent.textContent()).toBe('test');
await clickPageMoreActions(page);
await menusRenameItem.click({ delay: 100 });
await titleContent.fill('');
await page.keyboard.press('Escape');
expect(await titleBarTextContent.textContent()).toBe('Untitled');
});

View File

@@ -0,0 +1,18 @@
import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
clickPageMoreActions,
waitEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test';
test('Click import page item', async ({ page }) => {
await openHomePage(page);
await waitEditorLoad(page);
await clickPageMoreActions(page);
const importItem = page.getByTestId('editor-option-menu-import');
await importItem.click();
const importModal = page.locator('import-page');
expect(await importModal.isVisible()).toBe(true);
});

View File

@@ -46,6 +46,6 @@ export const createLinkedPage = async (page: Page, pageName?: string) => {
export async function clickPageMoreActions(page: Page) {
return page
.getByTestId('editor-header-items')
.getByTestId('editor-option-menu')
.getByTestId('header-dropDownButton')
.click();
}