Skip to content

Commit

Permalink
[ML] Functional tests - stabilize anomaly explorer tests (#122247)
Browse files Browse the repository at this point in the history
This PR stabilizes the anomaly explorer tests for adding a swim lane to a dashboard by validating the dashboard table row count after filtering.
  • Loading branch information
pheyos authored Jan 5, 2022
1 parent 65475ef commit 1a886c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
22 changes: 15 additions & 7 deletions x-pack/test/functional/services/ml/anomaly_explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1a886c2

Please sign in to comment.