Skip to content

Add data-testid attributes to wfo form components #2080

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

Merged
merged 7 commits into from
Jul 17, 2025
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
5 changes: 5 additions & 0 deletions .changeset/easy-planets-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@orchestrator-ui/orchestrator-ui-components': patch
---

Fixes for pydanticforms integration
2 changes: 1 addition & 1 deletion apps/wfo-ui
Submodule wfo-ui updated 1 files
+0 −2 pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const Footer = () => {

const PreviousButton = () => (
<EuiButton
data-testid="button-submit-form-previous"
id="button-submit-form-submit"
tabIndex={0}
fill
Expand All @@ -47,6 +48,7 @@ export const Footer = () => {

const CancelButton = () => (
<div
data-testid="button-submit-form-cancel"
onClick={handlePrevious}
css={{
cursor: 'pointer',
Expand Down Expand Up @@ -75,6 +77,7 @@ export const Footer = () => {
*/
return (
<EuiButton
data-testid="button-submit-form-submit"
id="button-submit-form-submit"
tabIndex={0}
fill
Expand All @@ -89,7 +92,7 @@ export const Footer = () => {
};

return (
<div>
<div data-testid="pydantic-form-footer">
<RenderFormErrors />
<EuiHorizontalRule />
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const Header = () => {

return pydanticFormSchema?.title &&
pydanticFormSchema.title !== 'unknown' ? (
<h3 css={headerStyling}>{pydanticFormSchema?.title}</h3>
<h3 data-testid="pydantic-form-header" css={headerStyling}>
{pydanticFormSchema?.title}
</h3>
) : undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const Row: RowRenderComponent = ({

return (
<EuiFormRow
data-testid="pydantic-form-row"
css={formRowStyle}
label={<Label />}
labelAppend={<EuiText size="m">{description}</EuiText>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import { Footer } from './Footer';
import { Header } from './Header';
import { Row } from './Row';
import {
Checkbox,
Divider,
Integer,
Label,
Radio,
Summary,
Text,
TextArea,
WfoArrayField,
WfoCheckbox,
WfoDivider,
WfoInteger,
WfoLabel,
WfoObjectField,
WfoRadio,
WfoSummary,
WfoText,
WfoTextArea,
} from './fields';

interface WfoPydanticFormProps {
Expand Down Expand Up @@ -146,7 +146,7 @@ export const WfoPydanticForm = ({
{
id: 'textarea',
ElementMatch: {
Element: TextArea,
Element: WfoTextArea,
isControlledElement: true,
},
matcher(field) {
Expand All @@ -159,7 +159,7 @@ export const WfoPydanticForm = ({
{
id: 'summary',
ElementMatch: {
Element: Summary,
Element: WfoSummary,
isControlledElement: false,
},
matcher(field) {
Expand All @@ -172,7 +172,7 @@ export const WfoPydanticForm = ({
{
id: 'label',
ElementMatch: {
Element: Label,
Element: WfoLabel,
isControlledElement: false,
},
matcher(field) {
Expand All @@ -185,7 +185,7 @@ export const WfoPydanticForm = ({
{
id: 'divider',
ElementMatch: {
Element: Divider,
Element: WfoDivider,
isControlledElement: false,
},
matcher(field) {
Expand All @@ -198,7 +198,7 @@ export const WfoPydanticForm = ({
{
id: 'checkbox',
ElementMatch: {
Element: Checkbox,
Element: WfoCheckbox,
isControlledElement: true,
},
matcher(field) {
Expand All @@ -208,7 +208,7 @@ export const WfoPydanticForm = ({
{
id: 'radio',
ElementMatch: {
Element: Radio,
Element: WfoRadio,
isControlledElement: true,
},
matcher(field) {
Expand All @@ -223,7 +223,7 @@ export const WfoPydanticForm = ({
{
id: 'integerfield',
ElementMatch: {
Element: Integer,
Element: WfoInteger,
isControlledElement: true,
},
matcher(field) {
Expand Down Expand Up @@ -259,7 +259,7 @@ export const WfoPydanticForm = ({
{
id: 'text',
ElementMatch: {
Element: Text,
Element: WfoText,
isControlledElement: true,
},
matcher(field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const WfoArrayField = ({
};

return (
<div css={container}>
<div data-testid={arrayName} css={container}>
{fields.map(renderField)}

{showPlus && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import type { PydanticFormControlledElement } from 'pydantic-forms';

import { EuiCheckbox } from '@elastic/eui';

export const Checkbox: PydanticFormControlledElement = ({
export const WfoCheckbox: PydanticFormControlledElement = ({
pydanticFormField,
onChange,
value,
disabled,
}) => {
return (
<EuiCheckbox
data-testid={pydanticFormField.id}
checked={value || false}
disabled={disabled}
id={pydanticFormField.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { EuiHorizontalRule } from '@elastic/eui';

import { useOrchestratorTheme } from '@/hooks';

export const Divider: PydanticFormElement = ({ pydanticFormField }) => {
export const WfoDivider: PydanticFormElement = ({ pydanticFormField }) => {
const { theme } = useOrchestratorTheme();
return (
<EuiHorizontalRule
data-testid={pydanticFormField.id}
style={{ marginTop: theme.base }}
id={pydanticFormField.id}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getFormFieldsBaseStyle = ({ theme }: WfoTheme) => {
};
};

export const Integer: PydanticFormControlledElement = ({
export const WfoInteger: PydanticFormControlledElement = ({
pydanticFormField,
onChange,
value,
Expand All @@ -34,6 +34,7 @@ export const Integer: PydanticFormControlledElement = ({

return (
<EuiFieldNumber
data-testid={pydanticFormField.id}
css={formFieldBaseStyle}
name={pydanticFormField.id}
onChange={(event) => onChange(parseInt(event.target.value))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { PydanticFormElement } from 'pydantic-forms';

import { useOrchestratorTheme } from '@/hooks';

export const Label: PydanticFormElement = ({ pydanticFormField }) => {
export const WfoLabel: PydanticFormElement = ({ pydanticFormField }) => {
const { theme } = useOrchestratorTheme();

return (
<div>
<div data-testid={pydanticFormField.id}>
<label
css={{
color: theme.colors.text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const WfoObjectField = ({
);

return (
<EuiFlexGroup css={wfoObjectFieldStyles}>
<EuiFlexGroup
data-testid={pydanticFormField.id}
css={wfoObjectFieldStyles}
>
<RenderFields pydanticFormComponents={components} />
</EuiFlexGroup>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { PydanticFormControlledElement } from 'pydantic-forms';

import { EuiRadioGroup } from '@elastic/eui';

export const Radio: PydanticFormControlledElement = ({
export const WfoRadio: PydanticFormControlledElement = ({
pydanticFormField,
onChange,
value,
Expand All @@ -17,6 +17,7 @@ export const Radio: PydanticFormControlledElement = ({

return (
<EuiRadioGroup
data-testid={pydanticFormField.id}
options={radioOptions}
idSelected={value}
onChange={(id) => onChange(id)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const getStyles = ({ theme }: WfoTheme) => {
};
};

export const Summary: PydanticFormElement = ({ pydanticFormField }) => {
export const WfoSummary: PydanticFormElement = ({ pydanticFormField }) => {
const { summaryFieldStyle } = useWithOrchestratorTheme(getStyles);
const { formRowStyle } = useWithOrchestratorTheme(getCommonFormFieldStyles);

Expand Down Expand Up @@ -103,7 +103,7 @@ export const Summary: PydanticFormElement = ({ pydanticFormField }) => {
);

return (
<EuiFlexItem css={[summaryFieldStyle, formRowStyle]}>
<EuiFlexItem data-testid={id} css={[summaryFieldStyle, formRowStyle]}>
<section>
<EuiFormRow
label={description}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import { EuiFieldText } from '@elastic/eui';
import { useWithOrchestratorTheme } from '@/hooks';
import { getFormFieldsBaseStyle } from '@/theme';

export const Text: PydanticFormControlledElement = ({
export const WfoText: PydanticFormControlledElement = ({
onChange,
value,
disabled,
pydanticFormField,
}) => {
const { formFieldBaseStyle } = useWithOrchestratorTheme(
getFormFieldsBaseStyle,
);

return (
<EuiFieldText
data-testid={pydanticFormField.id}
css={formFieldBaseStyle}
disabled={disabled}
onChange={(event) => onChange(event.target.value)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import type { PydanticFormControlledElement } from 'pydantic-forms';

import { EuiTextArea } from '@elastic/eui';

export const TextArea: PydanticFormControlledElement = ({
export const WfoTextArea: PydanticFormControlledElement = ({
pydanticFormField,
onChange,
value,
disabled,
}) => {
return (
<EuiTextArea
data-testid={pydanticFormField.id}
disabled={disabled}
name={pydanticFormField.id}
onChange={(event) => onChange(event.target.value)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export * from './TextArea';
export * from './Text';
export * from './Label';
export * from './Divider';
export * from './Checkbox';
export * from './Summary';
export * from './WfoTextArea';
export * from './WfoText';
export * from './WfoLabel';
export * from './WfoDivider';
export * from './WfoCheckbox';
export * from './WfoSummary';
export * from './WfoObjectField';
export * from './WfoArrayField';
export * from './Radio';
export * from './Integer';
export * from './WfoRadio';
export * from './WfoInteger';