keycloak_theme/stories/login/pages/WebauthnError.stories.tsx

88 lines
2.8 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-error.ftl" });
2024-06-03 01:23:28 +02:00
const meta = {
2024-06-06 07:28:34 +02:00
title: "login/webauthn-error.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 can retry the WebAuthn authentication after an error.
* - Scenario: The component renders with a "Try Again" button to allow retrying the authentication process.
* - Key Aspect: Ensures the retry button functionality is visible and the user can retry authentication.
*/
export const WithRetryAvailable: Story = {
render: () => (
<KcPageStory
kcContext={{
url: {
loginAction: "/mock-login-action"
},
isAppInitiatedAction: false,
message: {
summary: "WebAuthn authentication failed. Please try again.",
type: "error"
}
}}
/>
)
};
/**
* WithAppInitiatedAction:
* - Purpose: Tests when the WebAuthn error form is part of an application-initiated action.
* - Scenario: The component renders with both a "Try Again" button and a "Cancel" button for app-initiated actions.
* - Key Aspect: Ensures the form renders correctly with both "Try Again" and "Cancel" options.
*/
export const WithAppInitiatedAction: Story = {
render: () => (
<KcPageStory
kcContext={{
url: {
loginAction: "/mock-login-action"
},
isAppInitiatedAction: true,
message: {
summary: "WebAuthn authentication failed. You can try again or cancel.",
type: "error"
}
}}
/>
)
};
/**
* WithJavaScriptDisabled:
* - Purpose: Tests the behavior when JavaScript is disabled or not functioning.
* - Scenario: The component renders with a message prompting the user to retry manually without JavaScript.
* - Key Aspect: Ensures the retry mechanism works properly when JavaScript is disabled or unavailable.
*/
export const WithJavaScriptDisabled: Story = {
render: () => (
<KcPageStory
kcContext={{
url: {
loginAction: "/mock-login-action"
},
isAppInitiatedAction: false,
message: {
summary: "JavaScript is disabled or not working. Please retry manually.",
type: "warning"
}
}}
/>
)
};