Skip to content

Commit

Permalink
[Maps] unskip 'embed in dashboard' functional test (#141289)
Browse files Browse the repository at this point in the history
* [Maps] unskip 'embed in dashboard' functional test

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Nick Peihl <[email protected]>
  • Loading branch information
3 people authored Sep 23, 2022
1 parent e936a92 commit d23aa31
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
61 changes: 32 additions & 29 deletions test/functional/services/filter_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,29 +113,20 @@ export class FilterBarService extends FtrService {
return Promise.all(filters.map((filter) => filter.getVisibleText()));
}

/**
* Adds a filter to the filter bar.
*
* @param {string} field The name of the field the filter should be applied for.
* @param {string} operator A valid operator for that fields, e.g. "is one of", "is", "exists", etc.
* @param {string[]|string} values The remaining parameters are the values passed into the individual
* value input fields, i.e. the third parameter into the first input field, the fourth into the second, etc.
* Each value itself can be an array, in case you want to enter multiple values into one field (e.g. for "is one of"):
* @example
* // Add a plain single value
* filterBar.addFilter('country', 'is', 'NL');
* // Add an exists filter
* filterBar.addFilter('country', 'exists');
* // Add a range filter for a numeric field
* filterBar.addFilter('bytes', 'is between', '500', '1000');
* // Add a filter containing multiple values
* filterBar.addFilter('extension', 'is one of', ['jpg', 'png']);
*/
public async addFilter(field: string, operator: string, ...values: any): Promise<void> {
public async addFilterAndSelectDataView(
dataViewTitle: string | null,
field: string,
operator: string,
...values: any
): Promise<void> {
await this.retry.tryForTime(this.defaultTryTimeout * 2, async () => {
await this.testSubjects.click('addFilter');
await this.testSubjects.existOrFail('addFilterPopover');

if (dataViewTitle) {
await this.comboBox.set('filterIndexPatternsSelect', dataViewTitle);
}

await this.comboBox.set('filterFieldSuggestionList', field);
await this.comboBox.set('filterOperatorList', operator);
const params = await this.testSubjects.find('filterParams');
Expand Down Expand Up @@ -166,6 +157,28 @@ export class FilterBarService extends FtrService {
await this.header.awaitGlobalLoadingIndicatorHidden();
}

/**
* Adds a filter to the filter bar.
*
* @param {string} field The name of the field the filter should be applied for.
* @param {string} operator A valid operator for that fields, e.g. "is one of", "is", "exists", etc.
* @param {string[]|string} values The remaining parameters are the values passed into the individual
* value input fields, i.e. the third parameter into the first input field, the fourth into the second, etc.
* Each value itself can be an array, in case you want to enter multiple values into one field (e.g. for "is one of"):
* @example
* // Add a plain single value
* filterBar.addFilter('country', 'is', 'NL');
* // Add an exists filter
* filterBar.addFilter('country', 'exists');
* // Add a range filter for a numeric field
* filterBar.addFilter('bytes', 'is between', '500', '1000');
* // Add a filter containing multiple values
* filterBar.addFilter('extension', 'is one of', ['jpg', 'png']);
*/
public async addFilter(field: string, operator: string, ...values: any): Promise<void> {
await this.addFilterAndSelectDataView(null, field, operator, ...values);
}

/**
* Activates filter editing
* @param key field name
Expand Down Expand Up @@ -212,14 +225,4 @@ export class FilterBarService extends FtrService {
await this.ensureFieldEditorModalIsClosed();
return indexPatterns.trim().split('\n').join(',');
}

/**
* Adds new index pattern filter
* @param indexPatternTitle
*/
public async selectIndexPattern(indexPatternTitle: string): Promise<void> {
await this.testSubjects.click('addFilter');
await this.comboBox.set('filterIndexPatternsSelect', indexPatternTitle);
await this.testSubjects.click('addFilter');
}
}
18 changes: 8 additions & 10 deletions x-pack/test/functional/apps/maps/group2/embeddable/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export default function ({ getPageObjects, getService }) {
const security = getService('security');
const testSubjects = getService('testSubjects');

// Failing: See https://github.com/elastic/kibana/issues/140241
describe.skip('embed in dashboard', () => {
describe('embed in dashboard', () => {
before(async () => {
await security.testUser.setRoles(
[
Expand Down Expand Up @@ -100,16 +99,15 @@ export default function ({ getPageObjects, getService }) {
});

it('should apply new container state (time, query, filters) to embeddable', async () => {
await filterBar.selectIndexPattern('logstash-*');
await filterBar.addFilter('machine.os', 'is', 'win 8');
await filterBar.addFilterAndSelectDataView('logstash-*', 'machine.os', 'is', 'win 8');
await PageObjects.maps.waitForLayersToLoad();

// retry is fix for flaky test https://github.com/elastic/kibana/issues/113993
// timing issue where click for addFilter opens filter pill created above instead of clicking addFilter
await retry.try(async () => {
await filterBar.selectIndexPattern('meta_for_geo_shapes*');
await filterBar.addFilter('shape_name', 'is', 'alpha'); // runtime fields do not have autocomplete
});
await filterBar.addFilterAndSelectDataView(
'meta_for_geo_shapes*',
'shape_name',
'is',
'alpha'
);
await PageObjects.maps.waitForLayersToLoad();

const { rawResponse: gridResponse } = await PageObjects.maps.getResponseFromDashboardPanel(
Expand Down

0 comments on commit d23aa31

Please sign in to comment.