mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-31 09:09:54 +08:00
feat: run app in closure (#3790)
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { pluginRegisterPromise } from '@affine/core/bootstrap/register-plugins';
|
||||
import { routes } from '@affine/core/router';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { Decorator, StoryFn } from '@storybook/react';
|
||||
import type { StoryFn } from '@storybook/react';
|
||||
import { userEvent, waitFor } from '@storybook/testing-library';
|
||||
import { use } from 'foxact/use';
|
||||
import { Outlet, useLocation } from 'react-router-dom';
|
||||
import {
|
||||
reactRouterOutlets,
|
||||
@@ -11,11 +9,6 @@ import {
|
||||
withRouter,
|
||||
} from 'storybook-addon-react-router-v6';
|
||||
|
||||
const withCleanLocalStorage: Decorator = (Story, context) => {
|
||||
localStorage.clear();
|
||||
return <Story {...context} />;
|
||||
};
|
||||
|
||||
const FakeApp = () => {
|
||||
const location = useLocation();
|
||||
// fixme: `key` is a hack to force the storybook to re-render the outlet
|
||||
@@ -30,10 +23,9 @@ export default {
|
||||
};
|
||||
|
||||
export const Index: StoryFn = () => {
|
||||
use(pluginRegisterPromise);
|
||||
return <FakeApp />;
|
||||
};
|
||||
Index.decorators = [withRouter, withCleanLocalStorage];
|
||||
Index.decorators = [withRouter];
|
||||
Index.parameters = {
|
||||
reactRouter: reactRouterParameters({
|
||||
routing: reactRouterOutlets(routes),
|
||||
@@ -59,7 +51,7 @@ SettingPage.play = async ({ canvasElement }) => {
|
||||
) as Element;
|
||||
await userEvent.click(settingModalBtn);
|
||||
};
|
||||
SettingPage.decorators = [withRouter, withCleanLocalStorage];
|
||||
SettingPage.decorators = [withRouter];
|
||||
SettingPage.parameters = {
|
||||
reactRouter: reactRouterParameters({
|
||||
routing: reactRouterOutlets(routes),
|
||||
@@ -69,7 +61,7 @@ SettingPage.parameters = {
|
||||
export const NotFoundPage: StoryFn = () => {
|
||||
return <FakeApp />;
|
||||
};
|
||||
NotFoundPage.decorators = [withRouter, withCleanLocalStorage];
|
||||
NotFoundPage.decorators = [withRouter];
|
||||
NotFoundPage.parameters = {
|
||||
reactRouter: reactRouterParameters({
|
||||
routing: reactRouterOutlets(routes),
|
||||
@@ -99,7 +91,7 @@ WorkspaceList.play = async ({ canvasElement }) => {
|
||||
) as Element;
|
||||
await userEvent.click(currentWorkspace);
|
||||
};
|
||||
WorkspaceList.decorators = [withRouter, withCleanLocalStorage];
|
||||
WorkspaceList.decorators = [withRouter];
|
||||
WorkspaceList.parameters = {
|
||||
reactRouter: reactRouterParameters({
|
||||
routing: reactRouterOutlets(routes),
|
||||
|
||||
Reference in New Issue
Block a user