-
Notifications
You must be signed in to change notification settings - Fork 75
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(date): work around missing shadow piercing element in e2e test #1103
Conversation
@jcfranco ok, this was very involved but I think I got it passing in travis 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.
Awesome!
const changedEvent = await page.spyOnEvent("calciteDateChange"); | ||
await input.callMethod("setFocus"); | ||
// have to wait for transition | ||
await new Promise((res) => setTimeout(() => res(true), 200)); |
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.
Nitpick: You can use await page.waitFor(200);
to simplify this.
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.
isn't waitFor deprecated? Or have I imagined seeing that 10,000 times in the logs? 😆
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.
Yes, but the types haven't been updated for us to use waitForTimeout
(#1044).
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.
👍 nice
Just to leave a paper trail for any other devs that encounter travis failing on const input = (
await page.waitForFunction(() =>
document.querySelector("calcite-date").shadowRoot.querySelector("calcite-input input")
)
).asElement();
await input.focus(); Basically get an element handle by evaluating a function and returning an actual querySelector on the real shadow root. We should probably make this a test util if it comes up again. |
Summary
Tests sometimes fail with missing element when you query for an element inside a shadow dom boundary. This only happens on travis. All other environments work fine. For now, I'm just tabbing to the input and executing keyboard commands on the page instead.