Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Remove promise from shopping-cart-widget-component.js and add async/await #1153

Merged
merged 3 commits into from
Apr 23, 2018

Conversation

Stojdza
Copy link
Contributor

@Stojdza Stojdza commented Apr 22, 2018

@alisterscott This relates to the comments regarding shopping-cart-widget-component.js in PR #1123

Without promise or async/await tests will pass, but items from shopping cart won't be removed (specs/wp-manage-domains-spec.js).

After adding async/await to component, tests are still passing and shopping cart is empty.

Copy link
Contributor

@alisterscott alisterscott left a comment

Choose a reason for hiding this comment

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

This is looking great 👍
Some minor changes requested below - the cart open selector seems incorrect (and looks like it has been that way for some time)

@@ -10,96 +10,41 @@ export default class ShoppingCartWidgetComponent extends BaseContainer {
super( driver, by.className( 'cart-toggle-button' ) );
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 update this to a css selector whilst your here? (It's an old selector added before we try to use CSS selectors exclusively)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

return await driverHelper.clickWhenClickable(
driver,
by.css( '.cart-toggle-button' ),
explicitWait
Copy link
Contributor

Choose a reason for hiding this comment

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

this explicit wait isn't actually necessary as it's the same as the default value - would you remind removing it? (added before we defaulted the value I believe)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Did the same for driver.


return d.promise;
async displayedOpen() {
return await driverHelper.isElementPresent( this.driver, by.css( 'cart-body' ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

It's great to have one line, but that selector doesn't look like it should have ever worked as it's not a CSS class selector and there's no cart-body element in the DOM. Would you mind updating this to a proper CSS class selector - you could even re-use the selector from the constructor if you wanted to

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 removed displayedOpen(), and in open() method only click to open shopping cart (since in this flow cart is always closed and there is no need to check is it open, I removed check is it open).

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I'm not saying what you did is wrong, I just noticed that by.css( 'cart-body' ) would never had worked I don't think 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be by.css( '.cart-body' )

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I misread it again, I think that makes sense as we shouldn't have to worry about whether it's open 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I understood. But it crossed my mind this would be more optimal solution? It will work both ways.

@alisterscott
Copy link
Contributor

alisterscott commented Apr 23, 2018

This is looking promising - if we can get rid of promises like this in pages/components it should make it easier for the tests to convert over to call these components

Copy link
Contributor

@alisterscott alisterscott left a comment

Choose a reason for hiding this comment

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

🎉 Looks good to me - thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants