-
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
fix: setFocus methods should wait for the component to be loaded #5749
Conversation
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.
🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶
🕶😎🕶🕶🕶🕶😎😎🕶🕶🕶😎😎🕶🕶😎🕶🕶😎🕶😎😎😎🕶😎🕶🕶🕶😎🕶😎😎😎😎🕶
🕶😎🕶🕶🕶😎🕶🕶😎🕶😎🕶🕶😎🕶😎🕶😎🕶🕶🕶😎🕶🕶😎😎🕶🕶😎🕶😎🕶🕶🕶🕶
🕶😎🕶🕶🕶😎🕶🕶😎🕶😎🕶🕶😎🕶😎😎🕶🕶🕶🕶😎🕶🕶😎🕶😎🕶😎🕶😎🕶😎😎🕶
🕶😎🕶🕶🕶😎🕶🕶😎🕶😎🕶🕶😎🕶😎🕶😎🕶🕶🕶😎🕶🕶😎🕶🕶😎😎🕶😎🕶🕶😎🕶
🕶😎😎😎🕶🕶😎😎🕶🕶🕶😎😎🕶🕶😎🕶🕶😎🕶😎😎😎🕶😎🕶🕶🕶😎🕶😎😎😎😎🕶
🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶
🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶
🕶😎😎😎😎🕶🕶😎😎🕶🕶🕶😎😎🕶🕶😎😎😎🕶🕶😎🕶
🕶😎🕶🕶🕶🕶😎🕶🕶😎🕶😎🕶🕶😎🕶😎🕶🕶😎🕶😎🕶
🕶😎🕶😎😎🕶😎🕶🕶😎🕶😎🕶🕶😎🕶😎🕶🕶😎🕶😎🕶
🕶😎🕶🕶😎🕶😎🕶🕶😎🕶😎🕶🕶😎🕶😎🕶🕶😎🕶🕶🕶
🕶😎😎😎😎🕶🕶😎😎🕶🕶🕶😎😎🕶🕶😎😎😎🕶🕶😎🕶
🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶🕶
# Conflicts: # src/components/filter/filter.tsx # src/components/pick-list/pick-list.tsx
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!
WRT components using setFocus
, as long as we have a follow-up issue and convention note to ensure we use the loadable util consistently, I think it's fine for the focusable
test helper to not cover it since it's a Stencil lifecycle bug. It'd be really complex to test it consistently and would be out of scope regarding our test coverage.
src/utils/loadable.spec.ts
Outdated
loaded: false, | ||
promise: null | ||
}; | ||
const fakeComponent: any = { |
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.
I really like how this test is showing how the modules work together. If not too complex, we could do the same for other spec tests.
From that perspective, I think we could simplify the test and have it focus on its use case:
const afterDidLoad = fakeComponent.resolvesAfterDidLoad();
// assert afterDidLoad not resolved
fakeComponent.componentWillLoad();
// assert afterDidLoad not resolved
fakeComponent.componentDidLoad();
// assert afterDidLoad resolved
Alternatively, the individual utils could be tested as well:
// assert componentLoaded(fakeComponent) not resolved
setUpLoadableComponent(fakeComponent);
// assert componentLoaded(fakeComponent) not resolved
componentLoaded(fakeComponent);
// assert componentLoaded(fakeComponent) resolved
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.
I really like how this test is showing how the modules work together. If not too complex, we could do the same for other spec tests.
Can we get a followup issue for this? 👍
// assert afterDidLoad not resolved
How can I assert the promise is not resolved? There's not a property on the promise. Is there some util for 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.
Here's one, untested, idea:
const afterLoad = jest.fn();
const load = componentLoaded(fakeComponent).then(afterLoad);
await waitForAnimationFrame();
assert(afterLoad).not.toHaveBeenCalled();
setUpLoadableComponent(fakeComponent);
await waitForAnimationFrame();
assert(afterLoad).not.toHaveBeenCalled();
componentLoaded(fakeComponent);
await waitForAnimationFrame();
assert(afterLoad).toHaveBeenCalled();
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.
done!
# Conflicts: # src/components/popover/popover.tsx
@jcfranco this one good to merge? |
fix: setFocus methods should wait for the component to be loaded