2023-04-25 06:12:48 +03:00
|
|
|
import { test } from '@affine-test/kit/playwright';
|
2023-07-13 12:05:01 +03:00
|
|
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
2023-09-02 06:31:07 +03:00
|
|
|
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
|
2023-02-05 13:41:18 +03:00
|
|
|
import { expect } from '@playwright/test';
|
2023-02-17 10:33:32 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
test('Collapse Sidebar', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-08-31 15:46:06 +03:00
|
|
|
await page
|
|
|
|
.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]')
|
|
|
|
.click();
|
2023-04-28 00:46:08 +03:00
|
|
|
const sliderBarArea = page.getByTestId('app-sidebar');
|
2023-04-17 00:02:41 +03:00
|
|
|
await expect(sliderBarArea).not.toBeInViewport();
|
|
|
|
});
|
2022-12-30 16:40:15 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
test('Expand Sidebar', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-08-31 15:46:06 +03:00
|
|
|
await page
|
|
|
|
.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]')
|
|
|
|
.click();
|
2023-04-17 00:02:41 +03:00
|
|
|
const sliderBarArea = page.getByTestId('sliderBar-inner');
|
|
|
|
await expect(sliderBarArea).not.toBeInViewport();
|
2022-12-30 16:40:15 +03:00
|
|
|
|
2023-08-31 15:46:06 +03:00
|
|
|
await page
|
|
|
|
.locator('[data-testid=app-sidebar-arrow-button-expand][data-show=true]')
|
|
|
|
.click();
|
2023-04-17 00:02:41 +03:00
|
|
|
await expect(sliderBarArea).toBeInViewport();
|
|
|
|
});
|
2023-03-31 04:12:18 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
test('Click resizer can close sidebar', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-04-17 00:02:41 +03:00
|
|
|
const sliderBarArea = page.getByTestId('sliderBar-inner');
|
|
|
|
await expect(sliderBarArea).toBeVisible();
|
2023-03-31 04:12:18 +03:00
|
|
|
|
2023-12-13 10:52:01 +03:00
|
|
|
await page
|
|
|
|
.getByTestId('app-sidebar-wrapper')
|
|
|
|
.getByTestId('resize-handle')
|
|
|
|
.click();
|
2023-04-17 00:02:41 +03:00
|
|
|
await expect(sliderBarArea).not.toBeInViewport();
|
|
|
|
});
|
2023-03-31 04:12:18 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
test('Drag resizer can resize sidebar', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-04-17 00:02:41 +03:00
|
|
|
const sliderBarArea = page.getByTestId('sliderBar-inner');
|
|
|
|
await expect(sliderBarArea).toBeVisible();
|
2023-03-31 04:12:18 +03:00
|
|
|
|
2023-12-13 10:52:01 +03:00
|
|
|
const sliderResizer = page
|
|
|
|
.getByTestId('app-sidebar-wrapper')
|
|
|
|
.getByTestId('resize-handle');
|
2023-04-17 00:02:41 +03:00
|
|
|
await sliderResizer.hover();
|
|
|
|
await page.mouse.down();
|
|
|
|
await page.mouse.move(400, 300, {
|
|
|
|
steps: 10,
|
2023-03-31 04:12:18 +03:00
|
|
|
});
|
2023-04-17 00:02:41 +03:00
|
|
|
await page.mouse.up();
|
2023-04-28 00:46:08 +03:00
|
|
|
const boundingBox = await page.getByTestId('app-sidebar').boundingBox();
|
2023-06-21 14:57:59 +03:00
|
|
|
expect(boundingBox?.width).toBe(399);
|
2023-04-17 00:02:41 +03:00
|
|
|
});
|
2023-03-31 04:12:18 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
test('Sidebar in between sm & md breakpoint', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-04-17 00:02:41 +03:00
|
|
|
const sliderBarArea = page.getByTestId('sliderBar-inner');
|
2023-04-28 00:46:08 +03:00
|
|
|
const sliderBarModalBackground = page.getByTestId('app-sidebar-float-mask');
|
2023-04-17 00:02:41 +03:00
|
|
|
await expect(sliderBarArea).toBeInViewport();
|
|
|
|
await expect(sliderBarModalBackground).not.toBeVisible();
|
2023-03-31 04:12:18 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
await page.setViewportSize({
|
|
|
|
width: 768,
|
|
|
|
height: 1024,
|
|
|
|
});
|
|
|
|
await expect(sliderBarModalBackground).toBeVisible();
|
2023-03-31 04:12:18 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
// click modal background can close sidebar
|
|
|
|
await sliderBarModalBackground.click({
|
|
|
|
force: true,
|
|
|
|
position: { x: 600, y: 150 },
|
2023-03-31 04:12:18 +03:00
|
|
|
});
|
2023-04-17 00:02:41 +03:00
|
|
|
await expect(sliderBarArea).not.toBeInViewport();
|
2022-12-30 16:40:15 +03:00
|
|
|
});
|