Skip to content

Commit

Permalink
test: add chat-quick-bottons stories
Browse files Browse the repository at this point in the history
  • Loading branch information
codeincontext committed Dec 2, 2024
1 parent 054c8ee commit 7fb03cf
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import type { Meta, StoryObj } from "@storybook/react";

import {
ChatContext,
type ChatContextProps,
} from "@/components/ContextProviders/ChatProvider";
import { lessonPlanTrackingContext } from "@/lib/analytics/lessonPlanTrackingContext";

import ChatQuickButtons from "./chat-quick-buttons";

const DummyMessage = {};

const ChatDecorator: Story["decorators"] = (Story, { parameters }) => (
<ChatContext.Provider
value={
{
messages: [DummyMessage],
...parameters.chatContext,
} as unknown as ChatContextProps
}
>
<Story />
</ChatContext.Provider>
);

const LessonPlanTrackingContextDecorator: Story["decorators"] = (Story) => (
<lessonPlanTrackingContext.Provider
value={{
onClickContinue: () => {},
onClickRetry: () => {},
onClickStartFromExample: () => {},
onClickStartFromFreeText: () => {},
onStreamFinished: () => {},
onSubmitText: () => {},
}}
>
<Story />
</lessonPlanTrackingContext.Provider>
);

const meta: Meta<typeof ChatQuickButtons> = {
title: "Components/Chat/ChatQuickButtons",
component: ChatQuickButtons,
tags: ["autodocs"],
decorators: [ChatDecorator, LessonPlanTrackingContextDecorator],
};

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

export const Idle: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "Idle",
},
},
};

export const Loading: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "Loading",
},
},
};

export const LoadingWithoutMessages: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "Loading",
messages: [],
},
},
};

export const RequestMade: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "RequestMade",
},
},
};

export const StreamingLessonPlan: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "StreamingLessonPlan",
},
},
};

export const StreamingChatResponse: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "StreamingChatResponse",
},
},
};

export const Moderating: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "Moderating",
},
},
};

export const StreamingWithQueuedUserAction: Story = {
args: {},
parameters: {
chatContext: {
queuedUserAction: "regenerate",
ailaStreamingStatus: "StreamingLessonPlan",
},
},
};

export const ModeratingWithQueuedUserAction: Story = {
args: {},
parameters: {
chatContext: {
queuedUserAction: "regenerate",
ailaStreamingStatus: "Moderating",
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type LessonPlanTrackingContext = {
onClickStartFromFreeText: (text: string) => void;
};

const lessonPlanTrackingContext =
export const lessonPlanTrackingContext =
createContext<LessonPlanTrackingContext | null>(null);

export type LessonPlanTrackingProviderProps = Readonly<{
Expand Down

0 comments on commit 7fb03cf

Please sign in to comment.