Skip to content

Commit

Permalink
Merge branch 'master' into connectors_flyout
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Feb 27, 2020
2 parents ecc7c29 + a8380cf commit 6be1f06
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ export function generateFilters(
filter = existing;
} else {
const tmpIndexPattern = { id: index } as IIndexPattern;

// exists filter special case: fieldname = '_exists' and value = fieldname
const filterType = fieldName === '_exists_' ? FILTERS.EXISTS : FILTERS.PHRASE;
const actualFieldObj = fieldName === '_exists_' ? ({ name: value } as IFieldType) : fieldObj;
filter = buildFilter(
tmpIndexPattern,
fieldObj,
actualFieldObj,
filterType,
negate,
false,
Expand Down
16 changes: 13 additions & 3 deletions test/functional/apps/context/_filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ export default function({ getService, getPageObjects }) {
});
});

it('should be addable via expanded doc table rows', async function() {
it('inclusive filter should be addable via expanded doc table rows', async function() {
await docTable.toggleRowExpanded({ isAnchorRow: true });

await retry.try(async () => {
const anchorDetailsRow = await docTable.getAnchorDetailsRow();
await docTable.addInclusiveFilter(anchorDetailsRow, TEST_ANCHOR_FILTER_FIELD);
await PageObjects.context.waitUntilContextLoadingHasFinished();
// await docTable.toggleRowExpanded({ isAnchorRow: true });
expect(
await filterBar.hasFilter(TEST_ANCHOR_FILTER_FIELD, TEST_ANCHOR_FILTER_VALUE, true)
).to.be(true);
Expand All @@ -58,7 +57,7 @@ export default function({ getService, getPageObjects }) {
});
});

it('should be toggleable via the filter bar', async function() {
it('inclusive filter should be toggleable via the filter bar', async function() {
await filterBar.addFilter(TEST_ANCHOR_FILTER_FIELD, 'IS', TEST_ANCHOR_FILTER_VALUE);
await PageObjects.context.waitUntilContextLoadingHasFinished();
// disable filter
Expand All @@ -76,5 +75,16 @@ export default function({ getService, getPageObjects }) {
expect(hasOnlyFilteredRows).to.be(false);
});
});

it('filter for presence should be addable via expanded doc table rows', async function() {
await docTable.toggleRowExpanded({ isAnchorRow: true });

await retry.try(async () => {
const anchorDetailsRow = await docTable.getAnchorDetailsRow();
await docTable.addExistsFilter(anchorDetailsRow, TEST_ANCHOR_FILTER_FIELD);
await PageObjects.context.waitUntilContextLoadingHasFinished();
expect(await filterBar.hasFilter(TEST_ANCHOR_FILTER_FIELD, 'exists', true)).to.be(true);
});
});
});
}
19 changes: 17 additions & 2 deletions test/functional/services/doc_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,12 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont
const $ = await table.parseDomContent();
const rowLocator = options.isAnchorRow ? '~docTableAnchorRow' : '~docTableRow';
const rows = $.findTestSubjects(rowLocator).toArray();
const fields = rows.map((row: any) =>
return rows.map((row: any) =>
$(row)
.find('[data-test-subj~="docTableField"]')
.toArray()
.map((field: any) => $(field).text())
);
return fields;
}

public async getHeaderFields(): Promise<string[]> {
Expand Down Expand Up @@ -144,6 +143,22 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
}

public async getAddExistsFilterButton(
tableDocViewRow: WebElementWrapper
): Promise<WebElementWrapper> {
return await tableDocViewRow.findByCssSelector(`[data-test-subj~="addExistsFilterButton"]`);
}

public async addExistsFilter(
detailsRow: WebElementWrapper,
fieldName: WebElementWrapper
): Promise<void> {
const tableDocViewRow = await this.getTableDocViewRow(detailsRow, fieldName);
const addInclusiveFilterButton = await this.getAddExistsFilterButton(tableDocViewRow);
await addInclusiveFilterButton.click();
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
}

public async toggleRowExpanded(
options: SelectOptions = { isAnchorRow: false, rowIndex: 0 }
): Promise<WebElementWrapper> {
Expand Down

0 comments on commit 6be1f06

Please sign in to comment.