From f6cc4083f2b127583e76171a0474da8950e614e4 Mon Sep 17 00:00:00 2001
From: Adam Howard <91115+codeincontext@users.noreply.github.com>
Date: Wed, 11 Dec 2024 00:47:53 +0100
Subject: [PATCH] test: add DialogContentDecorator
---
.../decorators/DialogContentDecorator.tsx | 29 +++++++++++++++++++
apps/nextjs/.storybook/preview.tsx | 8 +----
.../DialogControl/DialogContents.stories.tsx | 18 ++----------
.../nextjs/src/mocks/clerk/ClerkDecorator.tsx | 6 ++++
4 files changed, 38 insertions(+), 23 deletions(-)
create mode 100644 apps/nextjs/.storybook/decorators/DialogContentDecorator.tsx
diff --git a/apps/nextjs/.storybook/decorators/DialogContentDecorator.tsx b/apps/nextjs/.storybook/decorators/DialogContentDecorator.tsx
new file mode 100644
index 000000000..b6c0c2a26
--- /dev/null
+++ b/apps/nextjs/.storybook/decorators/DialogContentDecorator.tsx
@@ -0,0 +1,29 @@
+import React from "react";
+
+import type { Decorator } from "@storybook/react";
+
+import type { DialogTypes } from "../../src/components/AppComponents/Chat/Chat/types";
+import { DialogContext } from "../../src/components/AppComponents/DialogContext";
+
+declare module "@storybook/csf" {
+ interface Parameters {
+ dialogWindow?: DialogTypes;
+ }
+}
+
+export const DialogContentDecorator: Decorator = (Story, { parameters }) => {
+ return (
+ {},
+ dialogProps: {},
+ setDialogProps: () => {},
+ openSidebar: false,
+ setOpenSidebar: () => {},
+ }}
+ >
+
+
+ );
+};
diff --git a/apps/nextjs/.storybook/preview.tsx b/apps/nextjs/.storybook/preview.tsx
index 55f606d81..59f9ee53d 100644
--- a/apps/nextjs/.storybook/preview.tsx
+++ b/apps/nextjs/.storybook/preview.tsx
@@ -54,13 +54,7 @@ const preview: Preview = {
loaders: [mswLoader],
};
-// Providers not currently used
-// - CookieConsentProvider
-// - DemoProvider
-// - LessonPlanTrackingProvider
-// - DialogProvider
-// - SidebarProvider
-// - ChatModerationProvider
+// NOTE: See ./decorators for more decorators available to use in stories
export const decorators: Decorator[] = [
RadixThemeDecorator,
diff --git a/apps/nextjs/src/components/DialogControl/DialogContents.stories.tsx b/apps/nextjs/src/components/DialogControl/DialogContents.stories.tsx
index 77e245f78..778ccb23e 100644
--- a/apps/nextjs/src/components/DialogControl/DialogContents.stories.tsx
+++ b/apps/nextjs/src/components/DialogControl/DialogContents.stories.tsx
@@ -4,28 +4,14 @@ import { http, HttpResponse } from "msw";
import type { AnalyticsContext } from "@/components/ContextProviders/AnalyticsProvider";
import { analyticsContext } from "@/components/ContextProviders/AnalyticsProvider";
-import { DialogContext } from "../AppComponents/DialogContext";
import { DemoProvider } from "../ContextProviders/Demo";
import DialogContents from "./DialogContents";
+import { DialogContentDecorator } from "@/storybook/decorators/DialogContentDecorator";
const meta: Meta = {
title: "Components/Dialogs/DialogContents",
component: DialogContents,
- decorators: (Story, { parameters }) => {
- return (
- {},
- dialogProps: {},
- setDialogProps: () => {},
- openSidebar: false,
- setOpenSidebar: () => {},
- }}
- >
-
-
- );
+ decorators: [DialogContentDecorator]
},
};
diff --git a/apps/nextjs/src/mocks/clerk/ClerkDecorator.tsx b/apps/nextjs/src/mocks/clerk/ClerkDecorator.tsx
index 328cec32f..4bb3a7b85 100644
--- a/apps/nextjs/src/mocks/clerk/ClerkDecorator.tsx
+++ b/apps/nextjs/src/mocks/clerk/ClerkDecorator.tsx
@@ -2,6 +2,12 @@ import type { Decorator } from "@storybook/react";
import { ClerkProvider } from "./nextjsComponents";
+declare module "@storybook/csf" {
+ interface Parameters {
+ auth?: "loading" | "signedIn" | "signedInDemo" | "signedOut";
+ }
+}
+
export const ClerkDecorator: Decorator = (Story, { parameters }) => {
return (