mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 16:19:43 +08:00
feat(electron): onboarding at first launch logic for client and web (#5183)
- Added a simple abstraction of persistent storage class.
- Different persistence solutions are provided for web and client.
- web: stored in localStorage
- client: stored in the application directory as `.json` file
- Define persistent app-config schema
- Add a new hook that can interactive with persistent-app-config reactively
This commit is contained in:
@@ -95,6 +95,8 @@ export const test = base.extend<{
|
||||
env.DEV_SERVER_URL = process.env.DEV_SERVER_URL;
|
||||
}
|
||||
|
||||
env.SKIP_ONBOARDING = '1';
|
||||
|
||||
const electronApp = await electron.launch({
|
||||
args: [clonedDist],
|
||||
env,
|
||||
|
||||
+10
-1
@@ -5,7 +5,7 @@ import path, { resolve } from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
import type { Workspace } from '@blocksuite/store';
|
||||
import { test as baseTest } from '@playwright/test';
|
||||
import { type BrowserContext, test as baseTest } from '@playwright/test';
|
||||
|
||||
export const rootDir = resolve(__dirname, '..', '..');
|
||||
// assert that the rootDir is the root of the project
|
||||
@@ -32,6 +32,12 @@ type CurrentWorkspace = {
|
||||
blockSuiteWorkspace: Workspace;
|
||||
};
|
||||
|
||||
export const skipOnboarding = async (context: BrowserContext) => {
|
||||
await context.addInitScript(() => {
|
||||
window.localStorage.setItem('app_config', '{"onBoarding":false}');
|
||||
});
|
||||
};
|
||||
|
||||
export const test = baseTest.extend<{
|
||||
workspace: {
|
||||
current: () => Promise<CurrentWorkspace>;
|
||||
@@ -59,6 +65,9 @@ export const test = baseTest.extend<{
|
||||
});
|
||||
},
|
||||
context: async ({ context }, use) => {
|
||||
// workaround for skipping onboarding redirect on the web
|
||||
await skipOnboarding(context);
|
||||
|
||||
if (enableCoverage) {
|
||||
await context.addInitScript(() =>
|
||||
window.addEventListener('beforeunload', () =>
|
||||
|
||||
Reference in New Issue
Block a user