2023-06-29 15:54:45 +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-06-29 15:54:45 +03:00
|
|
|
import {
|
2024-05-08 07:21:02 +03:00
|
|
|
confirmExperimentalPrompt,
|
2023-06-29 15:54:45 +03:00
|
|
|
openAboutPanel,
|
|
|
|
openAppearancePanel,
|
2024-05-08 07:21:02 +03:00
|
|
|
openExperimentalFeaturesPanel,
|
2023-06-29 15:54:45 +03:00
|
|
|
openSettingModal,
|
|
|
|
openShortcutsPanel,
|
2023-07-13 12:05:01 +03:00
|
|
|
} from '@affine-test/kit/utils/setting';
|
2023-09-02 08:57:04 +03:00
|
|
|
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
|
2023-07-13 12:05:01 +03:00
|
|
|
import { expect } from '@playwright/test';
|
2023-06-29 15:54:45 +03:00
|
|
|
|
|
|
|
test('Open settings modal', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-06-29 15:54:45 +03:00
|
|
|
await openSettingModal(page);
|
|
|
|
|
2023-10-12 08:04:58 +03:00
|
|
|
const modal = page.getByTestId('setting-modal');
|
2023-06-29 15:54:45 +03:00
|
|
|
await expect(modal).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2023-08-31 21:15:55 +03:00
|
|
|
test('change language using keyboard', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-08-31 21:15:55 +03:00
|
|
|
await openSettingModal(page);
|
|
|
|
|
|
|
|
const locator = page.getByTestId('language-menu-button');
|
|
|
|
const oldName = await locator.textContent();
|
|
|
|
await locator.click();
|
|
|
|
await page.waitForTimeout(200);
|
|
|
|
await page.keyboard.press('ArrowDown', {
|
|
|
|
delay: 50,
|
|
|
|
});
|
|
|
|
await page.keyboard.press('Enter', {
|
|
|
|
delay: 50,
|
|
|
|
});
|
|
|
|
{
|
|
|
|
const newName = await locator.textContent();
|
|
|
|
expect(oldName).not.toBe(newName);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-06-29 15:54:45 +03:00
|
|
|
test('Change theme', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-06-29 15:54:45 +03:00
|
|
|
await openSettingModal(page);
|
|
|
|
await openAppearancePanel(page);
|
|
|
|
const root = page.locator('html');
|
|
|
|
|
|
|
|
await page.getByTestId('light-theme-trigger').click();
|
2023-11-29 07:43:35 +03:00
|
|
|
const lightMode = await root.evaluate(element => element.dataset.theme);
|
2023-06-29 15:54:45 +03:00
|
|
|
expect(lightMode).toBe('light');
|
|
|
|
|
|
|
|
await page.getByTestId('dark-theme-trigger').click();
|
2023-11-29 07:43:35 +03:00
|
|
|
const darkMode = await root.evaluate(element => element.dataset.theme);
|
2023-06-29 15:54:45 +03:00
|
|
|
expect(darkMode).toBe('dark');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Change layout width', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-06-29 15:54:45 +03:00
|
|
|
await openSettingModal(page);
|
|
|
|
await openAppearancePanel(page);
|
|
|
|
|
|
|
|
await page.getByTestId('full-width-layout-trigger').click();
|
|
|
|
|
2023-10-12 08:04:58 +03:00
|
|
|
const editorWrapper = page.locator('.editor-wrapper');
|
2023-06-29 15:54:45 +03:00
|
|
|
const className = await editorWrapper.getAttribute('class');
|
|
|
|
expect(className).toContain('full-screen');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Open shortcuts panel', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-06-29 15:54:45 +03:00
|
|
|
await openSettingModal(page);
|
|
|
|
await openShortcutsPanel(page);
|
2023-10-12 08:04:58 +03:00
|
|
|
const title = page.getByTestId('keyboard-shortcuts-title');
|
2023-06-29 15:54:45 +03:00
|
|
|
await expect(title).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Open about panel', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-06-29 15:54:45 +03:00
|
|
|
await openSettingModal(page);
|
|
|
|
await openAboutPanel(page);
|
2023-10-12 08:04:58 +03:00
|
|
|
const title = page.getByTestId('about-title');
|
2023-06-29 15:54:45 +03:00
|
|
|
await expect(title).toBeVisible();
|
|
|
|
});
|
2023-07-06 05:19:06 +03:00
|
|
|
|
2024-05-08 07:21:02 +03:00
|
|
|
test('Open experimental features panel', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
|
|
|
await waitForEditorLoad(page);
|
|
|
|
await openSettingModal(page);
|
|
|
|
await openExperimentalFeaturesPanel(page);
|
|
|
|
const prompt = page.getByTestId('experimental-prompt');
|
|
|
|
await expect(prompt).toBeVisible();
|
|
|
|
await confirmExperimentalPrompt(page);
|
|
|
|
const settings = page.getByTestId('experimental-settings');
|
|
|
|
await expect(settings).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2023-07-06 05:19:06 +03:00
|
|
|
test('Different workspace should have different name in the setting panel', async ({
|
|
|
|
page,
|
|
|
|
}) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-09-02 08:57:04 +03:00
|
|
|
await createLocalWorkspace({ name: 'New Workspace 2' }, page);
|
|
|
|
await createLocalWorkspace({ name: 'New Workspace 3' }, page);
|
2023-07-06 05:19:06 +03:00
|
|
|
await openSettingModal(page);
|
|
|
|
await page.getByTestId('current-workspace-label').click();
|
2023-11-17 10:50:01 +03:00
|
|
|
await expect(page.getByTestId('workspace-name-input')).toHaveValue(
|
2023-07-06 05:19:06 +03:00
|
|
|
'New Workspace 3'
|
|
|
|
);
|
|
|
|
await page.getByText('New Workspace 2').click();
|
2023-11-17 10:50:01 +03:00
|
|
|
await expect(page.getByTestId('workspace-name-input')).toHaveValue(
|
2023-07-06 05:19:06 +03:00
|
|
|
'New Workspace 2'
|
|
|
|
);
|
|
|
|
});
|