Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Assert Lens show chart after navigation from Index data visualizer #124579

Merged
merged 2 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
farequoteLuceneSearchTestData,
sampleLogTestData,
} from './index_test_data';
import { ML_JOB_FIELD_TYPES } from '../../../../../plugins/ml/common/constants/field_types';

export default function ({ getPageObject, getService }: FtrProviderContext) {
const headerPage = getPageObject('header');
Expand Down Expand Up @@ -220,5 +221,51 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
});
runTests(sampleLogTestData);
});

describe('with view in lens action ', function () {
const testData = farequoteDataViewTestData;
// Run tests on full ft_module_sample_logs index.
it(`${testData.suiteTitle} loads the data visualizer selector page`, async () => {
// Start navigation from the base of the ML app.
await ml.navigation.navigateToMl();
await ml.navigation.navigateToDataVisualizer();
});

it(`${testData.suiteTitle} loads lens charts`, async () => {
await ml.testExecution.logTestStep(
`${testData.suiteTitle} loads the saved search selection page`
);
await ml.dataVisualizer.navigateToIndexPatternSelection();

await ml.testExecution.logTestStep(
`${testData.suiteTitle} loads the index data visualizer page`
);
await ml.jobSourceSelection.selectSourceForIndexBasedDataVisualizer(
testData.sourceIndexOrSavedSearch
);

await ml.testExecution.logTestStep(`${testData.suiteTitle} loads data for full time range`);
await ml.dataVisualizerIndexBased.clickUseFullDataButton(
testData.expected.totalDocCountFormatted
);
await headerPage.waitUntilLoadingHasFinished();

await ml.testExecution.logTestStep('navigate to Lens');
const lensMetricField = testData.expected.metricFields![0];

if (lensMetricField) {
await ml.dataVisualizerTable.assertLensActionShowChart(lensMetricField.fieldName);
await ml.navigation.browserBackTo('dataVisualizerTable');
}
const lensNonMetricField = testData.expected.nonMetricFields?.find(
(f) => f.type === ML_JOB_FIELD_TYPES.KEYWORD
);

if (lensNonMetricField) {
await ml.dataVisualizerTable.assertLensActionShowChart(lensNonMetricField.fieldName);
await ml.navigation.browserBackTo('dataVisualizerTable');
}
});
});
});
}
11 changes: 11 additions & 0 deletions x-pack/test/functional/services/ml/data_visualizer_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,17 @@ export function MachineLearningDataVisualizerTableProvider(
}
}

public async assertLensActionShowChart(fieldName: string) {
await retry.tryForTime(30 * 1000, async () => {
await testSubjects.clickWhenNotDisabled(
this.rowSelector(fieldName, 'dataVisualizerActionViewInLensButton')
);
await testSubjects.existOrFail('lnsVisualizationContainer', {
timeout: 15 * 1000,
});
});
}

public async ensureNumRowsPerPage(n: 10 | 25 | 50) {
const paginationButton = 'dataVisualizerTable > tablePaginationPopoverButton';
await retry.tryForTime(10000, async () => {
Expand Down
8 changes: 7 additions & 1 deletion x-pack/test/functional/services/ml/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function MachineLearningNavigationProvider({
const browser = getService('browser');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common']);
const PageObjects = getPageObjects(['common', 'header']);

return {
async navigateToMl() {
Expand Down Expand Up @@ -264,5 +264,11 @@ export function MachineLearningNavigationProvider({
`Expected the current URL "${currentUrl}" to not include ${expectedUrlPart}`
);
},

async browserBackTo(backTestSubj: string) {
await browser.goBack();
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.existOrFail(backTestSubj, { timeout: 10 * 1000 });
},
};
}