2023-04-20 05:41:34 +02:00
|
|
|
import React from "react";
|
2024-06-03 00:11:19 +02:00
|
|
|
import type { Meta, StoryObj } from "@storybook/react";
|
2024-06-09 11:53:25 +02:00
|
|
|
import { createKcPageStory } from "../KcPageStory";
|
2023-04-20 05:41:34 +02:00
|
|
|
|
2024-06-09 11:53:25 +02:00
|
|
|
const { KcPageStory } = createKcPageStory({ pageId: "login-password.ftl" });
|
2023-04-20 05:41:34 +02:00
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
const meta = {
|
2024-06-06 07:28:34 +02:00
|
|
|
title: "login/login-password.ftl",
|
2024-06-09 11:53:25 +02:00
|
|
|
component: KcPageStory
|
|
|
|
} satisfies Meta<typeof KcPageStory>;
|
2023-04-20 05:41:34 +02:00
|
|
|
|
|
|
|
export default meta;
|
|
|
|
|
2024-06-03 00:11:19 +02:00
|
|
|
type Story = StoryObj<typeof meta>;
|
|
|
|
|
|
|
|
export const Default: Story = {
|
2024-06-09 11:53:25 +02:00
|
|
|
render: () => <KcPageStory />
|
2024-06-03 00:11:19 +02:00
|
|
|
};
|
2024-10-19 17:24:29 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* WithPasswordError:
|
|
|
|
* - Purpose: Tests the behavior when an error occurs in the password field (e.g., incorrect password).
|
|
|
|
* - Scenario: Simulates a scenario where an invalid password is entered, and an error message is displayed.
|
|
|
|
* - Key Aspect: Ensures that the password input field displays error messages correctly.
|
|
|
|
*/
|
|
|
|
export const WithPasswordError: Story = {
|
|
|
|
render: () => (
|
|
|
|
<KcPageStory
|
|
|
|
kcContext={{
|
|
|
|
realm: {
|
|
|
|
resetPasswordAllowed: true
|
|
|
|
},
|
|
|
|
url: {
|
|
|
|
loginAction: "/mock-login",
|
|
|
|
loginResetCredentialsUrl: "/mock-reset-password"
|
|
|
|
},
|
|
|
|
messagesPerField: {
|
|
|
|
existsError: (field: string) => field === "password",
|
|
|
|
get: () => "Invalid password"
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WithoutResetPasswordOption:
|
|
|
|
* - Purpose: Tests the behavior when the reset password option is disabled.
|
|
|
|
* - Scenario: Simulates a scenario where the `resetPasswordAllowed` is set to `false`, and the "Forgot Password" link is not rendered.
|
|
|
|
* - Key Aspect: Ensures that the component handles cases where resetting the password is not allowed.
|
|
|
|
*/
|
|
|
|
export const WithoutResetPasswordOption: Story = {
|
|
|
|
render: () => (
|
|
|
|
<KcPageStory
|
|
|
|
kcContext={{
|
|
|
|
realm: {
|
|
|
|
resetPasswordAllowed: false
|
|
|
|
},
|
|
|
|
url: {
|
|
|
|
loginAction: "/mock-login",
|
|
|
|
loginResetCredentialsUrl: "/mock-reset-password"
|
|
|
|
},
|
|
|
|
messagesPerField: {
|
|
|
|
existsError: () => false
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|