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

CHECKOUT-3477: Show loading indicator while waiting for iframe to load #429

Merged
merged 4 commits into from
Oct 16, 2018

Conversation

davidchin
Copy link
Contributor

What?

  1. Show a loading indicator while waiting for the iframe to load.
  2. Reconfigure the iframe with styling information if it's reloaded again.

Why?

  1. To tell the shopper that something is happening in the background.
  2. Otherwise, we'd lose the styling configuration.

Testing / Proof

Unit

@bigcommerce/checkout @bigcommerce/payments

Copy link
Contributor

@lpschz lpschz left a 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);
Copy link
Contributor

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();
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor Author

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.');
Copy link
Contributor

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?

Copy link
Contributor Author

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', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

hides

Copy link
Contributor

@lpschz lpschz left a comment

Choose a reason for hiding this comment

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

✅ 👏

@davidchin davidchin merged commit 36ca708 into bigcommerce:embeddable_checkout Oct 16, 2018
@davidchin davidchin deleted the amendments branch October 16, 2018 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants