feat: 增加input-number inputExcel service tpl 的部分testid (#9526)

This commit is contained in:
Allen 2024-01-25 17:51:54 +08:00 committed by GitHub
parent 0d3563d994
commit da01d47b0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 68 additions and 16 deletions

View File

@ -30,6 +30,16 @@
color: #bdbdbd;
outline: none;
transition: border 0.24s ease-in-out;
position: relative;
> input {
display: block !important;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
opacity: 0;
}
}
&-dropzone:focus {

View File

@ -10,7 +10,14 @@ import getMiniDecimal, {
} from '@rc-component/mini-decimal';
import {Icon} from './icons';
import {ThemeProps, themeable, isNumeric, autobind, ucFirst} from 'amis-core';
import {
ThemeProps,
themeable,
isNumeric,
autobind,
ucFirst,
TestIdBuilder
} from 'amis-core';
export type ValueType = string | number;
@ -74,6 +81,8 @@ export interface NumberProps extends ThemeProps {
*
*/
inputControlClassName?: string;
testIdBuilder?: TestIdBuilder;
}
export interface NumberState {
@ -317,7 +326,8 @@ export class NumberInput extends React.Component<NumberProps, NumberState> {
inputRef,
keyboard,
inputControlClassName,
mobileUI
mobileUI,
testIdBuilder
} = this.props;
const precisionProps: any = {
precision: NumberInput.normalizePrecision(precision, step)
@ -356,6 +366,7 @@ export class NumberInput extends React.Component<NumberProps, NumberState> {
stringMode={this.isBig ? true : false}
keyboard={keyboard}
{...precisionProps}
{...testIdBuilder?.getTestId()}
/>
);
}

View File

@ -1139,6 +1139,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
<span
className={cx('Select-option-content')}
title={typeof label === 'string' ? label : ''}
{...optTestIdBudr?.getChild('content').getTestId()}
>
{item.disabled
? label

View File

@ -10,7 +10,8 @@ import {
autobind,
isObject,
resolveEventData,
dataMapping
dataMapping,
TestIdBuilder
} from 'amis-core';
import {FormBaseControlSchema, SchemaTokenizeableString} from '../../Schema';
import type {CellValue, CellRichTextValue} from 'exceljs';
@ -64,6 +65,8 @@ export interface InputExcelControlSchema extends FormBaseControlSchema {
autoFill?: {
[propName: string]: SchemaTokenizeableString;
};
testIdBuilder?: TestIdBuilder;
}
export interface ExcelProps
@ -401,7 +404,8 @@ export default class ExcelControl extends React.PureComponent<
classPrefix: ns,
disabled,
translate: __,
placeholder
placeholder,
testIdBuilder
} = this.props;
return (
@ -415,8 +419,14 @@ export default class ExcelControl extends React.PureComponent<
>
{({getRootProps, getInputProps}) => (
<section className={cx('ExcelControl-container', className)}>
<div {...getRootProps({className: cx('ExcelControl-dropzone')})}>
<input {...getInputProps()} />
<div
{...getRootProps({className: cx('ExcelControl-dropzone')})}
{...testIdBuilder?.getTestId()}
>
<input
{...getInputProps()}
{...testIdBuilder?.getChild('input').getTestId()}
/>
{this.state.filename ? (
__('Excel.parsed', {
filename: this.state.filename

View File

@ -7,7 +7,8 @@ import {
resolveEventData,
CustomStyle,
formatInputThemeCss,
setThemeClassName
setThemeClassName,
TestIdBuilder
} from 'amis-core';
import cx from 'classnames';
import {NumberInput, Select} from 'amis-ui';
@ -158,6 +159,8 @@ export interface NumberProps extends FormControlProps {
*
*/
clearValueOnEmpty?: boolean;
testIdBuilder?: TestIdBuilder;
}
interface NumberState {
@ -445,7 +448,8 @@ export default class NumberControl extends React.Component<
themeCss,
inputControlClassName,
id,
env
env,
testIdBuilder
} = this.props;
const {unit} = this.state;
const finalPrecision = this.filterNum(precision);
@ -523,6 +527,7 @@ export default class NumberControl extends React.Component<
displayMode={displayMode}
big={big}
clearValueOnEmpty={clearValueOnEmpty}
testIdBuilder={testIdBuilder}
/>
{Array.isArray(unitOptions) && unitOptions.length !== 0 ? (
unitOptions.length > 1 ? (

View File

@ -14,7 +14,8 @@ import {
isEffectiveApi,
isApiOutdated,
createObject,
autobind
autobind,
TestIdBuilder
} from 'amis-core';
import {TransferDropDown, Spinner, Select, SpinnerExtraProps} from 'amis-ui';
import {FormOptionsSchema, SchemaApi} from '../../Schema';
@ -155,6 +156,8 @@ export interface SelectControlSchema
*/
filterOption?: 'string';
};
testIdBuilder?: TestIdBuilder;
}
export interface SelectProps extends OptionsControlProps, SpinnerExtraProps {
@ -409,12 +412,13 @@ export default class SelectControl extends React.Component<SelectProps, any> {
@autobind
renderMenu(option: Option, state: any) {
const {menuTpl, render, data, optionClassName} = this.props;
const {menuTpl, render, data, optionClassName, testIdBuilder} = this.props;
return render(`menu/${state.index}`, menuTpl, {
showNativeTitle: true,
className: cx('Select-option-content', optionClassName),
data: createObject(createObject(data, state), option)
data: createObject(createObject(data, state), option),
testIdBuilder: testIdBuilder?.getChild('option-' + state.index)
});
}

View File

@ -21,7 +21,8 @@ import {
isVisible,
qsstringify,
createObject,
extendObject
extendObject,
TestIdBuilder
} from 'amis-core';
import {
BaseSchema,
@ -151,6 +152,7 @@ export interface ServiceProps
Omit<ServiceSchema, 'type' | 'className'> {
store: IServiceStore;
messages: SchemaMessage;
testIdBuilder?: TestIdBuilder;
}
export default class Service extends React.Component<ServiceProps> {
timer: ReturnType<typeof setTimeout>;
@ -797,11 +799,16 @@ export default class Service extends React.Component<ServiceProps> {
classPrefix: ns,
classnames: cx,
loadingConfig,
showErrorMsg
showErrorMsg,
testIdBuilder
} = this.props;
return (
<div className={cx(`${ns}Service`, className)} style={style}>
<div
className={cx(`${ns}Service`, className)}
style={style}
{...testIdBuilder?.getTestId()}
>
{!env.forceSilenceInsideError &&
store.error &&
showErrorMsg !== false ? (

View File

@ -7,7 +7,7 @@ import {
CustomStyle,
setThemeClassName
} from 'amis-core';
import {filter, asyncFilter} from 'amis-core';
import {filter, asyncFilter, TestIdBuilder} from 'amis-core';
import isEmpty from 'lodash/isEmpty';
import {anyChanged, getPropValue} from 'amis-core';
import {escapeHtml} from 'amis-core';
@ -52,6 +52,8 @@ export interface TplSchema extends BaseSchema {
*
*/
badge?: BadgeObject;
testidBuilder?: TestIdBuilder;
}
export interface TplProps extends RendererProps, TplSchema {
@ -200,7 +202,8 @@ export class Tpl extends React.Component<TplProps, TplState> {
id,
wrapperCustomStyle,
env,
themeCss
themeCss,
testIdBuilder
} = this.props;
const Component = wrapperComponent || (inline ? 'span' : 'div');
const {content} = this.state;
@ -236,6 +239,7 @@ export class Tpl extends React.Component<TplProps, TplState> {
onClick={this.handleClick}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
{...testIdBuilder?.getChild('tpl')?.getTestId()}
>
<span
className={cln ? cx(cln) : undefined}