Skip to content

Commit

Permalink
test: use tighter satisfies typing in storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
codeincontext committed Dec 17, 2024
1 parent 99110d7 commit 6fdb9e7
Show file tree
Hide file tree
Showing 37 changed files with 136 additions and 118 deletions.
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;
}

export function ChatMessagePart({
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 { ChatMessage } from "./";

const meta: Meta<typeof ChatMessage> = {
const meta = {
title: "Components/Chat/ChatMessage",
component: ChatMessage,
tags: ["autodocs"],
Expand All @@ -16,12 +16,14 @@ const meta: Meta<typeof ChatMessage> = {
),
],
args: {
chatId: "test-chat-id",
persistedModerations: [],
ailaStreamingStatus: "Idle",
},
};
} satisfies Meta<typeof ChatMessage>;

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

export const UserMessage: Story = {
args: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ export function ChatMessage({
messageParts.map((part) => {
return (
<div className="w-full" key={part.id}>
<ChatMessagePart
part={part}
moderationModalHelpers={moderationModalHelpers}
inspect={inspect}
/>
<ChatMessagePart part={part} inspect={inspect} />
</div>
);
})}
Expand Down
Loading

0 comments on commit 6fdb9e7

Please sign in to comment.