mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-16 05:47:09 +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:
@@ -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