2023-02-05 13:41:18 +03:00
|
|
|
import { expect } from '@playwright/test';
|
2023-02-17 10:33:32 +03:00
|
|
|
|
2023-03-24 01:15:40 +03:00
|
|
|
import { openHomePage } from '../libs/load-page';
|
2023-03-28 08:25:16 +03:00
|
|
|
import { waitMarkdownImported } from '../libs/page-logic';
|
2023-03-24 01:15:40 +03:00
|
|
|
import { test } from '../libs/playwright';
|
2022-12-30 16:40:15 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
test('Collapse Sidebar', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
|
|
|
await waitMarkdownImported(page);
|
|
|
|
await page.getByTestId('sliderBar-arrowButton-collapse').click();
|
|
|
|
const sliderBarArea = page.getByTestId('sliderBar-root');
|
|
|
|
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);
|
|
|
|
await waitMarkdownImported(page);
|
|
|
|
await page.getByTestId('sliderBar-arrowButton-collapse').click();
|
|
|
|
const sliderBarArea = page.getByTestId('sliderBar-inner');
|
|
|
|
await expect(sliderBarArea).not.toBeInViewport();
|
2022-12-30 16:40:15 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
await page.getByTestId('sliderBar-arrowButton-expand').click();
|
|
|
|
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);
|
|
|
|
await waitMarkdownImported(page);
|
|
|
|
const sliderBarArea = page.getByTestId('sliderBar-inner');
|
|
|
|
await expect(sliderBarArea).toBeVisible();
|
2023-03-31 04:12:18 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
await page.getByTestId('sliderBar-resizer').click();
|
|
|
|
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);
|
|
|
|
await waitMarkdownImported(page);
|
|
|
|
const sliderBarArea = page.getByTestId('sliderBar-inner');
|
|
|
|
await expect(sliderBarArea).toBeVisible();
|
2023-03-31 04:12:18 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
const sliderResizer = page.getByTestId('sliderBar-resizer');
|
|
|
|
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();
|
|
|
|
const boundingBox = await page.getByTestId('sliderBar-root').boundingBox();
|
|
|
|
expect(boundingBox?.width).toBe(400);
|
|
|
|
});
|
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);
|
|
|
|
await waitMarkdownImported(page);
|
|
|
|
const sliderBarArea = page.getByTestId('sliderBar-inner');
|
|
|
|
const sliderBarModalBackground = page.getByTestId(
|
|
|
|
'sliderBar-modalBackground'
|
|
|
|
);
|
|
|
|
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
|
|
|
});
|