|
| 1 | +import type { Meta, StoryObj } from "@storybook/react" |
| 2 | +import { SecurityPageView } from "./SecurityPage" |
| 3 | +import { action } from "@storybook/addon-actions" |
| 4 | +import { MockAuthMethods } from "testHelpers/entities" |
| 5 | +import { ComponentProps } from "react" |
| 6 | +import set from "lodash/fp/set" |
| 7 | +import { AuthMethods } from "api/typesGenerated" |
| 8 | + |
| 9 | +const defaultArgs: ComponentProps<typeof SecurityPageView> = { |
| 10 | + security: { |
| 11 | + form: { |
| 12 | + disabled: false, |
| 13 | + error: undefined, |
| 14 | + isLoading: false, |
| 15 | + onSubmit: action("onSubmit"), |
| 16 | + }, |
| 17 | + }, |
| 18 | + oidc: { |
| 19 | + section: { |
| 20 | + authMethods: MockAuthMethods, |
| 21 | + closeConfirmation: action("closeConfirmation"), |
| 22 | + confirm: action("confirm"), |
| 23 | + error: undefined, |
| 24 | + isConfirming: false, |
| 25 | + isUpdating: false, |
| 26 | + openConfirmation: action("openConfirmation"), |
| 27 | + }, |
| 28 | + }, |
| 29 | +} |
| 30 | + |
| 31 | +const meta: Meta<typeof SecurityPageView> = { |
| 32 | + title: "pages/SecurityPageView", |
| 33 | + component: SecurityPageView, |
| 34 | + args: defaultArgs, |
| 35 | +} |
| 36 | + |
| 37 | +export default meta |
| 38 | +type Story = StoryObj<typeof SecurityPageView> |
| 39 | + |
| 40 | +export const Default: Story = {} |
| 41 | + |
| 42 | +export const NoOIDCAvailable: Story = { |
| 43 | + args: { |
| 44 | + ...defaultArgs, |
| 45 | + oidc: undefined, |
| 46 | + }, |
| 47 | +} |
| 48 | + |
| 49 | +const authMethodsWithPassword: AuthMethods = { |
| 50 | + ...MockAuthMethods, |
| 51 | + me_login_type: "password", |
| 52 | + github: { enabled: true }, |
| 53 | + oidc: { enabled: true, signInText: "", iconUrl: "" }, |
| 54 | +} |
| 55 | + |
| 56 | +export const UserLoginTypeIsPassword: Story = { |
| 57 | + args: set("oidc.section.authMethods", authMethodsWithPassword, defaultArgs), |
| 58 | +} |
| 59 | + |
| 60 | +export const ConfirmingOIDCConversion: Story = { |
| 61 | + args: set( |
| 62 | + "oidc.section", |
| 63 | + { |
| 64 | + ...defaultArgs.oidc?.section, |
| 65 | + authMethods: authMethodsWithPassword, |
| 66 | + isConfirming: true, |
| 67 | + }, |
| 68 | + defaultArgs, |
| 69 | + ), |
| 70 | +} |
0 commit comments