-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Test: element filter expressions #33908
Conversation
Pinging @elastic/kibana-canvas |
aa3b459
to
7fb2fcb
Compare
💚 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' |
There was a problem hiding this comment.
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(|)
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
* test: add more filter elements * test: add getGlobalFilterExpression test * chore: only iterate filter elements once
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.