Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Behat] Refactor API clients#13832

Merged
Zales0123 merged 5 commits into
Sylius:masterfrom
AdamKasp:refactor-behat-api-clients
Apr 13, 2022
Merged

[Behat] Refactor API clients#13832
Zales0123 merged 5 commits into
Sylius:masterfrom
AdamKasp:refactor-behat-api-clients

Conversation

@AdamKasp
Copy link
Copy Markdown
Contributor

@AdamKasp AdamKasp commented Apr 6, 2022

Q A
Branch? master
Bug fix? no
BC breaks?
License MIT

With many API clients, we have problems with getting the last response, now we have only 2 clients: shop and admin.

@AdamKasp AdamKasp added Behat Issues and PRs aimed at improving Behat usage. API APIs related issues and PRs. labels Apr 6, 2022
@AdamKasp AdamKasp requested a review from a team as a code owner April 6, 2022 13:36
Comment thread src/Sylius/Behat/Context/Api/Admin/ManagingPaymentsContext.php Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice to be able to spot it, but perhaps we should extract separate context for it? May be done in separate PR

@AdamKasp AdamKasp force-pushed the refactor-behat-api-clients branch from a3f5e35 to 69834bd Compare April 11, 2022 06:29
@GSadee GSadee force-pushed the refactor-behat-api-clients branch from 69834bd to dac2677 Compare April 12, 2022 10:52
@GSadee GSadee changed the title [Behats] Refactor api clients [Behat] Refactor API clients Apr 12, 2022
Comment thread src/Sylius/Behat/Context/Api/Admin/ManagingZonesContext.php Outdated
@GSadee GSadee force-pushed the refactor-behat-api-clients branch 2 times, most recently from e6250ea to 985ad9a Compare April 13, 2022 10:49
@GSadee GSadee force-pushed the refactor-behat-api-clients branch from 985ad9a to 56dc7af Compare April 13, 2022 11:56
Copy link
Copy Markdown
Contributor

@Zales0123 Zales0123 left a comment

Choose a reason for hiding this comment

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

Seems as a good step forward regarding DX 👍

public function iBrowseExchangeRatesOfTheStore(): void
{
$this->client->index();
$this->client->index('exchange-rates',);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Extra comma, here and below 💃

public function theFirstProductOnTheListShouldHave(string $field, string $value): void
{
$products = $this->responseChecker->getCollection($this->client->getLastResponse());
$response = $this->sharedStorage->has('response') ? $this->sharedStorage->get('response') : $this->client->getLastResponse();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's 3 times in the class, could be extracted to the private function

<argument type="service" id="test.client" />
<argument type="service" id="sylius.behat.shared_storage" />
<argument>%sylius.api.authorization_header%</argument>
</service>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes in this file are just beautiful 🎉

@Zales0123 Zales0123 merged commit 75ef38d into Sylius:master Apr 13, 2022
@Zales0123
Copy link
Copy Markdown
Contributor

Thank you Adam & Grzegorz! 🎉

lchrusciel added a commit that referenced this pull request Apr 14, 2022
… a separate class (GSadee)

This PR was merged into the 1.10-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | after #13832
| License         | MIT

To avoid potential problems with defining resources names using API client, I've extracted available resources to one class in Behat.

<!--
 - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

864e61c [Behat][API] Extract resources names from contexts to a separate class
f16d93c [Behat][API] Extract providing last response to private method in ManagingProductsContext
GSadee added a commit that referenced this pull request Oct 10, 2022
…Milek)

This PR was merged into the 1.12 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.12 <!-- see the comment below -->                  |
| Bug fix?        | no                                                     |
| New feature?    | no                                                     |
| BC breaks?      | no                                                   |
| Deprecations?   | no <!-- don't forget to update the UPGRADE-*.md file --> |
| License         | MIT                                                          |

<!--
 - Bug fixes must be submitted against the 1.11 branch
 - Features and deprecations must be submitted against the 1.12 branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->
Related to [PR](#13832) and [PR](#13869) 

Commits
-------

3610c30 [API][Behat] Add note about behat client changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API APIs related issues and PRs. Behat Issues and PRs aimed at improving Behat usage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants