-
Notifications
You must be signed in to change notification settings - Fork 216
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
CHECKOUT-3477: Show loading indicator while waiting for iframe to load #429
CHECKOUT-3477: Show loading indicator while waiting for iframe to load #429
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.
Great work! Just some minor small comments
|
||
messageListener.trigger({ type: EmbeddedCheckoutEventType.FrameLoaded }); | ||
|
||
expect(messagePoster.post).toHaveBeenCalledTimes(2); |
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.
should you check the arguments to make sure it reconfigured styles?
it('toggles loading indicator', async () => { | ||
await embeddedCheckout.attach(); | ||
|
||
expect(loadingIndicator.show).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.
can you do something like, it toggles loading indicator after checkout has loaded?
expect(loadingIndicator.show).toHaveBeenCalled();
expect(loadingIndicator.hide).not.toHaveBeenCalled();
frameLoaded()
expect(loadingIndicator.hide).toHaveBeenCalled();
you could also check it hides if frame failed to load.
|
||
const ROTATION_ANIMATION = 'embedded-checkout-loading-indicator-rotation'; | ||
|
||
export default class LoadingIndicator { |
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 have a few doubts with the naming, maybe this could be LoadingOverlay? Indicator to me sounds like just the icon. 🍹
_container
could become _overlay
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 understand where you coming from. But in this case, the indicator is in fact the spinner icon that gets shown to the shopper when the page is initially loaded. So I think it is okay to keep it as "indicator"?
} | ||
|
||
if (!this._container.parentNode) { | ||
throw new Error('Unable to show the loading indicator because it is not attached to the DOM.'); |
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.
would this only happen if parentId
is not provided?
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.
Good question. I might not even need this check. I'll double check.
expect(() => indicator.show('invalid_container')).toThrow(); | ||
}); | ||
|
||
it('hide loading indicator', () => { |
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.
hides
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.
✅ 👏
What?
Why?
Testing / Proof
Unit
@bigcommerce/checkout @bigcommerce/payments