[ML] Functional tests - stabilize anomaly explorer tests (#122247) (#122317)

This PR stabilizes the anomaly explorer tests for adding a swim lane to a dashboard by validating the dashboard table row count after filtering.

Co-authored-by: Robert Oskamp <robert.oskamp@elastic.co>
This commit is contained in:
Kibana Machine 2022-01-05 06:06:43 -05:00 committed by GitHub
parent 1c87eee95c
commit 4b2c69ef50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 9 deletions

View file

@ -86,6 +86,9 @@ export const AddToDashboardControl: FC<AddToDashboardControlProps> = ({
pagination={true}
sorting={true}
data-test-subj={`mlDashboardSelectionTable${isLoading ? ' loading' : ' loaded'}`}
rowProps={(item) => ({
'data-test-subj': `mlDashboardSelectionTableRow row-${item.id}`,
})}
/>
</EuiFormRow>
</EuiModalBody>

View file

@ -63,8 +63,7 @@ export default function ({ getService }: FtrProviderContext) {
const ml = getService('ml');
const elasticChart = getService('elasticChart');
// FLAKY: https://github.com/elastic/kibana/issues/118584
describe.skip('anomaly explorer', function () {
describe('anomaly explorer', function () {
this.tags(['mlqa']);
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');

View file

@ -121,13 +121,21 @@ export function MachineLearningAnomalyExplorerProvider({
});
},
async filterDashboardSearchWithSearchString(filter: string) {
await this.waitForDashboardsToLoad();
const searchBarInput = await testSubjects.find('mlDashboardsSearchBox');
await searchBarInput.clearValueWithKeyboard();
await searchBarInput.type(filter);
await this.assertDashboardSearchInputValue(filter);
await this.waitForDashboardsToLoad();
async filterDashboardSearchWithSearchString(filter: string, expectedRowCount: number = 1) {
await retry.tryForTime(20 * 1000, async () => {
await this.waitForDashboardsToLoad();
const searchBarInput = await testSubjects.find('mlDashboardsSearchBox');
await searchBarInput.clearValueWithKeyboard();
await searchBarInput.type(filter);
await this.assertDashboardSearchInputValue(filter);
await this.waitForDashboardsToLoad();
const dashboardRows = await testSubjects.findAll('~mlDashboardSelectionTableRow', 2000);
expect(dashboardRows.length).to.eql(
expectedRowCount,
`Dashboard table should have ${expectedRowCount} rows, got ${dashboardRows.length}`
);
});
},
async assertDashboardSearchInputValue(expectedSearchValue: string) {