[ML] Functional tests - add validation messages (#67583)

This PR adds validation messages to all ML and Transform services in order to make it easier to debug test failures.
This commit is contained in:
Robert Oskamp 2020-05-28 15:19:25 +02:00 committed by GitHub
parent dcca06bad2
commit e492cf138d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 303 additions and 106 deletions

View file

@ -23,10 +23,13 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
await ml.securityCommon.cleanMlRoles();
await ml.testResources.deleteIndexPattern('kibana_sample_data_logs');
await ml.testResources.deleteIndexPattern('ft_farequote');
await esArchiver.unload('ml/ecommerce');
await esArchiver.unload('ml/categorization');
await esArchiver.unload('ml/sample_logs');
await esArchiver.unload('ml/farequote');
await esArchiver.unload('ml/bm_classification');
await ml.testResources.resetKibanaTimeZone();
});

View file

@ -19,7 +19,7 @@ export function MachineLearningAnomaliesTableProvider({ getService }: FtrProvide
const tableRows = await testSubjects.findAll('mlAnomaliesTable > ~mlAnomaliesListRow');
expect(tableRows.length).to.be.greaterThan(
0,
'Anomalies table should have at least one row (got 0)'
`Anomalies table should have at least one row (got '${tableRows.length}')`
);
},
};

View file

@ -140,7 +140,10 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) {
async getJobState(jobId: string): Promise<JOB_STATE> {
const jobStats = await this.getADJobStats(jobId);
expect(jobStats.jobs).to.have.length(1);
expect(jobStats.jobs).to.have.length(
1,
`Expected job stats to have exactly one job (got '${jobStats.length}')`
);
const state: JOB_STATE = jobStats.jobs[0].state;
return state;
@ -178,7 +181,10 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) {
.expect(200)
.then((res: any) => res.body);
expect(datafeedStats.datafeeds).to.have.length(1);
expect(datafeedStats.datafeeds).to.have.length(
1,
`Expected datafeed stats to have exactly one datafeed (got '${datafeedStats.datafeeds.length}')`
);
const state: DATAFEED_STATE = datafeedStats.datafeeds[0].state;
return state;
@ -206,7 +212,10 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) {
.expect(200)
.then((res: any) => res.body);
expect(analyticsStats.data_frame_analytics).to.have.length(1);
expect(analyticsStats.data_frame_analytics).to.have.length(
1,
`Expected dataframe analytics stats to have exactly one object (got '${analyticsStats.data_frame_analytics.length}')`
);
const state: DATA_FRAME_TASK_STATE = analyticsStats.data_frame_analytics[0].state;
return state;
@ -414,7 +423,10 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) {
async getADJobRecordCount(jobId: string): Promise<number> {
const jobStats = await this.getADJobStats(jobId);
expect(jobStats.jobs).to.have.length(1);
expect(jobStats.jobs).to.have.length(
1,
`Expected job stats to have exactly one job (got '${jobStats.jobs.length}')`
);
const processedRecordCount: number = jobStats.jobs[0].data_counts.processed_record_count;
return processedRecordCount;

View file

@ -19,7 +19,10 @@ export function MachineLearningCustomUrlsProvider({ getService }: FtrProviderCon
'mlJobCustomUrlLabelInput',
'value'
);
expect(actualCustomUrlLabel).to.eql(expectedValue);
expect(actualCustomUrlLabel).to.eql(
expectedValue,
`Expected custom url label to be '${expectedValue}' (got '${actualCustomUrlLabel}')`
);
},
async setCustomUrlLabel(customUrlsLabel: string) {
@ -29,11 +32,16 @@ export function MachineLearningCustomUrlsProvider({ getService }: FtrProviderCon
await this.assertCustomUrlLabelValue(customUrlsLabel);
},
async assertCustomUrlItem(index: number, label: string) {
async assertCustomUrlItem(index: number, expectedLabel: string) {
await testSubjects.existOrFail(`mlJobEditCustomUrlItem_${index}`);
expect(
await testSubjects.getAttribute(`mlJobEditCustomUrlLabelInput_${index}`, 'value')
).to.eql(label);
const actualLabel = await testSubjects.getAttribute(
`mlJobEditCustomUrlLabelInput_${index}`,
'value'
);
expect(actualLabel).to.eql(
expectedLabel,
`Expected custom url item to be '${expectedLabel}' (got '${actualLabel}')`
);
},
/**

View file

@ -75,7 +75,7 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
)) === 'true';
expect(actualCheckState).to.eql(
expectedCheckState,
`Advanced editor switch check state should be ${expectedCheckState} (got ${actualCheckState})`
`Advanced editor switch check state should be '${expectedCheckState}' (got '${actualCheckState}')`
);
},
@ -317,7 +317,7 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
const actualCheckState = await this.getCreateIndexPatternSwitchCheckState();
expect(actualCheckState).to.eql(
expectedCheckState,
`Create index pattern switch check state should be ${expectedCheckState} (got ${actualCheckState})`
`Create index pattern switch check state should be '${expectedCheckState}' (got '${actualCheckState}')`
);
},

View file

@ -107,7 +107,12 @@ export function MachineLearningDataFrameAnalyticsTableProvider({ getService }: F
public async assertAnalyticsRowFields(analyticsId: string, expectedRow: object) {
const rows = await this.parseAnalyticsTable();
const analyticsRow = rows.filter((row) => row.id === analyticsId)[0];
expect(analyticsRow).to.eql(expectedRow);
expect(analyticsRow).to.eql(
expectedRow,
`Expected analytics row to be '${JSON.stringify(expectedRow)}' (got '${JSON.stringify(
analyticsRow
)}')`
);
}
public async openRowActions(analyticsId: string) {

View file

@ -23,7 +23,10 @@ export function MachineLearningDataVisualizerIndexBasedProvider({
async assertTotalDocumentCount(expectedTotalDocCount: number) {
await retry.tryForTime(5000, async () => {
const docCount = await testSubjects.getVisibleText('mlDataVisualizerTotalDocCount');
expect(docCount).to.eql(expectedTotalDocCount);
expect(docCount).to.eql(
expectedTotalDocCount,
`Expected total document count to be '${expectedTotalDocCount}' (got '${docCount}')`
);
});
},
@ -34,7 +37,10 @@ export function MachineLearningDataVisualizerIndexBasedProvider({
async assertFieldsPanelsExist(expectedPanelCount: number) {
const allPanels = await testSubjects.findAll('~mlDataVisualizerFieldsPanel');
expect(allPanels).to.have.length(expectedPanelCount);
expect(allPanels).to.have.length(
expectedPanelCount,
`Expected field panels count to be '${expectedPanelCount}' (got '${allPanels.length}')`
);
},
async assertFieldsPanelForTypesExist(fieldTypes: ML_JOB_FIELD_TYPES[]) {
@ -50,7 +56,10 @@ export function MachineLearningDataVisualizerIndexBasedProvider({
const filteredCards = await testSubjects.findAll(
`mlDataVisualizerFieldsPanel ${panelFieldTypes} > ~mlFieldDataCard`
);
expect(filteredCards).to.have.length(expectedCardCount);
expect(filteredCards).to.have.length(
expectedCardCount,
`Expected field card count for panels '${panelFieldTypes}' to be '${expectedCardCount}' (got '${filteredCards.length}')`
);
});
},
@ -60,7 +69,10 @@ export function MachineLearningDataVisualizerIndexBasedProvider({
);
const searchBarInput = await searchBar.findByTagName('input');
const actualSearchValue = await searchBarInput.getAttribute('value');
expect(actualSearchValue).to.eql(expectedSearchValue);
expect(actualSearchValue).to.eql(
expectedSearchValue,
`Expected search value for field types '${fieldTypes}' to be '${expectedSearchValue}' (got '${actualSearchValue}')`
);
},
async filterFieldsPanelWithSearchString(
@ -91,7 +103,10 @@ export function MachineLearningDataVisualizerIndexBasedProvider({
'mlDataVisualizerFieldTypesSelect',
'value'
);
expect(actualTypeValue).to.eql(expectedTypeValue);
expect(actualTypeValue).to.eql(
expectedTypeValue,
`Expected fields panel type value to be '${expectedTypeValue}' (got '${actualTypeValue}')`
);
},
async setFieldsPanelTypeInputValue(

View file

@ -163,7 +163,10 @@ export function MachineLearningJobTableProvider({ getService }: FtrProviderConte
await this.refreshJobList();
const rows = await this.parseJobTable();
const jobRow = rows.filter((row) => row.id === jobId)[0];
expect(jobRow).to.eql(expectedRow);
expect(jobRow).to.eql(
expectedRow,
`Expected job row to be '${JSON.stringify(expectedRow)}' (got '${JSON.stringify(jobRow)}')`
);
}
public async assertJobRowDetailsCounts(

View file

@ -35,7 +35,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const actualValue = await aceEditor.getValue(
'mlAdvancedDatafeedQueryEditor > codeEditorContainer'
);
expect(actualValue).to.eql(expectedValue);
expect(actualValue).to.eql(
expectedValue,
`Expected datafeed query editor value to be '${expectedValue}' (got '${actualValue}')`
);
},
async assertQueryDelayInputExists() {
@ -44,7 +47,10 @@ export function MachineLearningJobWizardAdvancedProvider(
async assertQueryDelayValue(expectedValue: string) {
const actualQueryDelay = await this.getValueOrPlaceholder('mlJobWizardInputQueryDelay');
expect(actualQueryDelay).to.eql(expectedValue);
expect(actualQueryDelay).to.eql(
expectedValue,
`Expected query delay value to be '${expectedValue}' (got '${actualQueryDelay}')`
);
},
async setQueryDelay(queryDelay: string) {
@ -61,7 +67,10 @@ export function MachineLearningJobWizardAdvancedProvider(
async assertFrequencyValue(expectedValue: string) {
const actualFrequency = await this.getValueOrPlaceholder('mlJobWizardInputFrequency');
expect(actualFrequency).to.eql(expectedValue);
expect(actualFrequency).to.eql(
expectedValue,
`Expected frequency value to be '${expectedValue}' (got '${actualFrequency}')`
);
},
async setFrequency(frequency: string) {
@ -78,7 +87,10 @@ export function MachineLearningJobWizardAdvancedProvider(
async assertScrollSizeValue(expectedValue: string) {
const actualScrollSize = await this.getValueOrPlaceholder('mlJobWizardInputScrollSize');
expect(actualScrollSize).to.eql(expectedValue);
expect(actualScrollSize).to.eql(
expectedValue,
`Expected scroll size value to be '${expectedValue}' (got '${actualScrollSize}')`
);
},
async setScrollSize(scrollSize: string) {
@ -97,7 +109,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlTimeFieldNameSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected time field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectTimeField(identifier: string) {
@ -113,7 +128,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlCategorizationFieldNameSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected categorization field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectCategorizationField(identifier: string) {
@ -129,7 +147,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlSummaryCountFieldNameSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected summary count field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectSummaryCountField(identifier: string) {
@ -160,7 +181,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlAdvancedFunctionSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected detector function selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectDetectorFunction(identifier: string) {
@ -176,7 +200,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlAdvancedFieldSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected detector field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectDetectorField(identifier: string) {
@ -192,7 +219,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlAdvancedByFieldSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected detector by field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectDetectorByField(identifier: string) {
@ -208,7 +238,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlAdvancedOverFieldSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected detector over field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectDetectorOverField(identifier: string) {
@ -224,7 +257,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlAdvancedPartitionFieldSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected detector partition field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectDetectorPartitionField(identifier: string) {
@ -240,7 +276,10 @@ export function MachineLearningJobWizardAdvancedProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlAdvancedExcludeFrequentSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected detector exclude frequent selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectDetectorExcludeFrequent(identifier: string) {
@ -257,7 +296,10 @@ export function MachineLearningJobWizardAdvancedProvider(
'mlAdvancedDetectorDescriptionInput',
'value'
);
expect(actualDetectorDescription).to.eql(expectedValue);
expect(actualDetectorDescription).to.eql(
expectedValue,
`Expected detector description value to be '${expectedValue}' (got '${actualDetectorDescription}')`
);
},
async setDetectorDescription(description: string) {
@ -287,13 +329,19 @@ export function MachineLearningJobWizardAdvancedProvider(
const actualDetectorIdentifier = await testSubjects.getVisibleText(
`mlAdvancedDetector ${detectorIndex} > mlDetectorIdentifier`
);
expect(actualDetectorIdentifier).to.eql(expectedDetectorName);
expect(actualDetectorIdentifier).to.eql(
expectedDetectorName,
`Expected detector name to be '${expectedDetectorName}' (got '${actualDetectorIdentifier}')`
);
if (expectedDetectorDescription !== undefined) {
const actualDetectorDescription = await testSubjects.getVisibleText(
`mlAdvancedDetector ${detectorIndex} > mlDetectorDescription`
);
expect(actualDetectorDescription).to.eql(expectedDetectorDescription);
expect(actualDetectorDescription).to.eql(
expectedDetectorDescription,
`Expected detector description to be '${expectedDetectorDescription}' (got '${actualDetectorDescription}')`
);
}
},

View file

@ -41,7 +41,7 @@ export function MachineLearningJobWizardCategorizationProvider({ getService }: F
);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected categorization field selection to be '${expectedIdentifier}' (got ${comboBoxSelectedOptions}')`
`Expected categorization field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
@ -56,7 +56,7 @@ export function MachineLearningJobWizardCategorizationProvider({ getService }: F
const rows = await body[0].findAllByTagName('tr');
expect(rows.length).to.eql(
exampleCount,
`Expected categorization field examples table to have '${exampleCount}' rows (got ${rows.length}')`
`Expected categorization field examples table to have '${exampleCount}' rows (got '${rows.length}')`
);
},
};

View file

@ -101,7 +101,10 @@ export function MachineLearningJobWizardCommonProvider(
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlJobWizardAggSelection > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected agg and field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectAggAndField(identifier: string, isIdentifierKeptInField: boolean) {
@ -118,7 +121,10 @@ export function MachineLearningJobWizardCommonProvider(
'mlJobWizardInputBucketSpan',
'value'
);
expect(actualBucketSpan).to.eql(expectedValue);
expect(actualBucketSpan).to.eql(
expectedValue,
`Expected bucket span value to be '${expectedValue}' (got '${actualBucketSpan}')`
);
},
async setBucketSpan(bucketSpan: string) {
@ -135,7 +141,10 @@ export function MachineLearningJobWizardCommonProvider(
async assertJobIdValue(expectedValue: string) {
const actualJobId = await testSubjects.getAttribute('mlJobWizardInputJobId', 'value');
expect(actualJobId).to.eql(expectedValue);
expect(actualJobId).to.eql(
expectedValue,
`Expected job id value to be '${expectedValue}' (got '${actualJobId}')`
);
},
async setJobId(jobId: string) {
@ -153,7 +162,10 @@ export function MachineLearningJobWizardCommonProvider(
const actualJobDescription = await testSubjects.getVisibleText(
'mlJobWizardInputJobDescription'
);
expect(actualJobDescription).to.eql(expectedValue);
expect(actualJobDescription).to.eql(
expectedValue,
`Expected job description value to be '${expectedValue}' (got '${actualJobDescription}')`
);
},
async setJobDescription(jobDescription: string) {
@ -174,12 +186,20 @@ export function MachineLearningJobWizardCommonProvider(
},
async assertJobGroupSelection(jobGroups: string[]) {
expect(await this.getSelectedJobGroups()).to.eql(jobGroups);
const actualJobGroupSelection = await this.getSelectedJobGroups();
expect(actualJobGroupSelection).to.eql(
jobGroups,
`Expected job group selection to be '${jobGroups}' (got '${actualJobGroupSelection}')`
);
},
async addJobGroup(jobGroup: string) {
await comboBox.setCustom('mlJobWizardComboBoxJobGroups > comboBoxInput', jobGroup);
expect(await this.getSelectedJobGroups()).to.contain(jobGroup);
const actualJobGroupSelection = await this.getSelectedJobGroups();
expect(actualJobGroupSelection).to.contain(
jobGroup,
`Expected job group selection to contain '${jobGroup}' (got '${actualJobGroupSelection}')`
);
},
async getSelectedCalendars(): Promise<string[]> {
@ -190,13 +210,21 @@ export function MachineLearningJobWizardCommonProvider(
},
async assertCalendarsSelection(calendars: string[]) {
expect(await this.getSelectedCalendars()).to.eql(calendars);
const actualCalendarSelection = await this.getSelectedCalendars();
expect(actualCalendarSelection).to.eql(
calendars,
`Expected calendar selection to be '${calendars}' (got '${actualCalendarSelection}')`
);
},
async addCalendar(calendarId: string) {
await this.ensureAdditionalSettingsSectionOpen();
await comboBox.setCustom('mlJobWizardComboBoxCalendars > comboBoxInput', calendarId);
expect(await this.getSelectedCalendars()).to.contain(calendarId);
const actualCalendarSelection = await this.getSelectedCalendars();
expect(actualCalendarSelection).to.contain(
calendarId,
`Expected calendar selection to conatin '${calendarId}' (got '${actualCalendarSelection}')`
);
},
async assertModelPlotSwitchExists(
@ -229,14 +257,19 @@ export function MachineLearningJobWizardCommonProvider(
const actualCheckedState = await this.getModelPlotSwitchCheckedState({
withAdvancedSection: sectionOptions.withAdvancedSection,
});
expect(actualCheckedState).to.eql(expectedValue);
expect(actualCheckedState).to.eql(
expectedValue,
`Expected model plot switch to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${
actualCheckedState ? 'enabled' : 'disabled'
}')`
);
},
async assertModelPlotSwitchEnabled(expectedValue: boolean) {
const isEnabled = await testSubjects.isEnabled('mlJobWizardSwitchModelPlot');
expect(isEnabled).to.eql(
expectedValue,
`Expected model plot switch to be '${expectedValue ? 'enabled' : 'disabled'}' (got ${
`Expected model plot switch to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${
isEnabled ? 'enabled' : 'disabled'
}')`
);
@ -272,7 +305,12 @@ export function MachineLearningJobWizardCommonProvider(
const actualCheckedState = await this.getDedicatedIndexSwitchCheckedState({
withAdvancedSection: sectionOptions.withAdvancedSection,
});
expect(actualCheckedState).to.eql(expectedValue);
expect(actualCheckedState).to.eql(
expectedValue,
`Expected dedicated index switch to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${
actualCheckedState ? 'enabled' : 'disabled'
}')`
);
},
async activateDedicatedIndexSwitch(
@ -318,7 +356,10 @@ export function MachineLearningJobWizardCommonProvider(
subj = advancedSectionSelector(subj);
}
const actualModelMemoryLimit = await testSubjects.getAttribute(subj, 'value');
expect(actualModelMemoryLimit).to.eql(expectedValue);
expect(actualModelMemoryLimit).to.eql(
expectedValue,
`Expected model memory limit value to be '${expectedValue}' (got '${actualModelMemoryLimit}')`
);
},
async setModelMemoryLimit(
@ -347,12 +388,20 @@ export function MachineLearningJobWizardCommonProvider(
},
async assertInfluencerSelection(influencers: string[]) {
expect(await this.getSelectedInfluencers()).to.eql(influencers);
const actualInfluencerSelection = await this.getSelectedInfluencers();
expect(actualInfluencerSelection).to.eql(
influencers,
`Expected influencer selection to be '${influencers}' (got '${actualInfluencerSelection}')`
);
},
async addInfluencer(influencer: string) {
await comboBox.set('mlInfluencerSelect > comboBoxInput', influencer);
expect(await this.getSelectedInfluencers()).to.contain(influencer);
const actualInfluencerSelection = await this.getSelectedInfluencers();
expect(actualInfluencerSelection).to.contain(
influencer,
`Expected influencer selection to contain '${influencer}' (got '${actualInfluencerSelection}')`
);
},
async assertAnomalyChartExists(chartType: string, preSelector?: string) {
@ -367,9 +416,13 @@ export function MachineLearningJobWizardCommonProvider(
) {
await testSubjects.existOrFail(`mlDetector ${detectorPosition}`);
await testSubjects.existOrFail(`mlDetector ${detectorPosition} > mlDetectorTitle`);
expect(
await testSubjects.getVisibleText(`mlDetector ${detectorPosition} > mlDetectorTitle`)
).to.eql(aggAndFieldIdentifier);
const actualDetectorTitle = await testSubjects.getVisibleText(
`mlDetector ${detectorPosition} > mlDetectorTitle`
);
expect(actualDetectorTitle).to.eql(
aggAndFieldIdentifier,
`Expected detector title at position '${detectorPosition}' to be '${aggAndFieldIdentifier}' (got '${actualDetectorTitle}')`
);
await this.assertAnomalyChartExists(chartType, `mlDetector ${detectorPosition}`);
},
@ -393,10 +446,15 @@ export function MachineLearningJobWizardCommonProvider(
async assertDateRangeSelection(expectedStartDate: string, expectedEndDate: string) {
await retry.tryForTime(5000, async () => {
expect(await this.getSelectedDateRange()).to.eql({
startDate: expectedStartDate,
endDate: expectedEndDate,
});
const { startDate, endDate } = await this.getSelectedDateRange();
expect(startDate).to.eql(
expectedStartDate,
`Expected start date to be '${expectedStartDate}' (got '${startDate}')`
);
expect(endDate).to.eql(
expectedEndDate,
`Expected end date to be '${expectedEndDate}' (got '${endDate}')`
);
});
},

View file

@ -20,7 +20,10 @@ export function MachineLearningJobWizardMultiMetricProvider({ getService }: FtrP
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlMultiMetricSplitFieldSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected split field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectSplitField(identifier: string) {
@ -33,15 +36,21 @@ export function MachineLearningJobWizardMultiMetricProvider({ getService }: FtrP
await testSubjects.existOrFail(`mlDataSplit > mlSplitCard front`);
},
async assertDetectorSplitFrontCardTitle(frontCardTitle: string) {
expect(
await testSubjects.getVisibleText(`mlDataSplit > mlSplitCard front > mlSplitCardTitle`)
).to.eql(frontCardTitle);
async assertDetectorSplitFrontCardTitle(expectedFrontCardTitle: string) {
const actualFrontCardTitle = await testSubjects.getVisibleText(
`mlDataSplit > mlSplitCard front > mlSplitCardTitle`
);
expect(actualFrontCardTitle).to.eql(
expectedFrontCardTitle,
`Expected front card title to be '${expectedFrontCardTitle}' (got '${actualFrontCardTitle}')`
);
},
async assertDetectorSplitNumberOfBackCards(numberOfBackCards: number) {
expect(await testSubjects.findAll(`mlDataSplit > mlSplitCard back`)).to.have.length(
numberOfBackCards
async assertDetectorSplitNumberOfBackCards(expectedNumberOfBackCards: number) {
const allBackCards = await testSubjects.findAll(`mlDataSplit > mlSplitCard back`);
expect(allBackCards).to.have.length(
expectedNumberOfBackCards,
`Expected number of back cards to be '${expectedNumberOfBackCards}' (got '${allBackCards.length}')`
);
},
};

View file

@ -20,7 +20,10 @@ export function MachineLearningJobWizardPopulationProvider({ getService }: FtrPr
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'mlPopulationSplitFieldSelect > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected population field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectPopulationField(identifier: string) {
@ -41,7 +44,10 @@ export function MachineLearningJobWizardPopulationProvider({ getService }: FtrPr
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
`mlDetector ${detectorPosition} > mlByFieldSelect > comboBoxInput`
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected detector split field selection to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
},
async selectDetectorSplitField(detectorPosition: number, identifier: string) {
@ -59,23 +65,30 @@ export function MachineLearningJobWizardPopulationProvider({ getService }: FtrPr
);
},
async assertDetectorSplitFrontCardTitle(detectorPosition: number, frontCardTitle: string) {
expect(
await testSubjects.getVisibleText(
`mlDetector ${detectorPosition} > mlDataSplit > mlSplitCard front > mlSplitCardTitle`
)
).to.eql(frontCardTitle);
async assertDetectorSplitFrontCardTitle(
detectorPosition: number,
expectedFrontCardTitle: string
) {
const actualSplitFrontCardTitle = await testSubjects.getVisibleText(
`mlDetector ${detectorPosition} > mlDataSplit > mlSplitCard front > mlSplitCardTitle`
);
expect(actualSplitFrontCardTitle).to.eql(
expectedFrontCardTitle,
`Expected front card title for detector position '${detectorPosition}' to be '${expectedFrontCardTitle}' (got '${actualSplitFrontCardTitle}')`
);
},
async assertDetectorSplitNumberOfBackCards(
detectorPosition: number,
numberOfBackCards: number
expectedNumberOfBackCards: number
) {
expect(
await testSubjects.findAll(
`mlDetector ${detectorPosition} > mlDataSplit > mlSplitCard back`
)
).to.have.length(numberOfBackCards);
const allBackCards = await testSubjects.findAll(
`mlDetector ${detectorPosition} > mlDataSplit > mlSplitCard back`
);
expect(allBackCards).to.have.length(
expectedNumberOfBackCards,
`Expected number of back cards for detector position '${detectorPosition}' to be '${expectedNumberOfBackCards}' (got '${allBackCards.length}')`
);
},
};
}

View file

@ -25,8 +25,10 @@ export function MachineLearningNavigationProvider({
async assertTabsExist(tabTypeSubject: string, areaSubjects: string[]) {
await retry.tryForTime(10000, async () => {
expect(await testSubjects.findAll(`~${tabTypeSubject}`, 3)).to.have.length(
areaSubjects.length
const allTabs = await testSubjects.findAll(`~${tabTypeSubject}`, 3);
expect(allTabs).to.have.length(
areaSubjects.length,
`Expected number of '${tabTypeSubject}' to be '${areaSubjects.length}' (got '${allTabs.length}')`
);
for (const areaSubj of areaSubjects) {
await testSubjects.existOrFail(`~${tabTypeSubject}&~${areaSubj}`, { timeout: 1000 });

View file

@ -54,7 +54,10 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) {
.expect(200)
.then((res: any) => res.body);
expect(statsResponse.transforms).to.have.length(1);
expect(statsResponse.transforms).to.have.length(
1,
`Expected transform stats to contain exactly 1 object (got '${statsResponse.transforms.length}')`
);
return statsResponse.transforms[0];
},

View file

@ -98,7 +98,10 @@ export function TransformTableProvider({ getService }: FtrProviderContext) {
uniqueColumnValues.sort();
// check if the returned unique value matches the supplied filter value
expect(uniqueColumnValues).to.eql(expectedColumnValues);
expect(uniqueColumnValues).to.eql(
expectedColumnValues,
`Expected '${tableSubj}' column values to be '${expectedColumnValues}' (got '${uniqueColumnValues}')`
);
});
}
@ -123,7 +126,12 @@ export function TransformTableProvider({ getService }: FtrProviderContext) {
public async assertTransformRowFields(transformId: string, expectedRow: object) {
const rows = await this.parseTransformTable();
const transformRow = rows.filter((row) => row.id === transformId)[0];
expect(transformRow).to.eql(expectedRow);
expect(transformRow).to.eql(
expectedRow,
`Expected transform row to be '${JSON.stringify(expectedRow)}' (got '${JSON.stringify(
transformRow
)}')`
);
}
public async assertTransformExpandedRow() {

View file

@ -120,20 +120,20 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
});
},
async assertIndexPreview(columns: number, rows: number) {
async assertIndexPreview(columns: number, expectedNumberOfRows: number) {
await retry.tryForTime(2000, async () => {
// get a 2D array of rows and cell values
const rowsData = await this.parseEuiDataGrid('transformIndexPreview');
expect(rowsData).to.length(
rows,
`EuiDataGrid rows should be ${rows} (got ${rowsData.length})`
expectedNumberOfRows,
`EuiDataGrid rows should be '${expectedNumberOfRows}' (got '${rowsData.length}')`
);
rowsData.map((r, i) =>
expect(r).to.length(
columns,
`EuiDataGrid row #${i + 1} column count should be ${columns} (got ${r.length})`
`EuiDataGrid row #${i + 1} column count should be '${columns}' (got '${r.length}')`
)
);
});
@ -185,7 +185,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
'true';
expect(actualCheckState).to.eql(
expectedCheckState,
`Advanced query editor switch check state should be ${expectedCheckState} (got ${actualCheckState})`
`Advanced query editor switch check state should be '${expectedCheckState}' (got '${actualCheckState}')`
);
},
@ -198,7 +198,10 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'transformGroupBySelection > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected group by value to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
});
},
@ -214,7 +217,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
);
expect(actualLabel).to.eql(
expectedLabel,
`Label for group by entry ${index} should be '${expectedLabel}' (got '${actualLabel}')`
`Label for group by entry '${index}' should be '${expectedLabel}' (got '${actualLabel}')`
);
if (expectedIntervalLabel !== undefined) {
@ -223,7 +226,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
);
expect(actualIntervalLabel).to.eql(
expectedIntervalLabel,
`Label for group by entry ${index} should be '${expectedIntervalLabel}' (got '${actualIntervalLabel}')`
`Label for group by entry '${index}' should be '${expectedIntervalLabel}' (got '${actualIntervalLabel}')`
);
}
},
@ -248,7 +251,10 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions(
'transformAggregationSelection > comboBoxInput'
);
expect(comboBoxSelectedOptions).to.eql(expectedIdentifier);
expect(comboBoxSelectedOptions).to.eql(
expectedIdentifier,
`Expected aggregation value to be '${expectedIdentifier}' (got '${comboBoxSelectedOptions}')`
);
});
},
@ -260,7 +266,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
);
expect(actualLabel).to.eql(
expectedLabel,
`Label for aggregation entry ${index} should be '${expectedLabel}' (got '${actualLabel}')`
`Label for aggregation entry '${index}' should be '${expectedLabel}' (got '${actualLabel}')`
);
},
@ -278,7 +284,11 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
// const advancedEditorValue = JSON.parse(advancedEditorString);
// expect(advancedEditorValue).to.eql(expectedValue);
expect(advancedEditorString.split('\n').splice(0, 3)).to.eql(expectedValue);
const splicedAdvancedEditorValue = advancedEditorString.split('\n').splice(0, 3);
expect(splicedAdvancedEditorValue).to.eql(
expectedValue,
`Expected the first editor lines to be '${expectedValue}' (got '${splicedAdvancedEditorValue}')`
);
},
async assertAdvancedPivotEditorSwitchExists() {
@ -291,7 +301,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
'true';
expect(actualCheckState).to.eql(
expectedCheckState,
`Advanced pivot editor switch check state should be ${expectedCheckState} (got ${actualCheckState})`
`Advanced pivot editor switch check state should be '${expectedCheckState}' (got '${actualCheckState}')`
);
},
@ -310,7 +320,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
const actualTransformId = await testSubjects.getAttribute('transformIdInput', 'value');
expect(actualTransformId).to.eql(
expectedValue,
`Transform id input text should be ${expectedValue} (got ${actualTransformId})`
`Transform id input text should be '${expectedValue}' (got '${actualTransformId}')`
);
},
@ -330,7 +340,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
);
expect(actualTransformDescription).to.eql(
expectedValue,
`Transform description input text should be ${expectedValue} (got ${actualTransformDescription})`
`Transform description input text should be '${expectedValue}' (got '${actualTransformDescription}')`
);
},
@ -352,7 +362,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
);
expect(actualDestinationIndex).to.eql(
expectedValue,
`Destination index input text should be ${expectedValue} (got ${actualDestinationIndex})`
`Destination index input text should be '${expectedValue}' (got '${actualDestinationIndex}')`
);
},
@ -373,7 +383,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
'true';
expect(actualCheckState).to.eql(
expectedCheckState,
`Create index pattern switch check state should be ${expectedCheckState} (got ${actualCheckState})`
`Create index pattern switch check state should be '${expectedCheckState}' (got '${actualCheckState}')`
);
},
@ -387,7 +397,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
'true';
expect(actualCheckState).to.eql(
expectedCheckState,
`Continuous mode switch check state should be ${expectedCheckState} (got ${actualCheckState})`
`Continuous mode switch check state should be '${expectedCheckState}' (got '${actualCheckState}')`
);
},
@ -405,7 +415,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
expectedValue,
`Expected 'Create and start' button to be '${
expectedValue ? 'enabled' : 'disabled'
}' (got ${isEnabled ? 'enabled' : 'disabled'}')`
}' (got '${isEnabled ? 'enabled' : 'disabled'}')`
);
},
@ -421,7 +431,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
const isEnabled = await testSubjects.isEnabled('transformWizardCreateButton');
expect(isEnabled).to.eql(
expectedValue,
`Expected 'Create' button to be '${expectedValue ? 'enabled' : 'disabled'}' (got ${
`Expected 'Create' button to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${
isEnabled ? 'enabled' : 'disabled'
}')`
);
@ -441,7 +451,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
expectedValue,
`Expected 'Copy to clipboard' button to be '${
expectedValue ? 'enabled' : 'disabled'
}' (got ${isEnabled ? 'enabled' : 'disabled'}')`
}' (got '${isEnabled ? 'enabled' : 'disabled'}')`
);
},
@ -460,7 +470,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
const isEnabled = await testSubjects.isEnabled('transformWizardStartButton');
expect(isEnabled).to.eql(
expectedValue,
`Expected 'Start' button to be '${expectedValue ? 'enabled' : 'disabled'}' (got ${
`Expected 'Start' button to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${
isEnabled ? 'enabled' : 'disabled'
}')`
);