Files
keycloak_theme/stories/login/pages/WebauthnRegister.stories.tsx

63 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-06-03 01:23:28 +02:00
import React from "react";
import type { Meta, StoryObj } from "@storybook/react";
2024-06-09 11:53:25 +02:00
import { createKcPageStory } from "../KcPageStory";
2024-06-03 01:23:28 +02:00
2024-06-09 11:53:25 +02:00
const { KcPageStory } = createKcPageStory({ pageId: "webauthn-register.ftl" });
2024-06-03 01:23:28 +02:00
const meta = {
2024-06-06 07:28:34 +02:00
title: "login/webauthn-register.ftl",
2024-06-09 11:53:25 +02:00
component: KcPageStory
} satisfies Meta<typeof KcPageStory>;
2024-06-03 01:23:28 +02:00
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
2024-06-09 11:53:25 +02:00
render: () => <KcPageStory />
2024-06-03 01:23:28 +02:00
};
2024-10-19 17:24:29 -04:00
/**
* WithRetryAvailable:
* - Purpose: Tests when the user is allowed to retry WebAuthn registration after a failure.
* - Scenario: The component renders the form with a retry option.
* - Key Aspect: Ensures the retry functionality is available and the form allows the user to retry.
*/
export const WithRetryAvailable: Story = {
render: () => (
<KcPageStory
kcContext={{
url: {
loginAction: "/mock-login-action"
},
isSetRetry: true,
isAppInitiatedAction: false
}}
/>
)
};
/**
* WithErrorDuringRegistration:
* - Purpose: Tests when an error occurs during WebAuthn registration.
* - Scenario: The component displays an error message related to WebAuthn registration failure.
* - Key Aspect: Ensures the error message is displayed correctly, informing the user of the registration failure.
*/
export const WithErrorDuringRegistration: Story = {
render: () => (
<KcPageStory
kcContext={{
url: {
loginAction: "/mock-login-action"
},
isSetRetry: false,
isAppInitiatedAction: false,
message: {
summary: "An error occurred during WebAuthn registration. Please try again.",
type: "error"
}
}}
/>
)
};