Skip to content

Commit 785807f

Browse files
authored
[7.5] [ML] Add tests to create transforms (#49760) (#52080)
* [ML] Add tests to create transforms (#49760) * Apply #51066 to backport * Adjust eui switch handling for 7.5
1 parent aef43e7 commit 785807f

File tree

36 files changed

+1697
-687
lines changed

36 files changed

+1697
-687
lines changed

x-pack/legacy/plugins/ml/public/components/kql_filter_bar/filter_bar/filter_bar.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export class FilterBar extends Component {
178178
onClick={this.onClickInput}
179179
autoComplete="off"
180180
spellCheck={false}
181+
data-test-subj={this.props.testSubj}
181182
/>
182183

183184
{this.props.isLoading && (
@@ -213,12 +214,14 @@ FilterBar.propTypes = {
213214
placeholder: PropTypes.string,
214215
onSubmit: PropTypes.func.isRequired,
215216
valueExternal: PropTypes.string,
216-
suggestions: PropTypes.array.isRequired
217+
suggestions: PropTypes.array.isRequired,
218+
testSubj: PropTypes.string,
217219
};
218220

219221
FilterBar.defaultProps = {
220222
isLoading: false,
221223
disabled: false,
222224
placeholder: 'tag : engineering OR tag : marketing',
223-
suggestions: []
225+
suggestions: [],
226+
testSubj: undefined,
224227
};

x-pack/legacy/plugins/ml/public/components/kql_filter_bar/kql_filter_bar.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class KqlFilterBar extends Component {
9090

9191
render() {
9292
const { error } = this.state;
93-
const { initialValue, placeholder, valueExternal } = this.props;
93+
const { initialValue, placeholder, valueExternal, testSubj } = this.props;
9494

9595
return (
9696
<Fragment>
@@ -103,6 +103,7 @@ export class KqlFilterBar extends Component {
103103
onSubmit={this.onSubmit}
104104
suggestions={this.state.suggestions}
105105
valueExternal={valueExternal}
106+
testSubj={testSubj}
106107
/>
107108
{ error &&
108109
<EuiCallOut color="danger">
@@ -118,6 +119,7 @@ KqlFilterBar.propTypes = {
118119
initialValue: PropTypes.string,
119120
onSubmit: PropTypes.func.isRequired,
120121
placeholder: PropTypes.string,
121-
valueExternal: PropTypes.string
122+
valueExternal: PropTypes.string,
123+
testSubj: PropTypes.string,
122124
};
123125

x-pack/legacy/plugins/ml/public/components/ml_in_memory_table/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface FieldDataColumnType {
3131
render?: RenderFunc;
3232
footer?: string | ReactElement | FooterFunc;
3333
textOnly?: boolean;
34+
'data-test-subj'?: string;
3435
}
3536

3637
export interface ComputedColumnType {
@@ -40,6 +41,7 @@ export interface ComputedColumnType {
4041
sortable?: (item: Item) => any;
4142
width?: string;
4243
truncateText?: boolean;
44+
'data-test-subj'?: string;
4345
}
4446

4547
type ICON_TYPES = any;
@@ -183,7 +185,7 @@ export type EuiInMemoryTableProps = CommonProps & {
183185
selection?: SelectionType;
184186
itemId?: ItemIdType;
185187
itemIdToExpandedRowMap?: Record<string, Item>;
186-
rowProps?: () => void | Record<string, any>;
188+
rowProps?: (item: Item) => void | Record<string, any>;
187189
cellProps?: () => void | Record<string, any>;
188190
onTableChange?: (arg: OnTableChangeArg) => void;
189191
};

x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_dropdown/dropdown.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ interface Props {
1212
options: EuiComboBoxOptionProps[];
1313
placeholder?: string;
1414
changeHandler(d: EuiComboBoxOptionProps[]): void;
15+
testSubj?: string;
1516
}
1617

1718
export const DropDown: React.SFC<Props> = ({
1819
changeHandler,
1920
options,
2021
placeholder = 'Search ...',
22+
testSubj,
2123
}) => {
2224
return (
2325
<EuiComboBox
@@ -27,6 +29,7 @@ export const DropDown: React.SFC<Props> = ({
2729
selectedOptions={[]}
2830
onChange={changeHandler}
2931
isClearable={false}
32+
data-test-subj={testSubj}
3033
/>
3134
);
3235
};

x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/agg_label_form.test.tsx.snap

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/__snapshots__/list_form.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/agg_label_form.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export const AggLabelForm: React.SFC<Props> = ({
3939
return (
4040
<EuiFlexGroup alignItems="center" gutterSize="s" responsive={false}>
4141
<EuiFlexItem className="transform__AggregationLabel--text">
42-
<span className="eui-textTruncate">{item.aggName}</span>
42+
<span className="eui-textTruncate" data-test-subj="transformAggregationEntryLabel">
43+
{item.aggName}
44+
</span>
4345
</EuiFlexItem>
4446
<EuiFlexItem grow={false} className="transform__GroupByLabel--button">
4547
<EuiPopover
@@ -53,6 +55,7 @@ export const AggLabelForm: React.SFC<Props> = ({
5355
size="s"
5456
iconType="pencil"
5557
onClick={() => setPopoverVisibility(!isPopoverVisible)}
58+
data-test-subj="transformAggregationEntryEditButton"
5659
/>
5760
}
5861
isOpen={isPopoverVisible}
@@ -74,6 +77,7 @@ export const AggLabelForm: React.SFC<Props> = ({
7477
size="s"
7578
iconType="cross"
7679
onClick={() => deleteHandler(item.aggName)}
80+
data-test-subj="transformAggregationEntryDeleteButton"
7781
/>
7882
</EuiFlexItem>
7983
</EuiFlexGroup>

x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/aggregation_list/list_form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export const AggListForm: React.SFC<AggListProps> = ({
3333
const listKeys = Object.keys(list);
3434
return (
3535
<Fragment>
36-
{listKeys.map((aggName: AggName) => {
36+
{listKeys.map((aggName: AggName, i) => {
3737
const otherAggNames = listKeys.filter(k => k !== aggName);
3838
return (
3939
<Fragment key={aggName}>
40-
<EuiPanel paddingSize="s">
40+
<EuiPanel paddingSize="s" data-test-subj={`transformAggregationEntry ${i}`}>
4141
<AggLabelForm
4242
deleteHandler={deleteHandler}
4343
item={list[aggName]}

x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/group_by_label_form.test.tsx.snap

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/legacy/plugins/transform/public/app/sections/create_transform/components/group_by_list/__snapshots__/list_form.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)