mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 13:29:02 +08:00
f3ca17fcb3
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new slider component for line width selection, providing a more interactive and streamlined UI. - Added support for using the slider component across relevant panels. - **Improvements** - Simplified the line width selection panel for easier use and improved maintainability. - Enhanced event handling to prevent dropdowns from closing when interacting with the panel. - **Bug Fixes** - Improved event propagation control within the line styles panel. - **Chores** - Updated package exports to include the new slider component. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
import { test } from '@affine-test/kit/playwright';
|
|
import {
|
|
clickEdgelessModeButton,
|
|
clickView,
|
|
dragView,
|
|
locateEditorContainer,
|
|
locateToolbar,
|
|
setEdgelessTool,
|
|
} from '@affine-test/kit/utils/editor';
|
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
|
import {
|
|
clickNewPageButton,
|
|
waitForEditorLoad,
|
|
} from '@affine-test/kit/utils/page-logic';
|
|
import { expect } from '@playwright/test';
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await openHomePage(page);
|
|
await waitForEditorLoad(page);
|
|
await clickNewPageButton(page);
|
|
await clickEdgelessModeButton(page);
|
|
const container = locateEditorContainer(page);
|
|
await container.click();
|
|
});
|
|
|
|
test('should add highlighter', async ({ page }) => {
|
|
await setEdgelessTool(page, 'highlighter');
|
|
await dragView(page, [100, 300], [200, 400]);
|
|
|
|
await setEdgelessTool(page, 'default');
|
|
await clickView(page, [150, 350]);
|
|
|
|
const toolbar = locateToolbar(page);
|
|
|
|
await page.waitForTimeout(250);
|
|
|
|
await expect(toolbar).toBeVisible();
|
|
|
|
const lineWidthButton = toolbar
|
|
.locator('affine-slider')
|
|
.locator('.point-button[data-selected]')
|
|
.last();
|
|
const defaultLineWidth = await lineWidthButton.getAttribute('aria-label');
|
|
|
|
expect(defaultLineWidth).toBe('22');
|
|
});
|
|
|
|
test('should exit drawing tools menu when Escape is pressed', async ({
|
|
page,
|
|
}) => {
|
|
await setEdgelessTool(page, 'highlighter');
|
|
|
|
const drawingToolsMenu = page.locator('edgeless-pen-menu');
|
|
|
|
await expect(drawingToolsMenu).toBeVisible();
|
|
|
|
await page.keyboard.press('Escape');
|
|
|
|
await expect(drawingToolsMenu).toBeHidden();
|
|
});
|
|
|
|
test('should enter highlighter tool when `Shift + P` is pressed', async ({
|
|
page,
|
|
}) => {
|
|
const drawingToolButton = page.locator('.edgeless-pen-button');
|
|
const drawingToolsMenu = page.locator('edgeless-pen-menu');
|
|
|
|
await expect(drawingToolButton).toHaveAttribute('data-drawing-tool', 'brush');
|
|
await expect(drawingToolsMenu).toBeHidden();
|
|
|
|
await page.keyboard.press('Shift+P');
|
|
|
|
await expect(drawingToolButton).toHaveAttribute(
|
|
'data-drawing-tool',
|
|
'highlighter'
|
|
);
|
|
await expect(drawingToolsMenu).toBeVisible();
|
|
|
|
await page.keyboard.press('Escape');
|
|
await expect(drawingToolsMenu).toBeHidden();
|
|
await expect(drawingToolButton).toHaveAttribute(
|
|
'data-drawing-tool',
|
|
'highlighter'
|
|
);
|
|
});
|