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-update-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-update-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 when there is an error in the password input (e.g., invalid password).
|
|
|
|
* - Scenario: Simulates the case where the user enters an invalid password, and an error message is displayed.
|
|
|
|
* - Key Aspect: Ensures the password input field shows an error message when validation fails.
|
|
|
|
*/
|
|
|
|
export const WithPasswordError: Story = {
|
|
|
|
render: () => (
|
|
|
|
<KcPageStory
|
|
|
|
kcContext={{
|
|
|
|
url: {
|
|
|
|
loginAction: "/mock-login-action"
|
|
|
|
},
|
|
|
|
messagesPerField: {
|
|
|
|
existsError: (field: string) => field === "password",
|
|
|
|
get: () => "Password must be at least 8 characters long."
|
|
|
|
},
|
|
|
|
isAppInitiatedAction: false
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WithPasswordConfirmError:
|
|
|
|
* - Purpose: Tests when there is an error in the password confirmation input (e.g., passwords do not match).
|
|
|
|
* - Scenario: Simulates the case where the user enters mismatching passwords, and an error message is displayed in the confirmation field.
|
|
|
|
* - Key Aspect: Ensures that the password confirmation field shows an error when passwords do not match.
|
|
|
|
*/
|
|
|
|
export const WithPasswordConfirmError: Story = {
|
|
|
|
render: () => (
|
|
|
|
<KcPageStory
|
|
|
|
kcContext={{
|
|
|
|
url: {
|
|
|
|
loginAction: "/mock-login-action"
|
|
|
|
},
|
|
|
|
messagesPerField: {
|
|
|
|
existsError: (field: string) => field === "password-confirm",
|
|
|
|
get: () => "Passwords do not match."
|
|
|
|
},
|
|
|
|
isAppInitiatedAction: false
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|
2025-04-07 08:42:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* WithAppInitiatedAction:
|
|
|
|
* - Purpose: Tests when the update password action was triggered by an app.
|
|
|
|
* - Scenario: Simulates the case where the user presses a 'change password' button in an app and is redirected to Keycloak to change it.
|
|
|
|
* - Key Aspect: Ensures the 'Cancel' button is shown correctly, which displays only when the action is app initiated.
|
|
|
|
*/
|
|
|
|
export const WithAppInitiatedAction: Story = {
|
|
|
|
render: () => (
|
|
|
|
<KcPageStory
|
|
|
|
kcContext={{
|
|
|
|
url: {
|
|
|
|
loginAction: "/mock-login-action"
|
|
|
|
},
|
|
|
|
isAppInitiatedAction: true
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
};
|