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

spectator.query() with root: true does not work for DOMSelector selectors (only string selectors) #273

Closed
Coffee-Tea opened this issue Feb 21, 2020 · 1 comment

Comments

@Coffee-Tea
Copy link
Contributor

Coffee-Tea commented Feb 21, 2020

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

There is a way to find element by string selector in the whole DOM document using this:
spectator.query('.some-selector', { root: true })
This was suggested here #87 and added in version 4.0.0.

It's not working if you use DOMSelector instance instead of string selector
spectator.query(byAltText('some text'), { root: true })

Expected behavior

Would be great to have the similar logic for DOMSelector selectors as we have with string selectors.
spectator.query(byAltText('some text'), { root: true })
should return find element with alt text 'some text' through the whole document.

Minimal reproduction of the problem with instructions

When testing mat-dialog or cdk-experimental/dialog you would like to query something rendered within with DOMSelector you can't do that with spectator. You can use only string selector which is actually not always nice way.

What is the motivation / use case for changing the behavior?

Need to get some elements in OverlayContainer using spectator.query with DOMSelector selectors.

Environment


Angular version: 7.2.0


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX 10.15.1
- Platform: Mac 10.14.6

Others:

Maybe it would be better to replace `root: boolean` param by `rootElement: HTMLElement | Document` param to have more flexible way to specify some elements as root for such specific cases as testing stuff rendered in CDK Overlay.
@Coffee-Tea Coffee-Tea changed the title spectator.query() with root: true does spectator.query() with root: true does not work for DOMSelector selectors (only string selectors) Feb 21, 2020
@Coffee-Tea
Copy link
Contributor Author

I would raise PR with smth like this

image

Gonna raise it probably tomorrow or on Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants