feat: improve locators

This commit is contained in:
chenos 2023-10-18 09:36:29 +08:00
parent 3001f02c0c
commit df657baf71
11 changed files with 24 additions and 8 deletions

View File

@ -38,14 +38,14 @@ interface IconProps {
export const Icon = (props: IconProps) => {
const { type = '', component, ...restProps } = props;
if (component) {
return <AntdIcon component={component} {...restProps} />;
return <AntdIcon role="button" component={component} {...restProps} />;
}
if (type && icons.has(type.toLowerCase())) {
const IconComponent = icons.get(type.toLowerCase());
return <IconComponent {...restProps} />;
return <IconComponent role="button" {...restProps} />;
}
if (type && IconFont) {
return <IconFont type={type} />;
return <IconFont role="button" type={type} />;
}
return null;
};

View File

@ -30,6 +30,7 @@ export const BlockItem: React.FC<any> = (props) => {
return (
<SortableItem
data-testid={getTestId({ schema, blockName: props.name || name })}
role="button"
className={cls(
'nb-block-item',
className,

View File

@ -492,7 +492,12 @@ Menu.Item = observer(
label: (
<SchemaContext.Provider value={schema}>
<FieldContext.Provider value={field}>
<SortableItem className={designerCss} removeParentsIfNoChildren={false}>
<SortableItem
role="button"
aria-label={t(field.title)}
className={designerCss}
removeParentsIfNoChildren={false}
>
<Icon type={icon} />
<span
style={{

View File

@ -11,6 +11,7 @@ export const MenuItemInitializers = (props: any) => {
const { t } = useTranslation();
return (
<SchemaInitializer.Button
role="button"
insertPosition={'beforeEnd'}
icon={'PlusOutlined'}
insert={props.insert}

View File

@ -41,7 +41,7 @@ export const TableColumnDecorator = (props) => {
}
}, [uiSchema?.title]);
return (
<SortableItem className={designerCss}>
<SortableItem role="button" className={designerCss}>
<Designer fieldSchema={fieldSchema} uiSchema={uiSchema} collectionField={collectionField} />
{/* <RecursionField name={columnSchema.name} schema={columnSchema}/> */}
{field?.title || compile(uiSchema?.title)}

View File

@ -280,6 +280,7 @@ export const Table: any = observer(
return (
<th
{...props}
role="button"
className={cls(
props.className,
css`

View File

@ -38,6 +38,7 @@ export const Sortable = (props: any) => {
return React.createElement(
component || 'div',
{
role: 'none',
...others,
className: cx('nb-sortable-designer', props.className),
ref: setNodeRef,

View File

@ -88,7 +88,12 @@ export const GeneralSchemaDesigner = (props: any) => {
</Space>
</div>
)}
<div className={'general-schema-designer-icons'}>
<div
onClick={(e) => {
e.stopPropagation();
}}
className={'general-schema-designer-icons'}
>
<Space size={2} align={'center'}>
{draggable && (
<DragHandler>

View File

@ -133,7 +133,7 @@ export const useEditProfile = () => {
ctx?.setVisible(false);
},
label: (
<>
<div aria-label="edit-profile">
{t('Edit profile')}
<ActionContextProvider value={{ visible, setVisible }}>
<div onClick={(e) => e.stopPropagation()}>
@ -143,7 +143,7 @@ export const useEditProfile = () => {
/>
</div>
</ActionContextProvider>
</>
</div>
),
};
}, [visible]);

View File

@ -19,6 +19,7 @@ export const useLanguageSettings = () => {
},
label: (
<div
aria-label="language-settings"
style={{
display: 'flex',
alignItems: 'center',

View File

@ -14,6 +14,7 @@ export const useSwitchRole = () => {
eventKey: 'SwitchRole',
label: (
<div
aria-label="switch-role"
style={{
display: 'flex',
alignItems: 'center',