mirror of
https://github.com/fluxscape/fluxscape.git
synced 2026-01-12 15:22:54 +01:00
feat(runtime): Add "data-testid" attributes to UI nodes (#42)
This commit is contained in:
@@ -8,6 +8,8 @@ export interface ButtonProps extends Noodl.ReactProps {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
buttonType: 'button' | 'submit';
|
buttonType: 'button' | 'submit';
|
||||||
|
|
||||||
|
attrs: React.Attributes;
|
||||||
|
|
||||||
textStyle: Noodl.TextStyle;
|
textStyle: Noodl.TextStyle;
|
||||||
|
|
||||||
useLabel: boolean;
|
useLabel: boolean;
|
||||||
@@ -96,6 +98,7 @@ export function Button(props: ButtonProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
{...props.attrs}
|
||||||
className={className}
|
className={className}
|
||||||
disabled={!props.enabled}
|
disabled={!props.enabled}
|
||||||
{...Utils.controlEvents(props)}
|
{...Utils.controlEvents(props)}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ export interface CheckboxProps extends Noodl.ReactProps {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
|
|
||||||
|
attrs: React.Attributes;
|
||||||
|
|
||||||
useLabel: boolean;
|
useLabel: boolean;
|
||||||
label: string;
|
label: string;
|
||||||
labelSpacing: string;
|
labelSpacing: string;
|
||||||
@@ -47,6 +49,7 @@ export function Checkbox(props: CheckboxProps) {
|
|||||||
Layout.align(style, props);
|
Layout.align(style, props);
|
||||||
|
|
||||||
const inputProps = {
|
const inputProps = {
|
||||||
|
...props.attrs,
|
||||||
id: props.id,
|
id: props.id,
|
||||||
className: [props.className, 'ndl-controls-checkbox-2'].join(' '),
|
className: [props.className, 'ndl-controls-checkbox-2'].join(' '),
|
||||||
disabled: !props.enabled,
|
disabled: !props.enabled,
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ export interface RadioButtonProps extends Noodl.ReactProps {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
value: string;
|
value: string;
|
||||||
|
|
||||||
|
attrs: React.Attributes;
|
||||||
|
|
||||||
useLabel: boolean;
|
useLabel: boolean;
|
||||||
label: string;
|
label: string;
|
||||||
labelSpacing: string;
|
labelSpacing: string;
|
||||||
@@ -47,6 +49,7 @@ export function RadioButton(props: RadioButtonProps) {
|
|||||||
props.checkedChanged && props.checkedChanged(radioButtonGroup ? radioButtonGroup.selected === props.value : false);
|
props.checkedChanged && props.checkedChanged(radioButtonGroup ? radioButtonGroup.selected === props.value : false);
|
||||||
|
|
||||||
const inputProps = {
|
const inputProps = {
|
||||||
|
...props.attrs,
|
||||||
id: props.id,
|
id: props.id,
|
||||||
disabled: !props.enabled,
|
disabled: !props.enabled,
|
||||||
className: [props.className, 'ndl-controls-radio-2'].join(' '),
|
className: [props.className, 'ndl-controls-radio-2'].join(' '),
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ export interface SelectProps extends Noodl.ReactProps {
|
|||||||
textStyle: Noodl.TextStyle;
|
textStyle: Noodl.TextStyle;
|
||||||
items: TSFixme;
|
items: TSFixme;
|
||||||
|
|
||||||
|
attrs: React.Attributes;
|
||||||
|
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
placeholderOpacity: string;
|
placeholderOpacity: string;
|
||||||
|
|
||||||
@@ -81,6 +83,7 @@ export function Select(props: SelectProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const inputProps = {
|
const inputProps = {
|
||||||
|
...props.attrs,
|
||||||
id: props.id,
|
id: props.id,
|
||||||
className: props.className,
|
className: props.className,
|
||||||
style: {
|
style: {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ export interface SliderProps extends Noodl.ReactProps {
|
|||||||
id: string;
|
id: string;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
|
|
||||||
|
attrs: React.Attributes;
|
||||||
|
|
||||||
value: number;
|
value: number;
|
||||||
min: number;
|
min: number;
|
||||||
max: number;
|
max: number;
|
||||||
@@ -103,6 +105,7 @@ export function Slider(props: SliderProps) {
|
|||||||
const className = `ndl-controls-range2 ${instanceClassId} ${props.className ? props.className : ''} `;
|
const className = `ndl-controls-range2 ${instanceClassId} ${props.className ? props.className : ''} `;
|
||||||
|
|
||||||
const inputProps: React.InputHTMLAttributes<HTMLInputElement> = {
|
const inputProps: React.InputHTMLAttributes<HTMLInputElement> = {
|
||||||
|
...props.attrs,
|
||||||
id: props.id,
|
id: props.id,
|
||||||
style: {
|
style: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ export interface TextInputProps extends Noodl.ReactProps {
|
|||||||
type: 'text' | 'textArea' | 'email' | 'number' | 'password' | 'url';
|
type: 'text' | 'textArea' | 'email' | 'number' | 'password' | 'url';
|
||||||
textStyle: Noodl.TextStyle;
|
textStyle: Noodl.TextStyle;
|
||||||
|
|
||||||
|
attrs: React.Attributes;
|
||||||
|
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
|
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
@@ -149,6 +151,7 @@ export class TextInput extends React.Component<TextInputProps, State> {
|
|||||||
inputStyles.color = props.noodlNode.context.styles.resolveColor(inputStyles.color);
|
inputStyles.color = props.noodlNode.context.styles.resolveColor(inputStyles.color);
|
||||||
|
|
||||||
const inputProps = {
|
const inputProps = {
|
||||||
|
...props.attrs,
|
||||||
id: props.id,
|
id: props.id,
|
||||||
value: this.state.value,
|
value: this.state.value,
|
||||||
...Utils.controlEvents(props),
|
...Utils.controlEvents(props),
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ BScroll.use(Slide);
|
|||||||
export interface GroupProps extends Noodl.ReactProps {
|
export interface GroupProps extends Noodl.ReactProps {
|
||||||
as?: keyof JSX.IntrinsicElements | React.ComponentType<unknown>;
|
as?: keyof JSX.IntrinsicElements | React.ComponentType<unknown>;
|
||||||
|
|
||||||
|
attrs: React.Attributes;
|
||||||
|
|
||||||
scrollSnapEnabled: boolean;
|
scrollSnapEnabled: boolean;
|
||||||
showScrollbar: boolean;
|
showScrollbar: boolean;
|
||||||
scrollEnabled: boolean;
|
scrollEnabled: boolean;
|
||||||
@@ -271,6 +273,7 @@ export class Group extends React.Component<GroupProps> {
|
|||||||
<Component
|
<Component
|
||||||
// @ts-expect-error Lets hope that the type passed here is always static!
|
// @ts-expect-error Lets hope that the type passed here is always static!
|
||||||
className={props.className}
|
className={props.className}
|
||||||
|
{...props.attrs}
|
||||||
{...props.dom}
|
{...props.dom}
|
||||||
{...PointerListeners(props)}
|
{...PointerListeners(props)}
|
||||||
style={style}
|
style={style}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export interface ImageProps extends Noodl.ReactProps {
|
|||||||
src: string;
|
src: string;
|
||||||
onLoad?: () => void;
|
onLoad?: () => void;
|
||||||
};
|
};
|
||||||
|
attrs: React.Attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Image(props: ImageProps) {
|
export function Image(props: ImageProps) {
|
||||||
@@ -30,5 +31,5 @@ export function Image(props: ImageProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return <img className={props.className} {...props.dom} {...PointerListeners(props)} style={style} />;
|
return <img {...props.attrs} className={props.className} {...props.dom} {...PointerListeners(props)} style={style} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { Noodl } from '../../../types';
|
|||||||
export interface TextProps extends Noodl.ReactProps {
|
export interface TextProps extends Noodl.ReactProps {
|
||||||
as?: keyof JSX.IntrinsicElements | React.ComponentType<unknown>;
|
as?: keyof JSX.IntrinsicElements | React.ComponentType<unknown>;
|
||||||
|
|
||||||
|
attrs: React.Attributes;
|
||||||
|
|
||||||
textStyle: Noodl.TextStyle;
|
textStyle: Noodl.TextStyle;
|
||||||
text: string;
|
text: string;
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ export function Text(props: TextProps) {
|
|||||||
return (
|
return (
|
||||||
<Component
|
<Component
|
||||||
className={['ndl-visual-text', props.className].join(' ')}
|
className={['ndl-visual-text', props.className].join(' ')}
|
||||||
|
{...props.attrs}
|
||||||
{...props.dom}
|
{...props.dom}
|
||||||
{...PointerListeners(props)}
|
{...PointerListeners(props)}
|
||||||
style={style}
|
style={style}
|
||||||
|
|||||||
@@ -30,11 +30,24 @@ const ButtonNode = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.props.attrs = {};
|
||||||
this.props.layout = 'row'; //Used to tell child nodes what layout to expect
|
this.props.layout = 'row'; //Used to tell child nodes what layout to expect
|
||||||
},
|
},
|
||||||
getReactComponent() {
|
getReactComponent() {
|
||||||
return Button;
|
return Button;
|
||||||
},
|
},
|
||||||
|
inputs: {
|
||||||
|
testId: {
|
||||||
|
index: 100009,
|
||||||
|
displayName: 'Test ID Attribute',
|
||||||
|
group: 'Advanced HTML',
|
||||||
|
type: 'string',
|
||||||
|
set(value) {
|
||||||
|
this.props.attrs["data-testid"] = value;
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
inputCss: {
|
inputCss: {
|
||||||
backgroundColor: {
|
backgroundColor: {
|
||||||
index: 100,
|
index: 100,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const CheckBoxNode = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.props.attrs = {};
|
||||||
this.props.sizeMode = 'explicit';
|
this.props.sizeMode = 'explicit';
|
||||||
this.props.id = 'input-' + guid();
|
this.props.id = 'input-' + guid();
|
||||||
this.props.checked = this._internal.checked = false;
|
this.props.checked = this._internal.checked = false;
|
||||||
@@ -94,6 +95,16 @@ const CheckBoxNode = {
|
|||||||
this.flagOutputDirty('checked');
|
this.flagOutputDirty('checked');
|
||||||
this._updateVisualState();
|
this._updateVisualState();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
testId: {
|
||||||
|
index: 100009,
|
||||||
|
displayName: 'Test ID Attribute',
|
||||||
|
group: 'Advanced HTML',
|
||||||
|
type: 'string',
|
||||||
|
set(value) {
|
||||||
|
this.props.attrs["data-testid"] = value;
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputCss: {
|
inputCss: {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const OptionsNode = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
this.props.attrs = {};
|
||||||
this._itemsChanged = () => {
|
this._itemsChanged = () => {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
};
|
};
|
||||||
@@ -90,6 +91,16 @@ const OptionsNode = {
|
|||||||
this.flagOutputDirty('value');
|
this.flagOutputDirty('value');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
testId: {
|
||||||
|
index: 100009,
|
||||||
|
displayName: 'Test ID Attribute',
|
||||||
|
group: 'Advanced HTML',
|
||||||
|
type: 'string',
|
||||||
|
set(value) {
|
||||||
|
this.props.attrs["data-testid"] = value;
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputProps: {
|
inputProps: {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const RadioButtonNode = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.props.attrs = {};
|
||||||
this.props.sizeMode = 'explicit';
|
this.props.sizeMode = 'explicit';
|
||||||
this.props.id = 'input-' + guid();
|
this.props.id = 'input-' + guid();
|
||||||
|
|
||||||
@@ -61,6 +62,16 @@ const RadioButtonNode = {
|
|||||||
set(value) {
|
set(value) {
|
||||||
this.setStyle({ backgroundColor: value }, 'fill');
|
this.setStyle({ backgroundColor: value }, 'fill');
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
testId: {
|
||||||
|
index: 100009,
|
||||||
|
displayName: 'Test ID Attribute',
|
||||||
|
group: 'Advanced HTML',
|
||||||
|
type: 'string',
|
||||||
|
set(value) {
|
||||||
|
this.props.attrs["data-testid"] = value;
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputProps: {
|
inputProps: {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ const RangeNode = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.props.attrs = {};
|
||||||
this.props.sizeMode = 'contentHeight';
|
this.props.sizeMode = 'contentHeight';
|
||||||
this.props.id = 'input-' + guid();
|
this.props.id = 'input-' + guid();
|
||||||
|
|
||||||
@@ -67,6 +68,16 @@ const RangeNode = {
|
|||||||
set(value) {
|
set(value) {
|
||||||
this._setInputValue(value);
|
this._setInputValue(value);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
testId: {
|
||||||
|
index: 100009,
|
||||||
|
displayName: 'Test ID Attribute',
|
||||||
|
group: 'Advanced HTML',
|
||||||
|
type: 'string',
|
||||||
|
set(value) {
|
||||||
|
this.props.attrs["data-testid"] = value;
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
outputs: {
|
outputs: {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ const TextInputNode = {
|
|||||||
return TextInput;
|
return TextInput;
|
||||||
},
|
},
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.props.attrs = {};
|
||||||
this.props.startValue = '';
|
this.props.startValue = '';
|
||||||
this.props.id = this._internal.controlId = 'input-' + guid();
|
this.props.id = this._internal.controlId = 'input-' + guid();
|
||||||
},
|
},
|
||||||
@@ -167,6 +168,16 @@ const TextInputNode = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
testId: {
|
||||||
|
index: 100009,
|
||||||
|
displayName: 'Test ID Attribute',
|
||||||
|
group: 'Advanced HTML',
|
||||||
|
type: 'string',
|
||||||
|
set(value) {
|
||||||
|
this.props.attrs["data-testid"] = value;
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputCss: {
|
inputCss: {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const GroupNode = {
|
|||||||
groupPriority: ['General', 'Style', 'Events', 'Mounted', 'Hover Events', 'Pointer Events', 'Focus', 'Scroll']
|
groupPriority: ['General', 'Style', 'Events', 'Mounted', 'Hover Events', 'Pointer Events', 'Focus', 'Scroll']
|
||||||
},
|
},
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.props.attrs = {};
|
||||||
this._internal = {
|
this._internal = {
|
||||||
scrollElementDuration: 500,
|
scrollElementDuration: 500,
|
||||||
scrollIndexDuration: 500,
|
scrollIndexDuration: 500,
|
||||||
@@ -143,6 +144,16 @@ const GroupNode = {
|
|||||||
valueChangedToTrue() {
|
valueChangedToTrue() {
|
||||||
this.context.setNodeFocused(this, true);
|
this.context.setNodeFocused(this, true);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
testId: {
|
||||||
|
index: 100009,
|
||||||
|
displayName: 'Test ID Attribute',
|
||||||
|
group: 'Advanced HTML',
|
||||||
|
type: 'string',
|
||||||
|
set(value) {
|
||||||
|
this.props.attrs["data-testid"] = value;
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputProps: {
|
inputProps: {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ const ImageNode = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.props.attrs = {};
|
||||||
this.props.default = '';
|
this.props.default = '';
|
||||||
},
|
},
|
||||||
getReactComponent() {
|
getReactComponent() {
|
||||||
@@ -86,6 +87,16 @@ const ImageNode = {
|
|||||||
this.props.dom.src = getAbsoluteUrl(url);
|
this.props.dom.src = getAbsoluteUrl(url);
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
testId: {
|
||||||
|
index: 100009,
|
||||||
|
displayName: 'Test ID Attribute',
|
||||||
|
group: 'Advanced HTML',
|
||||||
|
type: 'string',
|
||||||
|
set(value) {
|
||||||
|
this.props.attrs["data-testid"] = value;
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputProps: {
|
inputProps: {
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ const TextNode = {
|
|||||||
nodeDoubleClickAction: {
|
nodeDoubleClickAction: {
|
||||||
focusPort: 'text'
|
focusPort: 'text'
|
||||||
},
|
},
|
||||||
|
initialize() {
|
||||||
|
this.props.attrs = {};
|
||||||
|
},
|
||||||
getReactComponent() {
|
getReactComponent() {
|
||||||
return Text;
|
return Text;
|
||||||
},
|
},
|
||||||
@@ -135,6 +138,16 @@ const TextNode = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
testId: {
|
||||||
|
index: 100009,
|
||||||
|
displayName: 'Test ID Attribute',
|
||||||
|
group: 'Advanced HTML',
|
||||||
|
type: 'string',
|
||||||
|
set(value) {
|
||||||
|
this.props.attrs["data-testid"] = value;
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user