mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
feat: create workspace from loading existing exported file (#2122)
Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
@@ -1,48 +1,17 @@
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { test, testResultDir } from '@affine-test/kit/playwright';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { ElectronApplication } from 'playwright';
|
||||
import { _electron as electron } from 'playwright';
|
||||
|
||||
let electronApp: ElectronApplication;
|
||||
let page: Page;
|
||||
import { test } from './fixture';
|
||||
|
||||
test.beforeEach(async () => {
|
||||
electronApp = await electron.launch({
|
||||
args: [resolve(__dirname, '..')],
|
||||
executablePath: resolve(__dirname, '../node_modules/.bin/electron'),
|
||||
colorScheme: 'light',
|
||||
});
|
||||
page = await electronApp.firstWindow();
|
||||
await page.getByTestId('onboarding-modal-close-button').click({
|
||||
delay: 100,
|
||||
});
|
||||
// cleanup page data
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
// cleanup page data
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
await page.close();
|
||||
await electronApp.close();
|
||||
});
|
||||
|
||||
test('new page', async () => {
|
||||
test('new page', async ({ page, workspace }) => {
|
||||
await page.getByTestId('new-page-button').click({
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForSelector('v-line');
|
||||
const flavour = await page.evaluate(
|
||||
// @ts-expect-error
|
||||
() => globalThis.currentWorkspace.flavour
|
||||
);
|
||||
const flavour = (await workspace.current()).flavour;
|
||||
expect(flavour).toBe('local');
|
||||
});
|
||||
|
||||
test('app theme', async () => {
|
||||
test('app theme', async ({ page, electronApp }) => {
|
||||
await page.waitForSelector('v-line');
|
||||
const root = page.locator('html');
|
||||
{
|
||||
@@ -50,25 +19,35 @@ test('app theme', async () => {
|
||||
element.getAttribute('data-theme')
|
||||
);
|
||||
expect(themeMode).toBe('light');
|
||||
|
||||
// check if electron theme source is set to light
|
||||
const themeSource = await electronApp.evaluate(({ nativeTheme }) => {
|
||||
return nativeTheme.themeSource;
|
||||
});
|
||||
|
||||
expect(themeSource).toBe('light');
|
||||
}
|
||||
await page.screenshot({
|
||||
path: resolve(testResultDir, 'affine-light-theme-electron.png'),
|
||||
});
|
||||
await page.getByTestId('editor-option-menu').click();
|
||||
await page.getByTestId('change-theme-dark').click();
|
||||
await page.waitForTimeout(50);
|
||||
|
||||
{
|
||||
const themeMode = await root.evaluate(element =>
|
||||
element.getAttribute('data-theme')
|
||||
);
|
||||
expect(themeMode).toBe('dark');
|
||||
await page.getByTestId('editor-option-menu').click();
|
||||
await page.getByTestId('change-theme-dark').click();
|
||||
await page.waitForTimeout(50);
|
||||
{
|
||||
const themeMode = await root.evaluate(element =>
|
||||
element.getAttribute('data-theme')
|
||||
);
|
||||
expect(themeMode).toBe('dark');
|
||||
}
|
||||
|
||||
const themeSource = await electronApp.evaluate(({ nativeTheme }) => {
|
||||
return nativeTheme.themeSource;
|
||||
});
|
||||
|
||||
expect(themeSource).toBe('dark');
|
||||
}
|
||||
await page.screenshot({
|
||||
path: resolve(testResultDir, 'affine-dark-theme-electron.png'),
|
||||
});
|
||||
});
|
||||
|
||||
test('affine cloud disabled', async () => {
|
||||
test('affine cloud disabled', async ({ page }) => {
|
||||
await page.getByTestId('new-page-button').click({
|
||||
delay: 100,
|
||||
});
|
||||
@@ -79,7 +58,8 @@ test('affine cloud disabled', async () => {
|
||||
state: 'visible',
|
||||
});
|
||||
});
|
||||
test('affine onboarding button', async () => {
|
||||
|
||||
test('affine onboarding button', async ({ page }) => {
|
||||
await page.getByTestId('help-island').click();
|
||||
await page.getByTestId('easy-guide').click();
|
||||
const onboardingModal = page.locator('[data-testid=onboarding-modal]');
|
||||
|
||||
Reference in New Issue
Block a user