Skip to content

Commit

Permalink
test: add stories for onboarding (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
codeincontext authored Dec 3, 2024
1 parent 7539661 commit e36841e
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 3 deletions.
15 changes: 15 additions & 0 deletions apps/nextjs/src/components/Onboarding/AcceptTermsForm.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Meta, StoryObj } from "@storybook/react";

import { AcceptTermsForm } from "./AcceptTermsForm";

const meta: Meta<typeof AcceptTermsForm> = {
title: "Pages/Onboarding/AcceptTermsForm",
component: AcceptTermsForm,
};

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

export const Default: Story = {
args: {},
};
3 changes: 2 additions & 1 deletion apps/nextjs/src/components/Onboarding/AcceptTermsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import Link from "next/link";
import Button from "@/components/Button";
import CheckBox from "@/components/CheckBox";
import SignUpSignInLayout from "@/components/SignUpSignInLayout";
import TermsContent from "@/components/TermsContent";
import { trpc } from "@/utils/trpc";

import TermsContent from "./TermsContent";

export const AcceptTermsForm = () => {
const [dropDownOpen, setDropDownOpen] = useState(true);
const { isLoaded } = useUser();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Meta, StoryObj } from "@storybook/react";

import { LegacyUpgradeNotice } from "./LegacyUpgradeNotice";

const meta: Meta<typeof LegacyUpgradeNotice> = {
title: "Pages/Onboarding/LegacyUpgradeNotice",
component: LegacyUpgradeNotice,
};

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

export const Default: Story = {
args: {},
};
15 changes: 15 additions & 0 deletions apps/nextjs/src/components/Onboarding/TermsContent.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Meta, StoryObj } from "@storybook/react";

import TermsContent from "./TermsContent";

const meta: Meta<typeof TermsContent> = {
title: "Components/Onboarding/TermsContent",
component: TermsContent,
};

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

export const Default: Story = {
args: {},
};
File renamed without changes.
15 changes: 15 additions & 0 deletions apps/nextjs/src/components/SignUpSignInLayout.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Meta, StoryObj } from "@storybook/react";

import SignUpSignInLayout from "./SignUpSignInLayout";

const meta: Meta<typeof SignUpSignInLayout> = {
title: "Components/Layout/SignUpSignInLayout",
component: SignUpSignInLayout,
};

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

export const Default: Story = {
args: {},
};
1 change: 1 addition & 0 deletions apps/nextjs/src/mocks/clerk/nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export {
useAuth,
useUser,
useClerk,
useSession,
SignedIn,
SignedOut,
ClerkProvider,
Expand Down
27 changes: 25 additions & 2 deletions apps/nextjs/src/mocks/clerk/nextjsComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,35 @@ export const useAuth = () => {
};
};

export const SignedIn = ({ children }: { readonly children: React.ReactNode }) => {
export const useSession = () => {
const context = React.useContext(ClerkContext);
const mockSession = {};
const session = context.isLoaded
? context.isSignedIn
? mockSession
: null
: undefined;
return {
isLoaded: context.isLoaded,
isSignedIn: context.isSignedIn,
session,
};
};

export const SignedIn = ({
children,
}: {
readonly children: React.ReactNode;
}) => {
const context = React.useContext(ClerkContext);
return context.isSignedIn ? children : null;
};

export const SignedOut = ({ children }: { readonly children: React.ReactNode }) => {
export const SignedOut = ({
children,
}: {
readonly children: React.ReactNode;
}) => {
const context = React.useContext(ClerkContext);
return context.isSignedIn ? null : children;
};
Expand Down

0 comments on commit e36841e

Please sign in to comment.