Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: button with formnovalidate #152

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/react-components/ory/helpers/node.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,71 @@ test("uiTextToFormattedMessage on a list", async ({ mount }) => {
await expect(component).toContainText("te45pbc0")
await expect(component).toContainText("q3vvtd4i")
})

test("button with id 1070007 should have formnovalidate", async ({ mount }) => {
const component = await mount(
<Node
node={{
type: "input",
group: "default",
attributes: {
id: "111111",
name: "resend",
value: "code",
type: "submit",
node_type: "input",
required: true,
disabled: false,
},
messages: [],
meta: {
label: {
id: 1070007,
text: "",
type: "info",
},
},
}}
/>,
)

// formnovalidate is inline and won't work with the .toHaveAttribute matcher
await expect(component.locator("[formnovalidate]")).toBeAttached()
// text is injected from the translation file
await expect(component).toHaveText("Email")
})

test("button with label id 1070008 should have formnovalidate", async ({
mount,
}) => {
const component = await mount(
<Node
node={{
type: "input",
group: "default",
attributes: {
id: "111111",
name: "resend",
value: "code",
type: "submit",
node_type: "input",
required: true,
disabled: false,
},
messages: [],
meta: {
label: {
id: 1070008,
text: "",
type: "info",
},
},
}}
/>,
)

// formnovalidate is inline and won't work with the .toHaveAttribute matcher
await expect(component.locator("[formnovalidate]")).toBeAttached()
// text is injected from the translation file
await expect(component).toHaveText("Resend code")
})
2 changes: 1 addition & 1 deletion src/react-components/ory/helpers/node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export const Node = ({

// the recovery code resend button
if (
node.meta.label?.id === 1070007 ?? // TODO: remove this once everyone has migrated to the fix (https://github.com/ory/kratos/pull/3067)
node.meta.label?.id === 1070007 || // TODO: remove this once everyone has migrated to the fix (https://github.com/ory/kratos/pull/3067)
node.meta.label?.id === 1070008
) {
// on html forms the required flag on an input field will prevent the form from submitting.
Expand Down
Loading