Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add stories for onboarding #423

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {},
};
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
Loading