feat: Accept single filter function rather than dict #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CP-2790
Updates made in #8 added the ability to provide filter functions to conditionally exclude certain trait values from being used during selector generation. In a nod to performance these were structured to only call a filter function if the trait being considered exactly matched the one under consideration (exact attribute name match, usually). However, it is desired that filters be able to supply a regex to match traits (e.g. allow filtering multiple attributes with the same criteria) which necessitates a change in contract to supply a single filter function that encapsulates all the necessary filtering logic. This will have a small performance impact on selector generation since every single trait will need to call into this filter function, but impact can be mitigated by aggressive use of the supplied
type
andkey
params as well as appropriate caching/memoization when crafting the filter param.Note: I had originally planned to handle caching internally here (since we already are doing so for overall selector gen and isUnique checks) but doing so required pulling in a lot of knowledge of how filters are being structured for our specific use case. I backed that out to reduce coupling and believe caching can be handled as efficiently/elegantly by the caller, but if anyone sees a superior approach I'd be interested to hear it since this lib has significant performance implications for UICov.
Once this merges there will be follow-on changes in
cypress-services
side to update this dep and build an appropriate filter function off of configBefore
After