2023-09-17 23:26:06 +03:00
|
|
|
import { test } from '@affine-test/kit/electron';
|
2023-10-16 15:27:06 +03:00
|
|
|
import { withCtrlOrMeta } from '@affine-test/kit/utils/keyboard';
|
2023-10-11 09:05:06 +03:00
|
|
|
import { getBlockSuiteEditorTitle } from '@affine-test/kit/utils/page-logic';
|
2023-10-16 11:44:09 +03:00
|
|
|
import {
|
|
|
|
clickSideBarCurrentWorkspaceBanner,
|
|
|
|
clickSideBarSettingButton,
|
|
|
|
} from '@affine-test/kit/utils/sidebar';
|
2023-10-16 15:27:06 +03:00
|
|
|
import { expect, type Page } from '@playwright/test';
|
|
|
|
|
|
|
|
const historyShortcut = async (page: Page, command: 'goBack' | 'goForward') => {
|
|
|
|
await withCtrlOrMeta(page, () =>
|
|
|
|
page.keyboard.press(command === 'goBack' ? '[' : ']', { delay: 50 })
|
|
|
|
);
|
|
|
|
};
|
2023-04-28 09:40:44 +03:00
|
|
|
|
2023-05-09 10:30:01 +03:00
|
|
|
test('new page', async ({ page, workspace }) => {
|
2023-04-25 02:53:36 +03:00
|
|
|
await page.getByTestId('new-page-button').click({
|
|
|
|
delay: 100,
|
|
|
|
});
|
|
|
|
await page.waitForSelector('v-line');
|
2023-05-09 10:30:01 +03:00
|
|
|
const flavour = (await workspace.current()).flavour;
|
2023-04-25 02:53:36 +03:00
|
|
|
expect(flavour).toBe('local');
|
|
|
|
});
|
2023-04-28 09:26:14 +03:00
|
|
|
|
2023-05-15 09:13:30 +03:00
|
|
|
// macOS only
|
2023-10-16 15:27:06 +03:00
|
|
|
// if (platform() === 'darwin') {
|
|
|
|
test('app sidebar router forward/back', async ({ page }) => {
|
|
|
|
await page.getByTestId('help-island').click();
|
|
|
|
await page.getByTestId('easy-guide').click();
|
|
|
|
await page.getByTestId('onboarding-modal-next-button').click();
|
|
|
|
await page.getByTestId('onboarding-modal-close-button').click();
|
|
|
|
{
|
|
|
|
// create pages
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
await page.getByTestId('new-page-button').click({
|
|
|
|
delay: 100,
|
|
|
|
});
|
|
|
|
await page.waitForSelector('v-line');
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
await title.focus();
|
|
|
|
await title.pressSequentially('test1', {
|
|
|
|
delay: 100,
|
|
|
|
});
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
await page.getByTestId('new-page-button').click({
|
|
|
|
delay: 100,
|
|
|
|
});
|
|
|
|
await page.waitForSelector('v-line');
|
2023-10-11 09:05:06 +03:00
|
|
|
|
2023-10-16 15:27:06 +03:00
|
|
|
await title.focus();
|
|
|
|
await title.pressSequentially('test2', {
|
|
|
|
delay: 100,
|
|
|
|
});
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
await page.getByTestId('new-page-button').click({
|
|
|
|
delay: 100,
|
|
|
|
});
|
|
|
|
await page.waitForSelector('v-line');
|
|
|
|
await title.focus();
|
|
|
|
await title.pressSequentially('test3', {
|
|
|
|
delay: 100,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
{
|
2023-11-17 10:50:01 +03:00
|
|
|
await expect(page.locator('.affine-doc-page-block-title')).toHaveText(
|
|
|
|
'test3'
|
|
|
|
);
|
2023-10-16 15:27:06 +03:00
|
|
|
}
|
2023-05-15 09:13:30 +03:00
|
|
|
|
2023-10-16 15:27:06 +03:00
|
|
|
await page.click('[data-testid="app-sidebar-arrow-button-back"]');
|
|
|
|
await page.click('[data-testid="app-sidebar-arrow-button-back"]');
|
|
|
|
{
|
2023-11-17 10:50:01 +03:00
|
|
|
await expect(page.locator('.affine-doc-page-block-title')).toHaveText(
|
|
|
|
'test1'
|
|
|
|
);
|
2023-10-16 15:27:06 +03:00
|
|
|
}
|
|
|
|
await page.click('[data-testid="app-sidebar-arrow-button-forward"]');
|
|
|
|
await page.click('[data-testid="app-sidebar-arrow-button-forward"]');
|
|
|
|
{
|
2023-11-17 10:50:01 +03:00
|
|
|
await expect(page.locator('.affine-doc-page-block-title')).toHaveText(
|
|
|
|
'test3'
|
|
|
|
);
|
2023-10-16 15:27:06 +03:00
|
|
|
}
|
|
|
|
await historyShortcut(page, 'goBack');
|
|
|
|
await historyShortcut(page, 'goBack');
|
|
|
|
{
|
2023-11-17 10:50:01 +03:00
|
|
|
await expect(page.locator('.affine-doc-page-block-title')).toHaveText(
|
|
|
|
'test1'
|
|
|
|
);
|
2023-10-16 15:27:06 +03:00
|
|
|
}
|
|
|
|
await historyShortcut(page, 'goForward');
|
|
|
|
await historyShortcut(page, 'goForward');
|
|
|
|
{
|
2023-11-17 10:50:01 +03:00
|
|
|
await expect(page.locator('.affine-doc-page-block-title')).toHaveText(
|
|
|
|
'test3'
|
|
|
|
);
|
2023-10-16 15:27:06 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
// }
|
2023-05-15 09:13:30 +03:00
|
|
|
|
2023-08-26 23:26:48 +03:00
|
|
|
test('clientBorder value should disable by default on window', async ({
|
|
|
|
page,
|
|
|
|
}) => {
|
|
|
|
await clickSideBarSettingButton(page);
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
const settingItem = page.locator(
|
|
|
|
'[data-testid="client-border-style-trigger"]'
|
|
|
|
);
|
|
|
|
expect(await settingItem.locator('input').inputValue()).toEqual(
|
|
|
|
process.platform === 'win32' ? 'off' : 'on'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2023-05-09 10:30:01 +03:00
|
|
|
test('app theme', async ({ page, electronApp }) => {
|
2023-04-28 09:40:44 +03:00
|
|
|
const root = page.locator('html');
|
|
|
|
{
|
2023-11-29 07:43:35 +03:00
|
|
|
const themeMode = await root.evaluate(element => element.dataset.theme);
|
2023-04-28 09:40:44 +03:00
|
|
|
expect(themeMode).toBe('light');
|
2023-05-09 10:30:01 +03:00
|
|
|
|
2023-05-10 06:04:36 +03:00
|
|
|
const theme = await electronApp.evaluate(({ nativeTheme }) => {
|
|
|
|
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
2023-05-09 10:30:01 +03:00
|
|
|
});
|
|
|
|
|
2023-05-10 06:04:36 +03:00
|
|
|
expect(theme).toBe('light');
|
2023-04-28 09:40:44 +03:00
|
|
|
}
|
2023-05-09 10:30:01 +03:00
|
|
|
|
2023-04-28 09:40:44 +03:00
|
|
|
{
|
2023-07-31 10:56:51 +03:00
|
|
|
await page.getByTestId('settings-modal-trigger').click();
|
|
|
|
await page.getByTestId('appearance-panel-trigger').click();
|
2023-05-09 10:30:01 +03:00
|
|
|
await page.waitForTimeout(50);
|
2023-07-31 10:56:51 +03:00
|
|
|
await page.getByTestId('dark-theme-trigger').click();
|
2023-11-29 07:43:35 +03:00
|
|
|
const themeMode = await root.evaluate(element => element.dataset.theme);
|
2023-05-10 06:04:36 +03:00
|
|
|
expect(themeMode).toBe('dark');
|
|
|
|
const theme = await electronApp.evaluate(({ nativeTheme }) => {
|
|
|
|
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
2023-05-09 10:30:01 +03:00
|
|
|
});
|
2023-05-10 06:04:36 +03:00
|
|
|
expect(theme).toBe('dark');
|
2023-04-28 09:40:44 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-05-09 10:30:01 +03:00
|
|
|
test('affine onboarding button', async ({ page }) => {
|
2023-05-04 10:29:16 +03:00
|
|
|
await page.getByTestId('help-island').click();
|
|
|
|
await page.getByTestId('easy-guide').click();
|
|
|
|
const onboardingModal = page.locator('[data-testid=onboarding-modal]');
|
|
|
|
expect(await onboardingModal.isVisible()).toEqual(true);
|
|
|
|
const switchVideo = page.locator(
|
|
|
|
'[data-testid=onboarding-modal-switch-video]'
|
|
|
|
);
|
|
|
|
expect(await switchVideo.isVisible()).toEqual(true);
|
|
|
|
await page.getByTestId('onboarding-modal-next-button').click();
|
|
|
|
const editingVideo = page.locator(
|
|
|
|
'[data-testid=onboarding-modal-editing-video]'
|
|
|
|
);
|
|
|
|
expect(await editingVideo.isVisible()).toEqual(true);
|
2023-05-10 11:11:42 +03:00
|
|
|
await page.getByTestId('onboarding-modal-close-button').click();
|
2023-05-04 10:29:16 +03:00
|
|
|
|
|
|
|
expect(await onboardingModal.isVisible()).toEqual(false);
|
|
|
|
});
|
2023-06-29 19:15:44 +03:00
|
|
|
|
|
|
|
test('windows only check', async ({ page }) => {
|
|
|
|
const windowOnlyUI = page.locator('[data-platform-target=win32]');
|
|
|
|
if (process.platform === 'win32') {
|
|
|
|
await expect(windowOnlyUI).toBeVisible();
|
|
|
|
} else {
|
|
|
|
await expect(windowOnlyUI).not.toBeVisible();
|
|
|
|
}
|
|
|
|
});
|
2023-07-11 07:37:47 +03:00
|
|
|
|
|
|
|
test('delete workspace', async ({ page }) => {
|
2023-10-16 11:44:09 +03:00
|
|
|
await clickSideBarCurrentWorkspaceBanner(page);
|
2023-07-11 07:37:47 +03:00
|
|
|
await page.getByTestId('new-workspace').click();
|
2023-10-11 09:05:06 +03:00
|
|
|
await page
|
|
|
|
.getByTestId('create-workspace-input')
|
|
|
|
.pressSequentially('Delete Me', {
|
|
|
|
delay: 100,
|
|
|
|
});
|
2023-08-17 07:20:27 +03:00
|
|
|
await page.getByTestId('create-workspace-create-button').click({
|
|
|
|
delay: 100,
|
|
|
|
});
|
2023-09-26 17:11:04 +03:00
|
|
|
// await page.getByTestId('create-workspace-continue-button').click({
|
|
|
|
// delay: 100,
|
|
|
|
// });
|
2023-08-17 07:20:27 +03:00
|
|
|
await page.waitForTimeout(1000);
|
2023-08-29 13:07:05 +03:00
|
|
|
await clickSideBarSettingButton(page);
|
2023-07-11 07:37:47 +03:00
|
|
|
await page.getByTestId('current-workspace-label').click();
|
|
|
|
expect(await page.getByTestId('workspace-name-input').inputValue()).toBe(
|
|
|
|
'Delete Me'
|
|
|
|
);
|
2023-10-11 09:05:06 +03:00
|
|
|
const contentElement = page.getByTestId('setting-modal-content');
|
2023-07-11 07:37:47 +03:00
|
|
|
const boundingBox = await contentElement.boundingBox();
|
|
|
|
if (!boundingBox) {
|
|
|
|
throw new Error('boundingBox is null');
|
|
|
|
}
|
|
|
|
await page.mouse.move(
|
|
|
|
boundingBox.x + boundingBox.width / 2,
|
|
|
|
boundingBox.y + boundingBox.height / 2
|
|
|
|
);
|
|
|
|
await page.mouse.wheel(0, 500);
|
|
|
|
await page.getByTestId('delete-workspace-button').click();
|
2023-10-11 09:05:06 +03:00
|
|
|
await page
|
|
|
|
.getByTestId('delete-workspace-input')
|
|
|
|
.pressSequentially('Delete Me');
|
2023-07-11 07:37:47 +03:00
|
|
|
await page.getByTestId('delete-workspace-confirm-button').click();
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
|
|
|
'Demo Workspace'
|
|
|
|
);
|
|
|
|
});
|