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

Test: element filter expressions #33908

Merged
merged 3 commits into from
Mar 28, 2019

Conversation

w33ble
Copy link
Contributor

@w33ble w33ble commented Mar 27, 2019

Since I need to change how this function works a bit for filter grouping, I thought it would be helpful to add a test for it.

Also, I refactored it a bit so the element list would not need to be iterated twice, since I now had a test to confirm the functionality did not change.

@w33ble w33ble added review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.0.0 v7.2.0 labels Mar 27, 2019
@w33ble w33ble requested a review from monfera March 27, 2019 00:10
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-canvas

@w33ble w33ble requested a review from a team as a code owner March 27, 2019 00:10
@w33ble w33ble force-pushed the test/element-filter-expressions branch from aa3b459 to 7fb2fcb Compare March 27, 2019 00:11
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

it('gets filters from all elements', () => {
const filters = selector.getGlobalFilterExpression(state);
expect(filters).to.equal(
'exactly value="beats" column="project" | timefilter column=@timestamp from=now-24h to=now'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if two elements have the same filters, then that filter string will be duped in the globalFilterExpression. Is there any value in deduping the array before doing the .join(|)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, but there's also no harm in just including it twice, just a small increase in expression execution time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crob611 I should add, if you think it's worth doing, open an issue about it. It wouldn't be hard to add, but since this PR isn't a functional change, I'm not going to do it here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I imagine the cost of deduping every time would outweigh any gains it would get us in the scenarios where filters are duplicated.

Copy link
Contributor

@crob611 crob611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@w33ble w33ble merged commit 65a5d52 into elastic:master Mar 28, 2019
w33ble added a commit to w33ble/kibana that referenced this pull request Mar 28, 2019
* test: add more filter elements

* test: add getGlobalFilterExpression test

* chore: only iterate filter elements once
w33ble added a commit that referenced this pull request Mar 28, 2019
* test: add more filter elements

* test: add getGlobalFilterExpression test

* chore: only iterate filter elements once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants