From 7fb03cfc530409c56b05ce00bcab30850b640558 Mon Sep 17 00:00:00 2001
From: Adam Howard <91115+codeincontext@users.noreply.github.com>
Date: Mon, 2 Dec 2024 15:26:17 +0100
Subject: [PATCH] test: add chat-quick-bottons stories
---
.../Chat/chat-quick-buttons.stories.tsx | 133 ++++++++++++++++++
.../analytics/lessonPlanTrackingContext.tsx | 2 +-
2 files changed, 134 insertions(+), 1 deletion(-)
create mode 100644 apps/nextjs/src/components/AppComponents/Chat/chat-quick-buttons.stories.tsx
diff --git a/apps/nextjs/src/components/AppComponents/Chat/chat-quick-buttons.stories.tsx b/apps/nextjs/src/components/AppComponents/Chat/chat-quick-buttons.stories.tsx
new file mode 100644
index 000000000..a3baefe15
--- /dev/null
+++ b/apps/nextjs/src/components/AppComponents/Chat/chat-quick-buttons.stories.tsx
@@ -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 }) => (
+
+
+
+);
+
+const LessonPlanTrackingContextDecorator: Story["decorators"] = (Story) => (
+ {},
+ onClickRetry: () => {},
+ onClickStartFromExample: () => {},
+ onClickStartFromFreeText: () => {},
+ onStreamFinished: () => {},
+ onSubmitText: () => {},
+ }}
+ >
+
+
+);
+
+const meta: Meta = {
+ title: "Components/Chat/ChatQuickButtons",
+ component: ChatQuickButtons,
+ tags: ["autodocs"],
+ decorators: [ChatDecorator, LessonPlanTrackingContextDecorator],
+};
+
+export default meta;
+type Story = StoryObj;
+
+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",
+ },
+ },
+};
diff --git a/apps/nextjs/src/lib/analytics/lessonPlanTrackingContext.tsx b/apps/nextjs/src/lib/analytics/lessonPlanTrackingContext.tsx
index 2f9e9a3af..d664640d4 100644
--- a/apps/nextjs/src/lib/analytics/lessonPlanTrackingContext.tsx
+++ b/apps/nextjs/src/lib/analytics/lessonPlanTrackingContext.tsx
@@ -30,7 +30,7 @@ type LessonPlanTrackingContext = {
onClickStartFromFreeText: (text: string) => void;
};
-const lessonPlanTrackingContext =
+export const lessonPlanTrackingContext =
createContext(null);
export type LessonPlanTrackingProviderProps = Readonly<{