From 7c7698c00b943332b656be611861baf75ac59de0 Mon Sep 17 00:00:00 2001 From: Jonas Hungershausen Date: Fri, 11 Oct 2024 16:34:06 +0200 Subject: [PATCH] chore: update text --- ...snap => constructCardHeader.spec.tsx.snap} | 160 +++++++++--------- ...r.spec.ts => constructCardHeader.spec.tsx} | 29 +++- .../default/utils/constructCardHeader.ts | 2 - 3 files changed, 101 insertions(+), 90 deletions(-) rename packages/elements-react/src/theme/default/utils/__tests__/__snapshots__/{constructCardHeader.spec.ts.snap => constructCardHeader.spec.tsx.snap} (88%) rename packages/elements-react/src/theme/default/utils/__tests__/{constructCardHeader.spec.ts => constructCardHeader.spec.tsx} (85%) diff --git a/packages/elements-react/src/theme/default/utils/__tests__/__snapshots__/constructCardHeader.spec.ts.snap b/packages/elements-react/src/theme/default/utils/__tests__/__snapshots__/constructCardHeader.spec.tsx.snap similarity index 88% rename from packages/elements-react/src/theme/default/utils/__tests__/__snapshots__/constructCardHeader.spec.ts.snap rename to packages/elements-react/src/theme/default/utils/__tests__/__snapshots__/constructCardHeader.spec.tsx.snap index 726a1b826..984f29995 100644 --- a/packages/elements-react/src/theme/default/utils/__tests__/__snapshots__/constructCardHeader.spec.ts.snap +++ b/packages/elements-react/src/theme/default/utils/__tests__/__snapshots__/constructCardHeader.spec.tsx.snap @@ -2,42 +2,42 @@ exports[`flowType=login refresh=false combination=code constructCardHeaderText 1`] = ` { - "description": "Sign in with a code sent to your email.", + "description": "Sign in with a code sent to your email", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=default_and_code constructCardHeaderText 1`] = ` { - "description": "Sign in with a code sent to your email.", + "description": "Sign in with a code sent to your email", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=default_and_oidc constructCardHeaderText 1`] = ` { - "description": "Sign in with a social provider.", + "description": "Sign in with a social provider", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=default_and_passkeys constructCardHeaderText 1`] = ` { - "description": "Sign in with a Passkey.", + "description": "Sign in with a Passkey", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=default_and_password constructCardHeaderText 1`] = ` { - "description": "Sign in with your email and password.", + "description": "Sign in with your email and password", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=default_and_webauthn constructCardHeaderText 1`] = ` { - "description": "Sign in with a security key.", + "description": "Sign in with a security key", "title": "Sign in", } `; @@ -51,91 +51,91 @@ exports[`flowType=login refresh=false combination=defaultGroup constructCardHead exports[`flowType=login refresh=false combination=idenfier_first_and_oidc constructCardHeaderText 1`] = ` { - "description": "Sign in with a social provider or your undefined.", + "description": "Sign in with a social provider or your Email", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=identifierFirst constructCardHeaderText 1`] = ` { - "description": "Sign in with your undefined.", + "description": "Sign in with your Email", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=identifierFirstPhone constructCardHeaderText 1`] = ` { - "description": "Sign in with your undefined.", + "description": "Sign in with your Phone number", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=oidc constructCardHeaderText 1`] = ` { - "description": "Sign in with a social provider.", + "description": "Sign in with a social provider", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=passkey constructCardHeaderText 1`] = ` { - "description": "Sign in with a Passkey.", + "description": "Sign in with a Passkey", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=password constructCardHeaderText 1`] = ` { - "description": "Sign in with your email and password.", + "description": "Sign in with your email and password", "title": "Sign in", } `; exports[`flowType=login refresh=false combination=webauthn constructCardHeaderText 1`] = ` { - "description": "Sign in with a security key.", + "description": "Sign in with a security key", "title": "Sign in", } `; exports[`flowType=login refresh=true combination=code constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with a code sent to your email.", + "description": "Confirm your identity with a code sent to your email", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=default_and_code constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with a code sent to your email.", + "description": "Confirm your identity with a code sent to your email", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=default_and_oidc constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with a social provider.", + "description": "Confirm your identity with a social provider", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=default_and_passkeys constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with a Passkey.", + "description": "Confirm your identity with a Passkey", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=default_and_password constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with your email and password.", + "description": "Confirm your identity with your email and password", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=default_and_webauthn constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with a security key.", + "description": "Confirm your identity with a security key", "title": "Reauthenticate", } `; @@ -149,49 +149,49 @@ exports[`flowType=login refresh=true combination=defaultGroup constructCardHeade exports[`flowType=login refresh=true combination=idenfier_first_and_oidc constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with a social provider or your undefined.", + "description": "Confirm your identity with a social provider or your Email", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=identifierFirst constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with your undefined.", + "description": "Confirm your identity with your Email", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=identifierFirstPhone constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with your undefined.", + "description": "Confirm your identity with your Phone number", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=oidc constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with a social provider.", + "description": "Confirm your identity with a social provider", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=passkey constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with a Passkey.", + "description": "Confirm your identity with a Passkey", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=password constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with your email and password.", + "description": "Confirm your identity with your email and password", "title": "Reauthenticate", } `; exports[`flowType=login refresh=true combination=webauthn constructCardHeaderText 1`] = ` { - "description": "Confirm your identity with a security key.", + "description": "Confirm your identity with a security key", "title": "Reauthenticate", } `; @@ -394,197 +394,197 @@ exports[`flowType=recovery refresh=true combination=webauthn constructCardHeader exports[`flowType=registration refresh=false combination=code constructCardHeaderText 1`] = ` { - "description": "Sign up with a code sent to your email.", - "title": "Sign up", + "description": "Sign up with a code sent to your email", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=default_and_code constructCardHeaderText 1`] = ` { - "description": "Sign up with a code sent to your email.", - "title": "Sign up", + "description": "Sign up with a code sent to your email", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=default_and_oidc constructCardHeaderText 1`] = ` { - "description": "Sign up with a social provider.", - "title": "Sign up", + "description": "Sign up with a social provider", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=default_and_passkeys constructCardHeaderText 1`] = ` { - "description": "Sign up with a Passkey.", - "title": "Sign up", + "description": "Sign up with a Passkey", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=default_and_password constructCardHeaderText 1`] = ` { - "description": "Sign up with your email and a password.", - "title": "Sign up", + "description": "Sign up with your email and a password", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=default_and_webauthn constructCardHeaderText 1`] = ` { - "description": "Sign up with a security key.", - "title": "Sign up", + "description": "Sign up with a security key", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=defaultGroup constructCardHeaderText 1`] = ` { "description": "", - "title": "Sign up", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=idenfier_first_and_oidc constructCardHeaderText 1`] = ` { - "description": "Sign up with a social provider or your undefined.", - "title": "Sign up", + "description": "Sign up with a social provider or your Email", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=identifierFirst constructCardHeaderText 1`] = ` { - "description": "Sign up with your undefined.", - "title": "Sign up", + "description": "Sign up with your Email", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=identifierFirstPhone constructCardHeaderText 1`] = ` { - "description": "Sign up with your undefined.", - "title": "Sign up", + "description": "Sign up with your Phone number", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=oidc constructCardHeaderText 1`] = ` { - "description": "Sign up with a social provider.", - "title": "Sign up", + "description": "Sign up with a social provider", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=passkey constructCardHeaderText 1`] = ` { - "description": "Sign up with a Passkey.", - "title": "Sign up", + "description": "Sign up with a Passkey", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=password constructCardHeaderText 1`] = ` { - "description": "Sign up with your email and a password.", - "title": "Sign up", + "description": "Sign up with your email and a password", + "title": "Register an account", } `; exports[`flowType=registration refresh=false combination=webauthn constructCardHeaderText 1`] = ` { - "description": "Sign up with a security key.", - "title": "Sign up", + "description": "Sign up with a security key", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=code constructCardHeaderText 1`] = ` { - "description": "Sign up with a code sent to your email.", - "title": "Sign up", + "description": "Sign up with a code sent to your email", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=default_and_code constructCardHeaderText 1`] = ` { - "description": "Sign up with a code sent to your email.", - "title": "Sign up", + "description": "Sign up with a code sent to your email", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=default_and_oidc constructCardHeaderText 1`] = ` { - "description": "Sign up with a social provider.", - "title": "Sign up", + "description": "Sign up with a social provider", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=default_and_passkeys constructCardHeaderText 1`] = ` { - "description": "Sign up with a Passkey.", - "title": "Sign up", + "description": "Sign up with a Passkey", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=default_and_password constructCardHeaderText 1`] = ` { - "description": "Sign up with your email and a password.", - "title": "Sign up", + "description": "Sign up with your email and a password", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=default_and_webauthn constructCardHeaderText 1`] = ` { - "description": "Sign up with a security key.", - "title": "Sign up", + "description": "Sign up with a security key", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=defaultGroup constructCardHeaderText 1`] = ` { "description": "", - "title": "Sign up", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=idenfier_first_and_oidc constructCardHeaderText 1`] = ` { - "description": "Sign up with a social provider or your undefined.", - "title": "Sign up", + "description": "Sign up with a social provider or your Email", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=identifierFirst constructCardHeaderText 1`] = ` { - "description": "Sign up with your undefined.", - "title": "Sign up", + "description": "Sign up with your Email", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=identifierFirstPhone constructCardHeaderText 1`] = ` { - "description": "Sign up with your undefined.", - "title": "Sign up", + "description": "Sign up with your Phone number", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=oidc constructCardHeaderText 1`] = ` { - "description": "Sign up with a social provider.", - "title": "Sign up", + "description": "Sign up with a social provider", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=passkey constructCardHeaderText 1`] = ` { - "description": "Sign up with a Passkey.", - "title": "Sign up", + "description": "Sign up with a Passkey", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=password constructCardHeaderText 1`] = ` { - "description": "Sign up with your email and a password.", - "title": "Sign up", + "description": "Sign up with your email and a password", + "title": "Register an account", } `; exports[`flowType=registration refresh=true combination=webauthn constructCardHeaderText 1`] = ` { - "description": "Sign up with a security key.", - "title": "Sign up", + "description": "Sign up with a security key", + "title": "Register an account", } `; diff --git a/packages/elements-react/src/theme/default/utils/__tests__/constructCardHeader.spec.ts b/packages/elements-react/src/theme/default/utils/__tests__/constructCardHeader.spec.tsx similarity index 85% rename from packages/elements-react/src/theme/default/utils/__tests__/constructCardHeader.spec.ts rename to packages/elements-react/src/theme/default/utils/__tests__/constructCardHeader.spec.tsx index d0ce619b5..1e8127d00 100644 --- a/packages/elements-react/src/theme/default/utils/__tests__/constructCardHeader.spec.ts +++ b/packages/elements-react/src/theme/default/utils/__tests__/constructCardHeader.spec.tsx @@ -3,6 +3,9 @@ import { FlowType, UiNode, UiTextTypeEnum } from "@ory/client-fetch" import { useCardHeaderText } from "../constructCardHeader" +import { renderHook } from "@testing-library/react" +import { PropsWithChildren } from "react" +import { IntlProvider } from "../../../../context" const password: UiNode = { group: "password", @@ -108,14 +111,15 @@ const identifierFirst: UiNode = { type: "text", value: "", disabled: false, + }, + messages: [], + meta: { label: { text: "Email", type: UiTextTypeEnum.Info, id: 9999, }, }, - messages: [], - meta: {}, } const identifierFirstPhone: UiNode = { @@ -127,14 +131,15 @@ const identifierFirstPhone: UiNode = { type: "text", value: "", disabled: false, + }, + messages: [], + meta: { label: { text: "Phone number", type: UiTextTypeEnum.Info, id: 9999, }, }, - messages: [], - meta: {}, } const combinations = { @@ -154,6 +159,10 @@ const combinations = { idenfier_first_and_oidc: [identifierFirst, oidc], } +const wrapper = ({ children }: PropsWithChildren) => ( + {children} +) + for (const flowType of [ FlowType.Login, FlowType.Registration, @@ -172,11 +181,15 @@ for (const flowType of [ for (const [key, value] of Object.entries(combinations)) { describe("combination=" + key, () => { test("constructCardHeaderText", () => { - const res = useCardHeaderText( - Array.isArray(value) ? value : [value], - opts, + const res = renderHook( + () => + useCardHeaderText( + Array.isArray(value) ? value : [value], + opts, + ), + { wrapper }, ) - expect(res).toMatchSnapshot() + expect(res.result.current).toMatchSnapshot() }) }) } diff --git a/packages/elements-react/src/theme/default/utils/constructCardHeader.ts b/packages/elements-react/src/theme/default/utils/constructCardHeader.ts index 5a79985a7..94059f367 100644 --- a/packages/elements-react/src/theme/default/utils/constructCardHeader.ts +++ b/packages/elements-react/src/theme/default/utils/constructCardHeader.ts @@ -148,8 +148,6 @@ export function useCardHeaderText( } } - // Melden Sie sich mit Ihrer E-Mail und Passwort, einem social provider oder einem Code per E-Mail an - switch (opts.flowType) { case FlowType.Login: if (opts.flow.refresh) {