Skip to content

Commit

Permalink
chore: cleanup auth code section logic and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Benehiko committed Sep 15, 2023
1 parent 7c32444 commit dd1bbcc
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
74 changes: 74 additions & 0 deletions src/react-components/ory/sections/auth-code-section.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,77 @@ test("shouldn't render anything with no code group", async ({ mount }) => {

await expect(container.locator("input[name=identifier]")).not.toBeVisible()
})

test("should render traits on default group", async ({ mount }) => {
const container = await mount(
<AuthCodeSection
nodes={[
{
group: "default",
attributes: {
name: "traits.email",
node_type: "input",
type: "text",
required: true,
disabled: false,
},
messages: [],
type: "input",
meta: {
label: {
id: 1070002,
text: "E-Mail",
type: "info",
context: {
title: "E-Mail",
},
},
},
},
{
group: "default",
attributes: {
name: "traits.name",
node_type: "input",
type: "text",
required: true,
disabled: false,
},
messages: [],
type: "input",
meta: {
label: {
id: 1070001,
text: "Name",
type: "info",
},
},
},
{
group: "code",
attributes: {
name: "method",
node_type: "input",
type: "submit",
required: true,
disabled: false,
value: "code",
},
messages: [],
type: "input",
meta: {
label: {
id: 1040006,
text: "Sign up with code",
type: "info",
},
},
},
]}
/>,
)

await expect(container.locator("input[name='traits.email']")).toBeVisible()
await expect(container.locator("input[name='traits.name']")).toBeVisible()
await expect(container.locator("button[name=method]")).toBeVisible()
})
7 changes: 4 additions & 3 deletions src/react-components/ory/sections/auth-code-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const AuthCodeSection = ({
filter={{
nodes: nodes,
groups: "code",
excludeAttributes: ["submit", "hidden"],
withoutDefaultAttributes: true,
excludeAttributes: ["hidden", "button", "submit"], // the form will take care of hidden fields
}}
/>
</div>
Expand All @@ -28,8 +29,8 @@ export const AuthCodeSection = ({
filter={{
nodes: nodes,
groups: "code",
withoutDefaultGroup: true,
attributes: ["submit", "hidden"],
withoutDefaultAttributes: true,
attributes: ["button", "submit"],
}}
/>
</div>
Expand Down

0 comments on commit dd1bbcc

Please sign in to comment.