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

[Api][Address] Browsing AddressBook #11914

Merged
merged 5 commits into from Oct 8, 2020
Merged

Conversation

Tomanhez
Copy link
Contributor

@Tomanhez Tomanhez commented Oct 7, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
License MIT

@Tomanhez Tomanhez requested a review from a team as a code owner October 7, 2020 06:35
Copy link
Contributor

@AdamKasp AdamKasp left a comment

Choose a reason for hiding this comment

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

generally I have problem with scenario tagged @javascript, it looks like UI feature, and IMO we shouldn't cover it with API especially when you added step And my billing address is fulfilled automatically after filling field which is matching to field from my address book's address in API we don't have behaviour like automatically do sth it should be call to addresses/index and the UI should fill address with data from addressbook, But of course i am open to discussion.

public function thisAddressShouldBeAssignedTo(string $fullName): void
{
/** @var AddressInterface $address */
$address = $this->sharedStorage->get('address_assigned_to_' . $fullName);
Copy link
Contributor

Choose a reason for hiding this comment

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

fullName has space between first and last name IMO you shouldn't have the key in shared storage with spaces,
address_assigned_to_Joe Doe ith looks bad :(

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 you aright, but $fullName is behind the scene, I can convert it to loverCase and add padding here and in places when I must get it by customer name, but for me its unnecessary confusion.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can use StringInflector class, just add there an method

public static function nameToSnakeCase(string $value): string
    {
        return (string) u($value)->snake();
    }
```

src/Sylius/Behat/Context/Ui/Shop/AddressBookContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Resources/config/services/api.xml Outdated Show resolved Hide resolved
@@ -6,15 +6,15 @@ Feature: Viewing my address book

Background:
Given the store operates on a single channel in "United States"
And I am a logged in customer
And I am a logged in customer with name "Lucifer Morningstar"
Copy link
Member

Choose a reason for hiding this comment

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

Why did you need to change that?

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 changed it, because IMO scenario Inability to view the addresses of other customers is not clearly and which is customer about in step this address should be assigned to "Lucifer Morningstar", we have added address with this name for this customer, but this customer is not "Lucifer Morningstar" but random named

src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php Outdated Show resolved Hide resolved
@Tomanhez
Copy link
Contributor Author

Tomanhez commented Oct 7, 2020

generally I have problem with scenario tagged @javascript, it looks like UI feature, and IMO we shouldn't cover it with API especially when you added step And my billing address is fulfilled automatically after filling field which is matching to field from my address book's address in API we don't have behaviour like automatically do sth it should be call to addresses/index and the UI should fill address with data from addressbook, But of course i am open to discussion.

I think that few tests for addressBook like choosing_billing_and_shipping_address_from_address_book.feature are wrote not perfect for UI, because lots is happening automatically and is based on autocomplete from web browser, I add few new steps for greater clarity and of course for improve to work with @api tests. I know that many of these behawior is hard to recode on api cases but, IMO its only what i can do. Other way is write new tests for API behawior instead of present tests.

@GSadee
Copy link
Member

GSadee commented Oct 7, 2020

generally I have problem with scenario tagged @javascript, it looks like UI feature, and IMO we shouldn't cover it with API especially when you added step And my billing address is fulfilled automatically after filling field which is matching to field from my address book's address in API we don't have behaviour like automatically do sth it should be call to addresses/index and the UI should fill address with data from addressbook, But of course i am open to discussion.

I think that few tests for addressBook like choosing_billing_and_shipping_address_from_address_book.feature are wrote not perfect for UI, because lots is happening automatically and is based on autocomplete from web browser, I add few new steps for greater clarity and of course for improve to work with @api tests. I know that many of these behawior is hard to recode on api cases but, IMO its only what i can do. Other way is write new tests for API behawior instead of present tests.

I'm not fully convinced but we could implement the existing scenarios without adding these unneeded (unclear for me) new steps. The proper behaviour for getting address from customer's address book could be implemented in the existing steps in API context.

@AdamKasp AdamKasp merged commit 91f26cd into Sylius:master Oct 8, 2020
@AdamKasp
Copy link
Contributor

AdamKasp commented Oct 8, 2020

Thanks, Tomasz! 🎉

Comment on lines +1107 to +1120
if (
$address['firstName'] === $addressToCompare->getFirstName() &&
$address['lastName'] === $addressToCompare->getLastName() &&
$address['countryCode'] === $addressToCompare->getCountryCode() &&
$address['street'] === $addressToCompare->getStreet() &&
$address['city'] === $addressToCompare->getCity() &&
$address['postcode'] === $addressToCompare->getPostcode() &&
($addressToCompare->getProvinceName() !== null && isset($address['provinceName'])) ?
$address['provinceName'] === $addressToCompare->getProvinceName() : true
) {
return true;
}

return false;
Copy link
Member

Choose a reason for hiding this comment

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

Could be simplified to one return

GSadee added a commit that referenced this pull request Oct 8, 2020
This PR was merged into the 1.9-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | partially #11914 ( this needs to be merged first)
| License         | MIT

Commits
-------

b566cd5 add api delete address book
d0d71cc fixed small issues in PR
ef7b2fd merged scenarios in one
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

4 participants