keycloak_theme/stories/login/pages/LoginConfigTotp.stories.tsx
Nima Shkouhfar c9d7fc1b6e Changes:
- First draft of test coverage improvement for storybooks
- code's page html rendering issue fixed
2024-09-29 04:35:02 -04:00

65 lines
1.6 KiB
TypeScript

import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { createKcPageStory } from "../KcPageStory";
const { KcPageStory } = createKcPageStory({ pageId: "login-config-totp.ftl" });
const meta = {
title: "login/login-config-totp.ftl",
component: KcPageStory
} satisfies Meta<typeof KcPageStory>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
render: () => <KcPageStory />
};
export const WithManualSetUp: Story = {
render: () => (
<KcPageStory
kcContext={{
mode: "manual"
}}
/>
)
};
export const WithError: Story = {
render: () => (
<KcPageStory
kcContext={{
messagesPerField: {
get: (fieldName: string) => (fieldName === "totp" ? "Invalid TOTP" : undefined),
exists: (fieldName: string) => fieldName === "totp",
existsError: (fieldName: string) => fieldName === "totp",
printIfExists: <T,>(fieldName: string, x: T) => (fieldName === "totp" ? x : undefined)
}
}}
/>
)
};
export const WithAppInitiatedAction: Story = {
render: () => (
<KcPageStory
kcContext={{
isAppInitiatedAction: true
}}
/>
)
};
export const WithPreFilledUserLabel: Story = {
render: () => (
<KcPageStory
kcContext={{
totp: {
otpCredentials: [{ userLabel: "MyDevice" }]
}
}}
/>
)
};