From 6de217d016875681172ebe2ba3205d042e99b7fa Mon Sep 17 00:00:00 2001 From: allenve Date: Fri, 2 Aug 2024 14:42:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20container=20wizard=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=20testid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/src/renderers/Container.tsx | 8 ++++++-- .../amis/src/renderers/Table/HeadCellSearchDropdown.tsx | 6 +++++- packages/amis/src/renderers/Table/index.tsx | 7 ++++++- packages/amis/src/renderers/Wizard.tsx | 9 ++++++--- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/packages/amis/src/renderers/Container.tsx b/packages/amis/src/renderers/Container.tsx index d7d1bf6c5..66e4b132b 100644 --- a/packages/amis/src/renderers/Container.tsx +++ b/packages/amis/src/renderers/Container.tsx @@ -157,7 +157,8 @@ export default class Container extends React.Component< classnames: cx, bodyClassName, disabled, - wrapperBody + wrapperBody, + testIdBuilder } = this.props; const isWrapperBody = wrapperBody ?? true; @@ -172,7 +173,10 @@ export default class Container extends React.Component< if (isWrapperBody) { return ( -
+
{containerBody}
); diff --git a/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx b/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx index 6b17c70d6..d980439f1 100644 --- a/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx +++ b/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx @@ -5,6 +5,7 @@ import {Icon} from 'amis-ui'; import {Overlay} from 'amis-core'; import {PopOver} from 'amis-core'; import {setVariable, createObject} from 'amis-core'; +import type {TestIdBuilder} from 'amis-core'; export interface QuickSearchConfig { type?: string; @@ -19,6 +20,7 @@ export interface HeadCellSearchProps extends RendererProps { searchable: boolean | QuickSearchConfig; classPrefix: string; onQuery: (values: object) => void; + testIdBuilder?: TestIdBuilder; } export function HeadCellSearchDropDown({ @@ -33,7 +35,8 @@ export function HeadCellSearchDropDown({ translate: __, classPrefix: ns, popOverContainer, - render + render, + testIdBuilder }: HeadCellSearchProps) { const ref = React.createRef(); const [formSchema, formItems] = React.useMemo(() => { @@ -183,6 +186,7 @@ export function HeadCellSearchDropDown({ isActive ? 'is-active' : '', isOpened ? 'is-opened' : '' )} + {...testIdBuilder?.getTestId()} > diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index 499ac910a..56b1f7c76 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -1851,12 +1851,14 @@ export default class Table extends React.Component { classnames: cx, autoGenerateFilter, dispatchEvent, - data + data, + testIdBuilder } = this.props; // 注意,这里用关了哪些 store 里面的东西,TableContent 里面得也用一下 // 因为 renderHeadCell 是 TableContent 回调的,tableContent 不重新渲染,这里面也不会重新渲染 + const tIdCell = testIdBuilder?.getChild(`head-cell-${column.name}`); const style = {...props.style}; const [stickyStyle, stickyClassName] = store.getStickyStyles( column, @@ -1989,6 +1991,7 @@ export default class Table extends React.Component { searchable={column.searchable} type={column.type} data={query} + testIdBuilder={tIdCell?.getChild('search')} popOverContainer={this.getPopOverContainer} /> ); @@ -2079,6 +2082,7 @@ export default class Table extends React.Component { superData={createObject(data, query)} filterable={column.filterable} popOverContainer={this.getPopOverContainer} + testIdBuilder={tIdCell?.getChild('filter')} /> ); } @@ -2093,6 +2097,7 @@ export default class Table extends React.Component { 'TableCell--filterable': column.filterable, 'Table-operationCell': column.type === 'operation' })} + {...tIdCell?.getTestId()} > {prefix}
{ actionFinishLabel, render, translate: __, - classnames: cx + classnames: cx, + testIdBuilder } = this.props; const steps = this.state.rawSteps; @@ -1155,7 +1156,8 @@ export default class Wizard extends React.Component { label: __(actionPrevLabel), actionType: 'prev', className: actionClassName, - hiddenOn: '${currentStep === 1}' + hiddenOn: '${currentStep === 1}', + id: testIdBuilder?.getChild('button-prev').getTestIdValue() }, { disabled: waiting || !prevCanJump || disabled, @@ -1176,7 +1178,8 @@ export default class Wizard extends React.Component { actionType: 'next', primary: !nextStep || !!step.api, className: actionClassName, - level: 'primary' + level: 'primary', + id: testIdBuilder?.getChild('button-next').getTestIdValue() }, { disabled: