Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use tighter "satisfies" typing in storybook #456

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apps/nextjs/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import "@fontsource/lexend/800.css";
import "@fontsource/lexend/900.css";
import { OakThemeProvider, oakDefaultTheme } from "@oaknational/oak-components";
import type { Preview, Decorator } from "@storybook/react";
import { initialize as initializeMsw, mswLoader } from "msw-storybook-addon";
import {
initialize as initializeMsw,
mswLoader,
MswParameters,
} from "msw-storybook-addon";

import { TooltipProvider } from "../src/components/AppComponents/Chat/ui/tooltip";
import { DialogProvider } from "../src/components/AppComponents/DialogContext";
Expand All @@ -19,6 +23,12 @@ import { chromaticParams } from "./chromatic";
import { RadixThemeDecorator } from "./decorators/RadixThemeDecorator";
import "./preview.css";

declare module "@storybook/csf" {
interface Parameters {
msw?: MswParameters["msw"];
}
}

initializeMsw();

const preview: Preview = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { chromaticParams } from "@/storybook/chromatic";
import { DemoProvider } from "../../../../../src/components/ContextProviders/Demo";
import { DownloadContent } from "./DownloadView";

const meta: Meta<typeof DownloadContent> = {
const meta = {
title: "Pages/Chat/Download",
component: DownloadContent,
parameters: {
Expand All @@ -20,10 +20,10 @@ const meta: Meta<typeof DownloadContent> = {
</DemoProvider>
),
],
};
} satisfies Meta<typeof DownloadContent>;

export default meta;
type Story = StoryObj<typeof DownloadContent>;
type Story = StoryObj<typeof meta>;

const chat: AilaPersistedChat = {
id: "nSLmbQ1LO75zLTcA",
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/aila/[id]/share/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { chromaticParams } from "@/storybook/chromatic";

import ShareChat from "./";

const meta: Meta<typeof ShareChat> = {
const meta = {
title: "Pages/Chat/Share",
component: ShareChat,
parameters: {
layout: "fullscreen",
...chromaticParams(["mobile", "desktop"]),
},
};
} satisfies Meta<typeof ShareChat>;

export default meta;
type Story = StoryObj<typeof ShareChat>;
type Story = StoryObj<typeof meta>;

const lessonPlan: LooseLessonPlan = {
title: "The End of Roman Britain",
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/aila/help/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { chromaticParams } from "@/storybook/chromatic";

import { HelpContent } from ".";

const meta: Meta<typeof HelpContent> = {
const meta = {
title: "Pages/Chat/Help",
component: HelpContent,
parameters: {
Expand All @@ -20,10 +20,10 @@ const meta: Meta<typeof HelpContent> = {
</DemoProvider>
),
],
};
} satisfies Meta<typeof HelpContent>;

export default meta;
type Story = StoryObj<typeof HelpContent>;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {},
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/faqs/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { chromaticParams } from "@/storybook/chromatic";

import { FAQPageContent } from ".";

const meta: Meta<typeof FAQPageContent> = {
const meta = {
title: "Pages/FAQs",
component: FAQPageContent,
parameters: {
...chromaticParams(["mobile", "desktop"]),
},
};
} satisfies Meta<typeof FAQPageContent>;

export default meta;
type Story = StoryObj<typeof FAQPageContent>;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {},
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/home-page.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { chromaticParams } from "@/storybook/chromatic";

import { HomePageContent } from "./home-page";

const meta: Meta<typeof HomePageContent> = {
const meta = {
title: "Pages/Homepage",
component: HomePageContent,
parameters: {
...chromaticParams(["mobile", "desktop"]),
},
};
} satisfies Meta<typeof HomePageContent>;

export default meta;
type Story = StoryObj<typeof HomePageContent>;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/legal/[slug]/legal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { chromaticParams } from "@/storybook/chromatic";

import { LegalContent } from "./legal";

const meta: Meta<typeof LegalContent> = {
const meta = {
title: "Pages/Legal/Sanity dynamic",
component: LegalContent,
parameters: {
...chromaticParams(["mobile", "desktop"]),
},
};
} satisfies Meta<typeof LegalContent>;

export default meta;
type Story = StoryObj<typeof LegalContent>;
type Story = StoryObj<typeof meta>;

const fixture = {
pageData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { chromaticParams } from "@/storybook/chromatic";

import { AccountLocked } from "./account-locked";

const meta: Meta<typeof AccountLocked> = {
const meta = {
title: "Pages/Legal/Account Locked",
component: AccountLocked,
parameters: {
...chromaticParams(["mobile", "desktop"]),
},
};
} satisfies Meta<typeof AccountLocked>;

export default meta;
type Story = StoryObj<typeof AccountLocked>;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {},
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/prompts/prompts.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { chromaticParams } from "@/storybook/chromatic";

import { PromptsContent } from "./prompts";

const meta: Meta<typeof PromptsContent> = {
const meta = {
title: "Pages/Prompts",
component: PromptsContent,
parameters: {
...chromaticParams(["mobile", "desktop"]),
},
};
} satisfies Meta<typeof PromptsContent>;

export default meta;
type Story = StoryObj<typeof PromptsContent>;
type Story = StoryObj<typeof meta>;

const fixture = {
apps: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Meta, StoryObj } from "@storybook/react";

import { ChatModerationDisplay } from "./ChatModerationDisplay";

const meta: Meta<typeof ChatModerationDisplay> = {
const meta = {
title: "Components/Dialogs/ChatModerationDisplay",
component: ChatModerationDisplay,
tags: ["autodocs"],
Expand All @@ -14,10 +14,10 @@ const meta: Meta<typeof ChatModerationDisplay> = {
</div>
),
],
};
} satisfies Meta<typeof ChatModerationDisplay>;

export default meta;
type Story = StoryObj<typeof ChatModerationDisplay>;
type Story = StoryObj<typeof meta>;

const toxicModeration: PersistedModerationBase = {
id: "mock-moderation-id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Meta, StoryObj } from "@storybook/react";

import { ChatHistory } from "./chat-history";

const meta: Meta<typeof ChatHistory> = {
const meta = {
title: "Components/Sidebar/ChatHistory",
component: ChatHistory,
parameters: {
Expand All @@ -17,10 +17,10 @@ const meta: Meta<typeof ChatHistory> = {
</Dialog.Root>
),
],
};
} satisfies Meta<typeof ChatHistory>;

export default meta;
type Story = StoryObj<typeof ChatHistory>;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ const chatContext: Partial<ChatContextProps> = {
ailaStreamingStatus: "Idle",
};

const meta: Meta<typeof LessonPlanDisplay> = {
const meta = {
title: "Components/LessonPlan/LessonPlanDisplay",
component: LessonPlanDisplay,
tags: ["autodocs"],
decorators: [ChatDecorator],
args: {
documentContainerRef: { current: null },
chatEndRef: undefined,
sectionRefs: {},
showLessonMobile: false,
},
};
} satisfies Meta<typeof LessonPlanDisplay>;

export default meta;

type Story = StoryObj<typeof LessonPlanDisplay>;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";

import { ChatDecorator } from "@/storybook/decorators/ChatDecorator";

import ChatLhsHeader from "./chat-lhs-header";

const meta: Meta<typeof ChatLhsHeader> = {
const meta = {
title: "Components/Chat/ChatLhsHeader",
component: ChatLhsHeader,
tags: ["autodocs"],
decorators: [ChatDecorator],
args: {
showStreamingStatus: false,
setShowLessonMobile: fn(),
showLessonMobile: false,
isDemoUser: false,
},
parameters: {
chatContext: {
ailaStreamingStatus: "Idle",
},
},
};
} satisfies Meta<typeof ChatLhsHeader>;

export default meta;
type Story = StoryObj<typeof ChatLhsHeader>;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {},
};
export const Default: Story = {};

export const NonProdStreamingStatus: Story = {
args: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ChatModerationProvider } from "@/components/ContextProviders/ChatModera

import { DemoLimitMessage } from "./demo-limit-message";

const meta: Meta<typeof DemoLimitMessage> = {
const meta = {
title: "Components/Chat/DemoLimitMessage",
component: DemoLimitMessage,
tags: ["autodocs"],
Expand All @@ -15,10 +15,13 @@ const meta: Meta<typeof DemoLimitMessage> = {
</ChatModerationProvider>
),
],
};
args: {
id: "test-chat-id",
},
} satisfies Meta<typeof DemoLimitMessage>;

export default meta;
type Story = StoryObj<typeof DemoLimitMessage>;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {

import { InChatDownloadButtons } from "./in-chat-download-buttons";

const meta: Meta<typeof InChatDownloadButtons> = {
const meta = {
title: "Components/Chat/InChatDownloadButtons",
component: InChatDownloadButtons,
tags: ["autodocs"],
Expand All @@ -18,10 +18,10 @@ const meta: Meta<typeof InChatDownloadButtons> = {
parameters: {
...demoParams({ isDemoUser: true }),
},
};
} satisfies Meta<typeof InChatDownloadButtons>;

export default meta;
type Story = StoryObj<typeof InChatDownloadButtons>;
type Story = StoryObj<typeof meta>;

export const Default: Story = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import type { Meta, StoryObj } from "@storybook/react";

import { ChatMessagePart } from "./ChatMessagePart";

const meta: Meta<typeof ChatMessagePart> = {
const meta = {
title: "Components/Chat/ChatMessagePart",
component: ChatMessagePart,
tags: ["autodocs"],
args: {
inspect: false,
},
};
} satisfies Meta<typeof ChatMessagePart>;

export default meta;
type Story = StoryObj<typeof ChatMessagePart>;
type Story = StoryObj<typeof meta>;

const basePart: Omit<MessagePart, "document"> = {
type: "message-part",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { aiLogger } from "@oakai/logger";

import { MemoizedReactMarkdownWithStyles } from "@/components/AppComponents/Chat/markdown";

import type { ModerationModalHelpers } from "../../FeedbackForms/ModerationFeedbackModal";

const log = aiLogger("chat");

const components = {
Expand All @@ -34,7 +32,6 @@ const components = {
export interface ChatMessagePartProps {
part: MessagePart;
inspect: boolean;
moderationModalHelpers: ModerationModalHelpers;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These helpers aren't used in the function

}

export function ChatMessagePart({
Expand Down
Loading
Loading