mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:39:05 +08:00
feat: testid 支持通过环境变量控制是否开启
This commit is contained in:
parent
28ee659a2c
commit
0c8cfa58f8
@ -246,6 +246,8 @@ export default function (schema, schemaProps, showCode, envOverrides) {
|
||||
};
|
||||
});
|
||||
},
|
||||
// 是否开启测试 testid
|
||||
// enableTestid: true,
|
||||
...envOverrides
|
||||
};
|
||||
|
||||
|
@ -478,11 +478,11 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
||||
|
||||
// 优先使用组件自己的testid或者id,这个解决不了table行内的一些子元素
|
||||
// 每一行都会出现这个testid的元素,只在测试工具中直接使用nth拿序号
|
||||
if (props.testid || props.id || props.testIdBuilder == null) {
|
||||
if (!(props.testIdBuilder instanceof TestIdBuilder)) {
|
||||
props.testIdBuilder = new TestIdBuilder(
|
||||
rest.env.enableTestid ? props.testid || props.id : null
|
||||
);
|
||||
if (rest.env.enableTestid) {
|
||||
if (props.testid || props.id || props.testIdBuilder == null) {
|
||||
if (!(props.testIdBuilder instanceof TestIdBuilder)) {
|
||||
props.testIdBuilder = new TestIdBuilder(props.testid || props.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ export interface ButtonGroupProps
|
||||
| 'btnClassName'
|
||||
> {
|
||||
options: Array<Option>;
|
||||
testIdBuilder: TestIdBuilder;
|
||||
testIdBuilder?: TestIdBuilder;
|
||||
}
|
||||
|
||||
export default class ButtonGroupControl extends React.Component<
|
||||
|
@ -60,12 +60,12 @@ export function AutoFilterForm({
|
||||
type: 'input-text',
|
||||
name: column.name,
|
||||
label: column.label,
|
||||
testIdBuilder: testIdBuilder.getChild(column.name)
|
||||
testIdBuilder: testIdBuilder?.getChild(column.name)
|
||||
}
|
||||
: {
|
||||
type: 'input-text',
|
||||
name: column.name,
|
||||
testIdBuilder: testIdBuilder.getChild(column.name),
|
||||
testIdBuilder: testIdBuilder?.getChild(column.name),
|
||||
...column.searchable
|
||||
}),
|
||||
name: column.searchable?.name ?? column.name,
|
||||
@ -130,7 +130,9 @@ export function AutoFilterForm({
|
||||
inputClassName: cx('Table-searchableForm-checkbox-inner'),
|
||||
name: `__whatever_name`,
|
||||
option: column.searchable?.label ?? column.label,
|
||||
testIdBuilder: moreTestIdBuilder?.getChild(column.name),
|
||||
testIdBuilder: moreTestIdBuilder?.getChild(
|
||||
column.name + ''
|
||||
),
|
||||
badge: {
|
||||
offset: [-10, 5],
|
||||
visibleOn: `${
|
||||
|
@ -22,7 +22,7 @@ export interface TableContentProps extends LocaleProps {
|
||||
className?: string;
|
||||
tableClassName?: string;
|
||||
classnames: ClassNamesFn;
|
||||
testIdBuilder: TestIdBuilder;
|
||||
testIdBuilder?: TestIdBuilder;
|
||||
columns: Array<IColumn>;
|
||||
columnsGroup: Array<{
|
||||
label: string;
|
||||
|
@ -1697,7 +1697,7 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
onSearchableFromSubmit={onSearchableFromSubmit}
|
||||
onSearchableFromInit={onSearchableFromInit}
|
||||
popOverContainer={this.getPopOverContainer}
|
||||
testIdBuilder={testIdBuilder.getChild('filter')}
|
||||
testIdBuilder={testIdBuilder?.getChild('filter')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -2122,7 +2122,7 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
quickEditFormRef={this.subFormRef}
|
||||
onImageEnlarge={this.handleImageEnlarge}
|
||||
translate={translate}
|
||||
testIdBuilder={testIdBuilder.getChild(
|
||||
testIdBuilder={testIdBuilder?.getChild(
|
||||
`cell-${props.rowPath}-${column.index}`
|
||||
)}
|
||||
/>
|
||||
@ -2832,7 +2832,7 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
'Table--autoFillHeight': autoFillHeight
|
||||
})}
|
||||
style={store.buildStyles(style)}
|
||||
{...testIdBuilder.getTestId()}
|
||||
{...testIdBuilder?.getTestId()}
|
||||
>
|
||||
{autoGenerateFilter ? this.renderAutoFilterForm() : null}
|
||||
{this.renderAffixHeader(tableClassName)}
|
||||
|
Loading…
Reference in New Issue
Block a user