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
feat(web): chainable PageElements
#1864
Conversation
To enable advanced filtering patters, `PageElements.located(..)` call will no longer return a `PageElements` object. Instead, it now returns a `MetaList\<PageElement\>`, which still resolves to `PageElement[]`, but allows for additionally allows for chaining using the `.of(parent)` call. This change should not require any changes to client code. However, any custom questions, interactions or tasks that relied on receiving a parameter of type `PageElements` should expect a `MetaList\<PageElement\>` instead.
Hey @viper3400, I'm expanding PEQL to allow for a new query pattern. Would you mind taking a look? |
MetaList<PageElement>
PageElements
with a more flexible MetaList<PageElement>
PageElements
with a more flexible MetaList<PageElement>
PageElements
with MetaList<PageElement>
Hi @jan-molak I'm currently in holidays so let me give you just some initial feedback without diving to deep into the code. First, I always liked the idea of this "smart chaining" in Serenity/JS. But I always felt a bit uncomfortable with the introduction of this Explanation of https://serenity-js.org/api/core/interface/MetaQuestion/ always sounded a bit stiff to me. Okay, back to this PR. What comes into my mind: We should have some clear examples what the goal and the possibilities of this chaining is. I mean examples and some explanation at serentiy-js.org, not just somehow hidden in some test specs in the repo. Then what you say is: "It should not require code changes, but anyway, it does." ;) If I think of our business code bases, this will mean some hundred lines of code changes for typed returns as well: // from
const ShoppingLists: PageElements = () => ...
// to
const ShoppingLists: MetaList<PageElement> = () => ... So, according to semantic versioning this would be a change for Serenity/JS 4 ? Maybe we should start thinking of providing some https://www.npmjs.com/package/jscodeshift support or something similar? While I appreciate change and progress, I also know code bases that have to be maintained and it's hard to stroll through release notes hunting down breaking changes, when you have not the possibility to stay up to date with each and every version update, (I still struggle with the switch to WIDO8, btw.) |
Sure thing, I hope you have a nice time off!
Over time, targets became questions themselves, and the model became better aligned. Meta-questions were meant to be "questions that can be parameterised with other questions", but now that I think about it more, I wonder if this distinction still holds. Warning: Brain dump commencing. Does it make sense to have a question without its context? A PageElement is always resolved in the context of some root page element. Text, Value, Attribute and so on are always "parameterised" with a page element that's also a question. So would it be fair to say that every question can be parameterised with a question, and therefore every question is a meta-question and so the distinction is no longer necessary? I wonder how this would work with questions like
Yeah, it might be trying to tell us something :)
Yeah, agreed 100%. In fact, I'm re-working the handbook as we speak. Do you feel like there is a natural place for those examples in the docs already? Should we extend the article on PEQL, or do we need something different?
Hmm... yeah. You might be right here.
Yeah, I focused on folks using
I can do it in a backwards-compatible way. Good catch and thank you!
This could be useful, but I have no capacity to research that. If you have any time to do it that would be awesome!
Yup, point taken.
Oh, is this something that's WDIO8-specific, or do we have any bugs in S/JS? |
thanks to @viper3400 for code review and the suggestion
PageElements
with MetaList<PageElement>
PageElements
chaining
PageElements
chainingPageElements
PageElements
PageElements
This change enables
PageElements
to offer more advanced chaining patternsand DOES NOT require any modifications to the existing client code.
PageElements
now allow for defining the container element at runtime, separately from defining the filtering chain.For example:
PageElements
now also allows for using pre-composed filter chains, like the one above, in.where
clauses: