Skip to content

Commit bf91323

Browse files
committed
[ML] Functional tests: Enable randomize query switch.
1 parent f88abb9 commit bf91323

File tree

6 files changed

+102
-10
lines changed

6 files changed

+102
-10
lines changed

x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ export const ScatterplotMatrix: FC<ScatterplotMatrixProps> = ({
341341
fullWidth
342342
>
343343
<EuiSwitch
344+
data-test-subj={`mlScatterplotMatrixRandomizeQuerySwitch`}
344345
name="mlScatterplotMatrixRandomizeQuery"
345346
label={randomizeQuery ? TOGGLE_ON : TOGGLE_OFF}
346347
checked={randomizeQuery}

x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ export default function ({ getService }: FtrProviderContext) {
105105
await ml.testExecution.logTestStep('displays the include fields selection');
106106
await ml.dataFrameAnalyticsCreation.assertIncludeFieldsSelectionExists();
107107

108+
await ml.testExecution.logTestStep(
109+
'sets the randomize query switch to true for the scatterplot matrix'
110+
);
111+
await ml.dataFrameAnalyticsCreation.setScatterplotMatrixRandomizeQueryCheckState(true);
112+
108113
await ml.testExecution.logTestStep('displays the scatterplot matrix');
109114
await ml.dataFrameAnalyticsCreation.assertScatterplotMatrix(
110115
testData.expected.scatterplotMatrixColorStats
@@ -236,6 +241,12 @@ export default function ({ getService }: FtrProviderContext) {
236241
await ml.testExecution.logTestStep('displays the results view for created job');
237242
await ml.dataFrameAnalyticsTable.openResultsView(testData.jobId);
238243
await ml.dataFrameAnalyticsResults.assertClassificationEvaluatePanelElementsExists();
244+
await ml.dataFrameAnalyticsResults.assertClassificationTablePanelExists();
245+
await ml.dataFrameAnalyticsResults.assertResultsTableExists();
246+
await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist();
247+
await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty();
248+
249+
await ml.testExecution.logTestStep('displays the ROC curve chart');
239250
await ml.commonUI.assertColorsInCanvasElement(
240251
'mlDFAnalyticsClassificationExplorationRocCurveChart',
241252
testData.expected.rocCurveColorState,
@@ -246,10 +257,13 @@ export default function ({ getService }: FtrProviderContext) {
246257
// since the returned colors vary quite a bit on each run.
247258
20
248259
);
249-
await ml.dataFrameAnalyticsResults.assertClassificationTablePanelExists();
250-
await ml.dataFrameAnalyticsResults.assertResultsTableExists();
251-
await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist();
252-
await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty();
260+
261+
await ml.testExecution.logTestStep(
262+
'sets the randomize query switch to true for the scatterplot matrix'
263+
);
264+
await ml.dataFrameAnalyticsResults.setScatterplotMatrixRandomizeQueryCheckState(true);
265+
266+
await ml.testExecution.logTestStep('displays the scatterplot matrix');
253267
await ml.dataFrameAnalyticsResults.assertScatterplotMatrix(
254268
testData.expected.scatterplotMatrixColorStats
255269
);

x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function ({ getService }: FtrProviderContext) {
5252
],
5353
scatterplotMatrixColorsWizard: [
5454
// markers
55-
{ color: '#52B398', percentage: 25 },
55+
{ color: '#52B398', percentage: 15 },
5656
// grey boilerplate
5757
{ color: '#6A717D', percentage: 30 },
5858
],
@@ -62,9 +62,9 @@ export default function ({ getService }: FtrProviderContext) {
6262
// tick/grid/axis, grey markers
6363
{ color: '#6A717D', percentage: 30 },
6464
{ color: '#D3DAE6', percentage: 8 },
65-
{ color: '#98A1B3', percentage: 25 },
65+
{ color: '#98A1B3', percentage: 12 },
6666
// anti-aliasing
67-
{ color: '#F5F7FA', percentage: 27 },
67+
{ color: '#F5F7FA', percentage: 30 },
6868
],
6969
row: {
7070
type: 'outlier_detection',
@@ -126,6 +126,11 @@ export default function ({ getService }: FtrProviderContext) {
126126
await ml.testExecution.logTestStep('displays the include fields selection');
127127
await ml.dataFrameAnalyticsCreation.assertIncludeFieldsSelectionExists();
128128

129+
await ml.testExecution.logTestStep(
130+
'sets the randomize query switch to true for the scatterplot matrix'
131+
);
132+
await ml.dataFrameAnalyticsCreation.setScatterplotMatrixRandomizeQueryCheckState(true);
133+
129134
await ml.testExecution.logTestStep('displays the scatterplot matrix');
130135
await ml.dataFrameAnalyticsCreation.assertScatterplotMatrix(
131136
testData.expected.scatterplotMatrixColorsWizard
@@ -255,6 +260,13 @@ export default function ({ getService }: FtrProviderContext) {
255260
await ml.dataFrameAnalyticsResults.assertResultsTableExists();
256261
await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty();
257262
await ml.dataFrameAnalyticsResults.assertFeatureInfluenceCellNotEmpty();
263+
264+
await ml.testExecution.logTestStep(
265+
'sets the randomize query switch to true for the scatterplot matrix'
266+
);
267+
await ml.dataFrameAnalyticsResults.setScatterplotMatrixRandomizeQueryCheckState(true);
268+
269+
await ml.testExecution.logTestStep('displays the scatterplot matrix');
258270
await ml.dataFrameAnalyticsResults.assertScatterplotMatrix(
259271
testData.expected.scatterplotMatrixColorStatsResults
260272
);

x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ export default function ({ getService }: FtrProviderContext) {
9999
await ml.testExecution.logTestStep('displays the include fields selection');
100100
await ml.dataFrameAnalyticsCreation.assertIncludeFieldsSelectionExists();
101101

102+
await ml.testExecution.logTestStep(
103+
'sets the randomize query switch to true for the scatterplot matrix'
104+
);
105+
await ml.dataFrameAnalyticsCreation.setScatterplotMatrixRandomizeQueryCheckState(true);
106+
102107
await ml.testExecution.logTestStep('displays the scatterplot matrix');
103108
await ml.dataFrameAnalyticsCreation.assertScatterplotMatrix(
104109
testData.expected.scatterplotMatrixColorStats
@@ -229,6 +234,13 @@ export default function ({ getService }: FtrProviderContext) {
229234
await ml.dataFrameAnalyticsResults.assertResultsTableExists();
230235
await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist();
231236
await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty();
237+
238+
await ml.testExecution.logTestStep(
239+
'sets the randomize query switch to true for the scatterplot matrix'
240+
);
241+
await ml.dataFrameAnalyticsResults.setScatterplotMatrixRandomizeQueryCheckState(true);
242+
243+
await ml.testExecution.logTestStep('displays the scatterplot matrix');
232244
await ml.dataFrameAnalyticsResults.assertScatterplotMatrix(
233245
testData.expected.scatterplotMatrixColorStats
234246
);

x-pack/test/functional/services/ml/data_frame_analytics_creation.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,29 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
274274
);
275275
},
276276

277+
async getScatterplotMatrixRandomizeQuerySwitchCheckState(): Promise<boolean> {
278+
const state = await testSubjects.getAttribute(
279+
'mlScatterplotMatrixRandomizeQuerySwitch',
280+
'aria-checked'
281+
);
282+
return state === 'true';
283+
},
284+
285+
async assertScatterplotMatrixRandomizeQueryCheckState(expectedCheckState: boolean) {
286+
const actualCheckState = await this.getScatterplotMatrixRandomizeQuerySwitchCheckState();
287+
expect(actualCheckState).to.eql(
288+
expectedCheckState,
289+
`Randomize query check state should be '${expectedCheckState}' (got '${actualCheckState}')`
290+
);
291+
},
292+
293+
async setScatterplotMatrixRandomizeQueryCheckState(checkState: boolean) {
294+
if ((await this.getScatterplotMatrixRandomizeQuerySwitchCheckState()) !== checkState) {
295+
await testSubjects.click('mlScatterplotMatrixRandomizeQuerySwitch');
296+
}
297+
await this.assertScatterplotMatrixRandomizeQueryCheckState(checkState);
298+
},
299+
277300
async assertTrainingPercentInputExists() {
278301
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardTrainingPercentSlider');
279302
},

x-pack/test/functional/services/ml/data_frame_analytics_results.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,44 @@ export function MachineLearningDataFrameAnalyticsResultsProvider(
8585
});
8686
},
8787

88+
async getScatterplotMatrixRandomizeQuerySwitchCheckState(): Promise<boolean> {
89+
const state = await testSubjects.getAttribute(
90+
'mlScatterplotMatrixRandomizeQuerySwitch',
91+
'aria-checked'
92+
);
93+
return state === 'true';
94+
},
95+
96+
async assertScatterplotMatrixRandomizeQueryCheckState(expectedCheckState: boolean) {
97+
const actualCheckState = await this.getScatterplotMatrixRandomizeQuerySwitchCheckState();
98+
expect(actualCheckState).to.eql(
99+
expectedCheckState,
100+
`Randomize query check state should be '${expectedCheckState}' (got '${actualCheckState}')`
101+
);
102+
},
103+
104+
async setScatterplotMatrixRandomizeQueryCheckState(checkState: boolean) {
105+
if ((await this.getScatterplotMatrixRandomizeQuerySwitchCheckState()) !== checkState) {
106+
await testSubjects.click('mlScatterplotMatrixRandomizeQuerySwitch');
107+
}
108+
await this.assertScatterplotMatrixRandomizeQueryCheckState(checkState);
109+
},
110+
88111
async assertScatterplotMatrix(expectedValue: CanvasElementColorStats) {
89112
await testSubjects.existOrFail('mlDFExpandableSection-splom > mlScatterplotMatrix loaded', {
90113
timeout: 5000,
91114
});
92115
await testSubjects.scrollIntoView('mlDFExpandableSection-splom > mlScatterplotMatrix loaded');
93-
await mlCommonUI.assertColorsInCanvasElement('mlDFExpandableSection-splom', expectedValue, [
94-
'#000000',
95-
]);
116+
await mlCommonUI.assertColorsInCanvasElement(
117+
'mlDFExpandableSection-splom',
118+
expectedValue,
119+
['#000000'],
120+
undefined,
121+
undefined,
122+
// increased tolerance up from 10 to 20
123+
// since the returned randomized colors vary quite a bit on each run.
124+
20
125+
);
96126
},
97127

98128
async assertFeatureImportanceDecisionPathChartElementsExists() {

0 commit comments

Comments
 (0)