add tests (#536)
This commit is contained in:
@@ -117,6 +117,7 @@ export const Header = () => {
|
|||||||
/>
|
/>
|
||||||
<StyledHeader hasWarning={showWarning}>
|
<StyledHeader hasWarning={showWarning}>
|
||||||
<StyledLogo
|
<StyledLogo
|
||||||
|
data-testid="left-top-corner-logo"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
contactModalHandler(true);
|
contactModalHandler(true);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ type TransitionsModalProps = {
|
|||||||
export const ContactModal = ({ open, onClose }: TransitionsModalProps) => {
|
export const ContactModal = ({ open, onClose }: TransitionsModalProps) => {
|
||||||
return (
|
return (
|
||||||
<Modal open={open} onClose={onClose}>
|
<Modal open={open} onClose={onClose}>
|
||||||
<StyledModalWrapper>
|
<StyledModalWrapper data-testid="contact-us-modal-content">
|
||||||
<StyledModalHeader>
|
<StyledModalHeader>
|
||||||
<StyledModalHeaderLeft>
|
<StyledModalHeaderLeft>
|
||||||
<StyledLogo src={logo.src} alt="" />
|
<StyledLogo src={logo.src} alt="" />
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ const AnimateRadioItem = ({
|
|||||||
</StyledIcon>
|
</StyledIcon>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<StyledRadioItem active={active} status={status} {...props}>
|
<StyledRadioItem title={label} active={active} status={status} {...props}>
|
||||||
{isLeft ? icon : null}
|
{isLeft ? icon : null}
|
||||||
<StyledLabel shrink={status !== 'stretch'} isLeft={isLeft}>
|
<StyledLabel shrink={status !== 'stretch'} isLeft={isLeft}>
|
||||||
{label}
|
{label}
|
||||||
@@ -95,7 +95,11 @@ export const EditorModeSwitch = ({
|
|||||||
}, [isHover, mode]);
|
}, [isHover, mode]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledAnimateRadioContainer shrink={!isHover} style={style}>
|
<StyledAnimateRadioContainer
|
||||||
|
data-testid="editor-mode-switcher"
|
||||||
|
shrink={!isHover}
|
||||||
|
style={style}
|
||||||
|
>
|
||||||
<AnimateRadioItem
|
<AnimateRadioItem
|
||||||
isLeft={true}
|
isLeft={true}
|
||||||
label="Paper"
|
label="Paper"
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export const FAQ = () => {
|
|||||||
<StyledFAQWrapper>
|
<StyledFAQWrapper>
|
||||||
<Tooltip content="Contact Us" placement="left-end">
|
<Tooltip content="Contact Us" placement="left-end">
|
||||||
<StyledIconWrapper
|
<StyledIconWrapper
|
||||||
|
data-testid="right-bottom-contact-us-icon"
|
||||||
isEdgelessDark={isEdgelessDark}
|
isEdgelessDark={isEdgelessDark}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowContent(false);
|
setShowContent(false);
|
||||||
@@ -45,6 +46,7 @@ export const FAQ = () => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content="Keyboard Shortcuts" placement="left-end">
|
<Tooltip content="Keyboard Shortcuts" placement="left-end">
|
||||||
<StyledIconWrapper
|
<StyledIconWrapper
|
||||||
|
data-testid="shortcuts-icon"
|
||||||
isEdgelessDark={isEdgelessDark}
|
isEdgelessDark={isEdgelessDark}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowContent(false);
|
setShowContent(false);
|
||||||
@@ -58,7 +60,10 @@ export const FAQ = () => {
|
|||||||
</Grow>
|
</Grow>
|
||||||
|
|
||||||
<div style={{ position: 'relative' }}>
|
<div style={{ position: 'relative' }}>
|
||||||
<StyledIconWrapper isEdgelessDark={isEdgelessDark}>
|
<StyledIconWrapper
|
||||||
|
data-testid="faq-icon"
|
||||||
|
isEdgelessDark={isEdgelessDark}
|
||||||
|
>
|
||||||
<HelpIcon />
|
<HelpIcon />
|
||||||
</StyledIconWrapper>
|
</StyledIconWrapper>
|
||||||
<StyledTransformIcon in={showContent}>
|
<StyledTransformIcon in={showContent}>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const ShortcutsModal = ({ open, onClose }: ModalProps) => {
|
|||||||
: windowsKeyboardShortcuts;
|
: windowsKeyboardShortcuts;
|
||||||
return createPortal(
|
return createPortal(
|
||||||
<Slide direction="left" in={open} mountOnEnter unmountOnExit>
|
<Slide direction="left" in={open} mountOnEnter unmountOnExit>
|
||||||
<StyledShortcutsModal>
|
<StyledShortcutsModal data-testid="shortcuts-modal">
|
||||||
<>
|
<>
|
||||||
<StyledModalHeader>
|
<StyledModalHeader>
|
||||||
<StyledTitle>
|
<StyledTitle>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const config: PlaywrightTestConfig = {
|
|||||||
workers: process.env.CI ? 1 : undefined,
|
workers: process.env.CI ? 1 : undefined,
|
||||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
reporter: 'list',
|
reporter: 'list',
|
||||||
|
// reporter: 'html',
|
||||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||||
use: {
|
use: {
|
||||||
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
|
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
|
||||||
|
|||||||
38
tests/change-page-mode.spec.ts
Normal file
38
tests/change-page-mode.spec.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
import { loadPage } from './libs/load-page';
|
||||||
|
|
||||||
|
loadPage();
|
||||||
|
|
||||||
|
test.describe('Change page mode(Paper or Edgeless)', () => {
|
||||||
|
test('Switch to edgeless', async ({ page }) => {
|
||||||
|
const switcher = page.locator('[data-testid=editor-mode-switcher]');
|
||||||
|
const box = await switcher.boundingBox();
|
||||||
|
await expect(box?.x).not.toBeUndefined();
|
||||||
|
|
||||||
|
// mouse hover trigger animation for showing full switcher
|
||||||
|
await page.mouse.move((box?.x ?? 0) + 5, (box?.y ?? 0) + 5);
|
||||||
|
|
||||||
|
const edgelessButton = page.locator(
|
||||||
|
'[data-testid=editor-mode-switcher] [title=Edgeless]'
|
||||||
|
);
|
||||||
|
await edgelessButton.click();
|
||||||
|
|
||||||
|
// // mouse move to edgeless button
|
||||||
|
// await page.mouse.move(
|
||||||
|
// (box?.x ?? 0) + (box?.width ?? 0) - 5,
|
||||||
|
// (box?.y ?? 0) + 5
|
||||||
|
// );
|
||||||
|
|
||||||
|
// await page.waitForTimeout(1000);
|
||||||
|
|
||||||
|
// // click switcher
|
||||||
|
// await page.mouse.click(
|
||||||
|
// (box?.x ?? 0) + (box?.width ?? 0) - 5,
|
||||||
|
// (box?.y ?? 0) + 5
|
||||||
|
// );
|
||||||
|
|
||||||
|
const edgelessDom = page.locator('edgeless-page-block');
|
||||||
|
|
||||||
|
await expect(await edgelessDom.isVisible()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
35
tests/contact-us.spec.ts
Normal file
35
tests/contact-us.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { test, expect, type Page } from '@playwright/test';
|
||||||
|
import { loadPage } from './libs/load-page';
|
||||||
|
|
||||||
|
loadPage();
|
||||||
|
|
||||||
|
test.describe('Open contact us', () => {
|
||||||
|
test('Click left-top corner Logo', async ({ page }) => {
|
||||||
|
const leftTopCorner = page.locator('[data-testid=left-top-corner-logo]');
|
||||||
|
await leftTopCorner.click();
|
||||||
|
|
||||||
|
const contactUsModal = page.locator(
|
||||||
|
'[data-testid=contact-us-modal-content]'
|
||||||
|
);
|
||||||
|
await expect(contactUsModal).toContainText('Join our community.');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Click right-bottom corner contact icon', async ({ page }) => {
|
||||||
|
const faqIcon = page.locator('[data-testid=faq-icon]');
|
||||||
|
const box = await faqIcon.boundingBox();
|
||||||
|
await expect(box?.x).not.toBeUndefined();
|
||||||
|
await page.mouse.move((box?.x ?? 0) + 5, (box?.y ?? 0) + 5);
|
||||||
|
|
||||||
|
const rightBottomContactUs = page.locator(
|
||||||
|
'[data-testid=right-bottom-contact-us-icon]'
|
||||||
|
);
|
||||||
|
await expect(await rightBottomContactUs.isVisible()).toEqual(true);
|
||||||
|
|
||||||
|
await rightBottomContactUs.click();
|
||||||
|
|
||||||
|
const contactUsModal = page.locator(
|
||||||
|
'[data-testid=contact-us-modal-content]'
|
||||||
|
);
|
||||||
|
await expect(contactUsModal).toContainText('Join our community.');
|
||||||
|
});
|
||||||
|
});
|
||||||
9
tests/libs/load-page.ts
Normal file
9
tests/libs/load-page.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { test } from '@playwright/test';
|
||||||
|
|
||||||
|
export function loadPage() {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('http://localhost:3000');
|
||||||
|
// waiting for page loading end
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
21
tests/shortcuts.spec.ts
Normal file
21
tests/shortcuts.spec.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
import { loadPage } from './libs/load-page';
|
||||||
|
|
||||||
|
loadPage();
|
||||||
|
|
||||||
|
test.describe('Shortcuts Modal', () => {
|
||||||
|
test('Open shortcuts modal', async ({ page }) => {
|
||||||
|
const faqIcon = page.locator('[data-testid=faq-icon]');
|
||||||
|
const box = await faqIcon.boundingBox();
|
||||||
|
await expect(box?.x).not.toBeUndefined();
|
||||||
|
await page.mouse.move((box?.x ?? 0) + 5, (box?.y ?? 0) + 5);
|
||||||
|
|
||||||
|
const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]');
|
||||||
|
await expect(await shortcutsIcon.isVisible()).toEqual(true);
|
||||||
|
|
||||||
|
await shortcutsIcon.click();
|
||||||
|
|
||||||
|
const shortcutsModal = page.locator('[data-testid=shortcuts-modal]');
|
||||||
|
await expect(shortcutsModal).toContainText('Keyboard Shortcuts');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import { test, expect, type Page } from '@playwright/test';
|
import { test, expect, type Page } from '@playwright/test';
|
||||||
|
import { loadPage } from './libs/load-page';
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
loadPage();
|
||||||
await page.goto('http://localhost:3000');
|
|
||||||
});
|
|
||||||
|
|
||||||
test.describe('Change Theme', () => {
|
test.describe('Change Theme', () => {
|
||||||
test('default white', async ({ page }) => {
|
test('default white', async ({ page }) => {
|
||||||
@@ -28,7 +27,7 @@ test.describe('Change Theme', () => {
|
|||||||
await expect(box?.x).not.toBeUndefined();
|
await expect(box?.x).not.toBeUndefined();
|
||||||
await page.mouse.move((box?.x ?? 0) + 5, (box?.y ?? 0) + 5);
|
await page.mouse.move((box?.x ?? 0) + 5, (box?.y ?? 0) + 5);
|
||||||
|
|
||||||
await page.waitForTimeout(3000);
|
await page.waitForTimeout(1000);
|
||||||
|
|
||||||
const darkButton = page.locator('[data-testid=change-theme-dark]');
|
const darkButton = page.locator('[data-testid=change-theme-dark]');
|
||||||
const darkButtonPositionTop = await darkButton.evaluate(
|
const darkButtonPositionTop = await darkButton.evaluate(
|
||||||
|
|||||||
Reference in New Issue
Block a user