mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat(storybook): add not found page (#3767)
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -152,7 +152,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
workingDir: apps/storybook
|
workingDir: apps/storybook
|
||||||
buildScriptName: build
|
buildScriptName: build
|
||||||
onlyStoryNames: Preview/Core
|
onlyStoryNames: 'Preview/**'
|
||||||
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
||||||
|
|
||||||
build-core:
|
build-core:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { routes } from '@affine/core/router';
|
import { routes } from '@affine/core/router';
|
||||||
import { expect } from '@storybook/jest';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
import type { StoryContext, StoryFn } from '@storybook/react';
|
import type { StoryContext, StoryFn } from '@storybook/react';
|
||||||
import { userEvent } from '@storybook/testing-library';
|
import { userEvent, waitFor } from '@storybook/testing-library';
|
||||||
import { Outlet, useLocation } from 'react-router-dom';
|
import { Outlet, useLocation } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
reactRouterOutlets,
|
reactRouterOutlets,
|
||||||
@@ -27,7 +27,6 @@ export default {
|
|||||||
export const Index: StoryFn = () => {
|
export const Index: StoryFn = () => {
|
||||||
return <FakeApp />;
|
return <FakeApp />;
|
||||||
};
|
};
|
||||||
|
|
||||||
Index.decorators = [withRouter, withCleanLocalStorage];
|
Index.decorators = [withRouter, withCleanLocalStorage];
|
||||||
Index.parameters = {
|
Index.parameters = {
|
||||||
reactRouter: reactRouterParameters({
|
reactRouter: reactRouterParameters({
|
||||||
@@ -38,13 +37,20 @@ Index.parameters = {
|
|||||||
export const SettingPage: StoryFn = () => {
|
export const SettingPage: StoryFn = () => {
|
||||||
return <FakeApp />;
|
return <FakeApp />;
|
||||||
};
|
};
|
||||||
|
|
||||||
SettingPage.play = async ({ canvasElement }) => {
|
SettingPage.play = async ({ canvasElement }) => {
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
await waitFor(
|
||||||
|
() => {
|
||||||
|
assertExists(
|
||||||
|
canvasElement.querySelector('[data-testid="settings-modal-trigger"]')
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timeout: 5000,
|
||||||
|
}
|
||||||
|
);
|
||||||
const settingModalBtn = canvasElement.querySelector(
|
const settingModalBtn = canvasElement.querySelector(
|
||||||
'[data-testid="settings-modal-trigger"]'
|
'[data-testid="settings-modal-trigger"]'
|
||||||
) as Element;
|
) as Element;
|
||||||
expect(settingModalBtn).not.toBeNull();
|
|
||||||
await userEvent.click(settingModalBtn);
|
await userEvent.click(settingModalBtn);
|
||||||
};
|
};
|
||||||
SettingPage.decorators = [withRouter, withCleanLocalStorage];
|
SettingPage.decorators = [withRouter, withCleanLocalStorage];
|
||||||
@@ -53,3 +59,16 @@ SettingPage.parameters = {
|
|||||||
routing: reactRouterOutlets(routes),
|
routing: reactRouterOutlets(routes),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const NotFoundPage: StoryFn = () => {
|
||||||
|
return <FakeApp />;
|
||||||
|
};
|
||||||
|
NotFoundPage.decorators = [withRouter, withCleanLocalStorage];
|
||||||
|
NotFoundPage.parameters = {
|
||||||
|
reactRouter: reactRouterParameters({
|
||||||
|
routing: reactRouterOutlets(routes),
|
||||||
|
location: {
|
||||||
|
path: '/404',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user