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; color: #bdbdbd;
outline: none; outline: none;
transition: border 0.24s ease-in-out; 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 { &-dropzone:focus {

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,8 @@ import {
isEffectiveApi, isEffectiveApi,
isApiOutdated, isApiOutdated,
createObject, createObject,
autobind autobind,
TestIdBuilder
} from 'amis-core'; } from 'amis-core';
import {TransferDropDown, Spinner, Select, SpinnerExtraProps} from 'amis-ui'; import {TransferDropDown, Spinner, Select, SpinnerExtraProps} from 'amis-ui';
import {FormOptionsSchema, SchemaApi} from '../../Schema'; import {FormOptionsSchema, SchemaApi} from '../../Schema';
@ -155,6 +156,8 @@ export interface SelectControlSchema
*/ */
filterOption?: 'string'; filterOption?: 'string';
}; };
testIdBuilder?: TestIdBuilder;
} }
export interface SelectProps extends OptionsControlProps, SpinnerExtraProps { export interface SelectProps extends OptionsControlProps, SpinnerExtraProps {
@ -409,12 +412,13 @@ export default class SelectControl extends React.Component<SelectProps, any> {
@autobind @autobind
renderMenu(option: Option, state: any) { 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, { return render(`menu/${state.index}`, menuTpl, {
showNativeTitle: true, showNativeTitle: true,
className: cx('Select-option-content', optionClassName), 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, isVisible,
qsstringify, qsstringify,
createObject, createObject,
extendObject extendObject,
TestIdBuilder
} from 'amis-core'; } from 'amis-core';
import { import {
BaseSchema, BaseSchema,
@ -151,6 +152,7 @@ export interface ServiceProps
Omit<ServiceSchema, 'type' | 'className'> { Omit<ServiceSchema, 'type' | 'className'> {
store: IServiceStore; store: IServiceStore;
messages: SchemaMessage; messages: SchemaMessage;
testIdBuilder?: TestIdBuilder;
} }
export default class Service extends React.Component<ServiceProps> { export default class Service extends React.Component<ServiceProps> {
timer: ReturnType<typeof setTimeout>; timer: ReturnType<typeof setTimeout>;
@ -797,11 +799,16 @@ export default class Service extends React.Component<ServiceProps> {
classPrefix: ns, classPrefix: ns,
classnames: cx, classnames: cx,
loadingConfig, loadingConfig,
showErrorMsg showErrorMsg,
testIdBuilder
} = this.props; } = this.props;
return ( return (
<div className={cx(`${ns}Service`, className)} style={style}> <div
className={cx(`${ns}Service`, className)}
style={style}
{...testIdBuilder?.getTestId()}
>
{!env.forceSilenceInsideError && {!env.forceSilenceInsideError &&
store.error && store.error &&
showErrorMsg !== false ? ( showErrorMsg !== false ? (

View File

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