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

test(date): work around missing shadow piercing element in e2e test #1103

Merged
merged 6 commits into from
Oct 9, 2020

Conversation

paulcpederson
Copy link
Member

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.

@paulcpederson paulcpederson requested a review from a team as a code owner October 9, 2020 19:32
@paulcpederson
Copy link
Member Author

@jcfranco ok, this was very involved but I think I got it passing in travis now.

Copy link
Member

@jcfranco jcfranco left a 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));
Copy link
Member

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.

Copy link
Member Author

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? 😆

Copy link
Member

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).

Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice

@paulcpederson
Copy link
Member Author

Just to leave a paper trail for any other devs that encounter travis failing on >>> selection, this was logged on stencil e2e a while back ionic-team/stencil#1530, it is actually due to missing functionality in puppeteer: puppeteer/puppeteer#858 , this suggests you use something like:

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.

@paulcpederson paulcpederson merged commit 6fb9349 into master Oct 9, 2020
@paulcpederson paulcpederson deleted the paulcpederson/date-test-fix branch October 9, 2020 21:29
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

Successfully merging this pull request may close these issues.

None yet

3 participants