fix(storybook): fix storybook test (#5970)

This commit is contained in:
EYHN
2024-03-01 02:30:04 +00:00
parent d4e78dd3d0
commit a231884d9e
2 changed files with 53 additions and 29 deletions

View File

@@ -1,8 +1,9 @@
import { NavigateContext } from '@affine/core/hooks/use-navigate-helper';
import { workbenchRoutes } from '@affine/core/router';
import { assertExists } from '@blocksuite/global/utils';
import type { StoryFn } from '@storybook/react';
import { screen, userEvent, waitFor, within } from '@storybook/testing-library';
import { Outlet, useLocation } from 'react-router-dom';
import { Outlet, useLocation, useNavigate } from 'react-router-dom';
import {
reactRouterOutlets,
reactRouterParameters,
@@ -11,8 +12,13 @@ import {
const FakeApp = () => {
const location = useLocation();
const navigate = useNavigate();
// fixme: `key` is a hack to force the storybook to re-render the outlet
return <Outlet key={location.pathname} />;
return (
<NavigateContext.Provider value={navigate}>
<Outlet key={location.pathname} />
</NavigateContext.Provider>
);
};
export default {