mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-15 01:20:59 +00:00
[Api][Zone] Enable behat tests
This commit is contained in:
parent
74b24bf672
commit
28819a6c0a
10 changed files with 58 additions and 71 deletions
|
|
@ -12,7 +12,7 @@ Feature: Adding a new zone with country type members
|
|||
And the store has a zone "North America" with code "NA"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @mink:chromedriver @api
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Adding a zone with a country type member
|
||||
When I want to create a new zone consisting of country
|
||||
And I name it "European Union"
|
||||
|
|
@ -22,7 +22,7 @@ Feature: Adding a new zone with country type members
|
|||
Then I should be notified that it has been successfully created
|
||||
And the zone named "European Union" with the "France" country member should appear in the registry
|
||||
|
||||
@ui @mink:chromedriver @api
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Adding a zone with province type member
|
||||
When I want to create a new zone consisting of province
|
||||
And I name it "United States"
|
||||
|
|
@ -32,7 +32,7 @@ Feature: Adding a new zone with country type members
|
|||
Then I should be notified that it has been successfully created
|
||||
And the zone named "United States" with the "Alabama" province member should appear in the registry
|
||||
|
||||
@ui @mink:chromedriver @api
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Adding a zone with zone type member
|
||||
When I want to create a new zone consisting of zone
|
||||
And I name it "America"
|
||||
|
|
@ -42,7 +42,7 @@ Feature: Adding a new zone with country type members
|
|||
Then I should be notified that it has been successfully created
|
||||
And the zone named "America" with the "North America" zone member should appear in the registry
|
||||
|
||||
@no-ui @api
|
||||
@api @no-ui
|
||||
Scenario: Adding a zone with a zone type member, but the member's code is too long
|
||||
When I want to create a new zone consisting of zone
|
||||
And I name it "America"
|
||||
|
|
@ -51,7 +51,7 @@ Feature: Adding a new zone with country type members
|
|||
And I add it
|
||||
Then I should be informed that the provided zone member code is too long
|
||||
|
||||
@ui @mink:chromedriver @api
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Adding a zone with a country type member and a shipping scope
|
||||
When I want to create a new zone consisting of country
|
||||
And I name it "European Union"
|
||||
|
|
@ -63,7 +63,7 @@ Feature: Adding a new zone with country type members
|
|||
And the zone named "European Union" with the "France" country member should appear in the registry
|
||||
And its scope should be "shipping"
|
||||
|
||||
@ui @mink:chromedriver @api
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Adding zone with disabled country
|
||||
When I want to create a new zone consisting of country
|
||||
And I name it "European Union"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Feature: Browsing zones
|
|||
And the store also has a zone "South America" with code "SA"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Browsing zones in store
|
||||
When I want to see all zones in store
|
||||
Then I should see 2 zones in the list
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Feature: Deleting multiple zones
|
|||
Given the store has zones "North America", "South America" and "Europe"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @mink:chromedriver @no-api
|
||||
@no-api @ui @mink:chromedriver
|
||||
Scenario: Deleting multiple zones at once
|
||||
When I browse zones
|
||||
And I check the "North America" zone
|
||||
|
|
|
|||
|
|
@ -14,19 +14,19 @@ Feature: Deleting a zone
|
|||
And the store has "Sales Tax" tax rate of 20% for "Sports gear" within the "SA" zone
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Deleted zone should disappear from the registry
|
||||
When I delete the zone named "North America"
|
||||
Then I should be notified that it has been successfully deleted
|
||||
And the zone named "North America" should no longer exist in the registry
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Deleting zone with associated tax rates should not be possible
|
||||
When I try to delete the zone named "South America"
|
||||
Then I should be notified that this zone cannot be deleted
|
||||
And I should still see the zone named "South America" in the list
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Deleting zone that is a zone member should not be possible
|
||||
When I try to delete the zone named "Central and Eastern Europe"
|
||||
Then I should be notified that this zone cannot be deleted
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Feature: Editing a zone
|
|||
And the store has a zone "South America" with code "SA"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @mink:chromedriver @api
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Removing a country from a zone
|
||||
Given the store has a zone "European Union" with code "EU"
|
||||
And it has the "France" country member
|
||||
|
|
@ -25,7 +25,7 @@ Feature: Editing a zone
|
|||
Then I should be notified that it has been successfully edited
|
||||
And this zone should have only the "France" country member
|
||||
|
||||
@ui @mink:chromedriver @api
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Removing and adding countries to a zone
|
||||
Given the store has a zone "European Union" with code "EU"
|
||||
And it has the "Belgium", "France" and "Germany" country members
|
||||
|
|
@ -36,7 +36,7 @@ Feature: Editing a zone
|
|||
Then I should be notified that it has been successfully edited
|
||||
And this zone should have only the "France" country member
|
||||
|
||||
@ui @mink:chromedriver @api
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Removing a province from a zone
|
||||
Given the store has a zone "United States" with code "USA"
|
||||
And it has the "Alabama" province member
|
||||
|
|
@ -47,7 +47,7 @@ Feature: Editing a zone
|
|||
Then I should be notified that it has been successfully edited
|
||||
And this zone should have only the "Alabama" province member
|
||||
|
||||
@ui @mink:chromedriver @api
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Removing a zone from a zone
|
||||
Given the store has a zone "America" with code "AM"
|
||||
And it has the zone named "North America"
|
||||
|
|
@ -58,7 +58,7 @@ Feature: Editing a zone
|
|||
Then I should be notified that it has been successfully edited
|
||||
And this zone should have only the "South America" zone member
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Renaming a zone
|
||||
Given the store has a zone "European Union" with code "EU"
|
||||
And it has the "France" country member
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Feature: Zone unique code validation
|
|||
And this zone has the "United States" country member
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Trying to add zone with taken code
|
||||
When I want to create a new zone consisting of country
|
||||
And I specify its code as "US"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Feature: Zone validation
|
|||
And the store has country "United States"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Trying to add a zone without specifying its code
|
||||
When I want to create a new zone consisting of country
|
||||
And I name it "European Union"
|
||||
|
|
@ -18,7 +18,7 @@ Feature: Zone validation
|
|||
Then I should be notified that code is required
|
||||
And zone with name "European Union" should not be added
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Trying to add a zone with a too long code
|
||||
When I want to create a new zone consisting of country
|
||||
And I name it "European Union"
|
||||
|
|
@ -26,7 +26,7 @@ Feature: Zone validation
|
|||
And I try to add it
|
||||
Then I should be notified that code is too long
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Trying to add a zone without specifying its name
|
||||
When I want to create a new zone consisting of country
|
||||
And I specify its code as "EU"
|
||||
|
|
@ -35,7 +35,7 @@ Feature: Zone validation
|
|||
Then I should be notified that name is required
|
||||
And zone with code "EU" should not be added
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Trying to add a zone without any countries
|
||||
When I want to create a new zone consisting of country
|
||||
And I name it "European Union"
|
||||
|
|
@ -45,26 +45,26 @@ Feature: Zone validation
|
|||
Then I should be notified that at least one zone member is required
|
||||
And zone with name "European Union" should not be added
|
||||
|
||||
@ui @api
|
||||
@api @ui
|
||||
Scenario: Being unable to edit code of an existing zone
|
||||
Given the store has a zone "European Union" with code "EU"
|
||||
And it has the "France" country member
|
||||
When I want to modify the zone named "European Union"
|
||||
Then I should not be able to edit its code
|
||||
|
||||
@ui @api @mink:chromedriver
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Being unable to add itself to members during editing an existing zone
|
||||
Given the store has a zone "European Union" with code "EU"
|
||||
When I want to modify the zone named "European Union"
|
||||
Then I should not be able to add the "European Union" zone as a member
|
||||
|
||||
@ui @todo-api
|
||||
@no-api @ui
|
||||
Scenario: Seeing a disabled type field when adding country type zone
|
||||
When I want to create a new zone consisting of country
|
||||
Then I should not be able to edit its type
|
||||
And it should be of country type
|
||||
|
||||
@ui @todo-api
|
||||
@no-api @ui
|
||||
Scenario: Seeing a disabled type field when adding province type zone
|
||||
When I want to create a new zone consisting of province
|
||||
Then I should not be able to edit its type
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Behat\Context\Api\Admin;
|
||||
|
||||
use ApiPlatform\Api\IriConverterInterface;
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Behat\Client\ApiClientInterface;
|
||||
use Sylius\Behat\Client\ResponseCheckerInterface;
|
||||
|
|
@ -26,7 +25,7 @@ use Sylius\Component\Addressing\Model\ZoneInterface;
|
|||
use Sylius\Component\Addressing\Model\ZoneMemberInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class ManagingZonesContext implements Context
|
||||
final readonly class ManagingZonesContext implements Context
|
||||
{
|
||||
use ValidationTrait;
|
||||
|
||||
|
|
@ -34,8 +33,6 @@ final class ManagingZonesContext implements Context
|
|||
private ApiClientInterface $client,
|
||||
private ResponseCheckerInterface $responseChecker,
|
||||
private SharedStorageInterface $sharedStorage,
|
||||
private IriConverterInterface $iriConverter,
|
||||
private string $zoneMemberClass,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -211,11 +208,11 @@ final class ManagingZonesContext implements Context
|
|||
ZoneInterface $zone,
|
||||
CountryInterface $country,
|
||||
): void {
|
||||
Assert::true($this->responseChecker->hasItemWithValue(
|
||||
$this->client->subResourceIndex(Resources::ZONES, 'members', $zone->getCode()),
|
||||
'code',
|
||||
$country->getCode(),
|
||||
));
|
||||
$members = $this->responseChecker->getValue(
|
||||
$this->client->getLastResponse(),
|
||||
'members'
|
||||
);
|
||||
Assert::inArray($country->getCode(), array_column($members, 'code'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -253,11 +250,11 @@ final class ManagingZonesContext implements Context
|
|||
ZoneInterface $zone,
|
||||
ProvinceInterface $province,
|
||||
): void {
|
||||
Assert::true($this->responseChecker->hasItemWithValue(
|
||||
$this->client->subResourceIndex(Resources::ZONES, 'members', $zone->getCode()),
|
||||
'code',
|
||||
$province->getCode(),
|
||||
));
|
||||
$members = $this->responseChecker->getValue(
|
||||
$this->client->getLastResponse(),
|
||||
'members'
|
||||
);
|
||||
Assert::inArray($province->getCode(), array_column($members, 'code'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -267,11 +264,11 @@ final class ManagingZonesContext implements Context
|
|||
ZoneInterface $zone,
|
||||
ZoneInterface $otherZone,
|
||||
): void {
|
||||
Assert::true($this->responseChecker->hasItemWithValue(
|
||||
$this->client->subResourceIndex(Resources::ZONES, 'members', $zone->getCode()),
|
||||
'code',
|
||||
$otherZone->getCode(),
|
||||
));
|
||||
$members = $this->responseChecker->getValue(
|
||||
$this->client->getLastResponse(),
|
||||
'members'
|
||||
);
|
||||
Assert::inArray($otherZone->getCode(), array_column($members, 'code'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -345,16 +342,12 @@ final class ManagingZonesContext implements Context
|
|||
*/
|
||||
public function thisZoneShouldHaveOnlyTheProvinceMember(ZoneInterface $zone, ZoneMemberInterface $zoneMember): void
|
||||
{
|
||||
Assert::true($this->responseChecker->hasItemWithValue(
|
||||
$this->client->subResourceIndex(Resources::ZONES, 'members', $zone->getCode()),
|
||||
'code',
|
||||
$zoneMember->getCode(),
|
||||
));
|
||||
|
||||
Assert::same(
|
||||
$this->responseChecker->countCollectionItems($this->client->getLastResponse()),
|
||||
1,
|
||||
$members = $this->responseChecker->getValue(
|
||||
$this->client->getLastResponse(),
|
||||
'members'
|
||||
);
|
||||
Assert::inArray($zoneMember->getCode(), array_column($members, 'code'));
|
||||
Assert::count($members, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -473,19 +466,15 @@ final class ManagingZonesContext implements Context
|
|||
|
||||
private function removeZoneMember(CountryInterface|ProvinceInterface|ZoneInterface $objectToRemove): void
|
||||
{
|
||||
/** @var ZoneInterface $zone */
|
||||
$zone = $this->sharedStorage->get('zone');
|
||||
$members = $this->client->getContent()['members'];
|
||||
|
||||
$members = $zone->getMembers();
|
||||
|
||||
foreach ($members as $member) {
|
||||
if ($member->getCode() === $objectToRemove->getCode()) {
|
||||
$objectToRemove = $member;
|
||||
foreach ($members as $key => $member) {
|
||||
if ($member['code'] === $objectToRemove->getCode()) {
|
||||
unset($members[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$iri = $this->iriConverter->getItemIriFromResourceClass($this->zoneMemberClass, ['id' => $objectToRemove->getId()]);
|
||||
|
||||
$this->client->removeSubResource('members', $iri);
|
||||
$this->client->setSubResourceData('members', $members);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,13 +229,11 @@
|
|||
<!-- <argument type="service" id="sylius.behat.shared_storage" />-->
|
||||
<!-- </service>-->
|
||||
|
||||
<!-- <service id="sylius.behat.context.api.admin.managing_zones" class="Sylius\Behat\Context\Api\Admin\ManagingZonesContext">-->
|
||||
<!-- <argument type="service" id="sylius.behat.api_platform_client.admin" />-->
|
||||
<!-- <argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />-->
|
||||
<!-- <argument type="service" id="sylius.behat.shared_storage" />-->
|
||||
<!-- <argument type="service" id="api_platform.iri_converter" />-->
|
||||
<!-- <argument>%sylius.model.zone_member.class%</argument>-->
|
||||
<!-- </service>-->
|
||||
<service id="sylius.behat.context.api.admin.managing_zones" class="Sylius\Behat\Context\Api\Admin\ManagingZonesContext">
|
||||
<argument type="service" id="sylius.behat.api_platform_client.admin" />
|
||||
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
|
||||
<argument type="service" id="sylius.behat.shared_storage" />
|
||||
</service>
|
||||
|
||||
<!-- <service id="Sylius\Behat\Context\Api\Admin\RemovingProductContext">-->
|
||||
<!-- <argument type="service" id="sylius.behat.api_platform_client.admin" />-->
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ imports:
|
|||
- api/account/email_verification.yml
|
||||
- api/account/login.yaml
|
||||
- api/addressing/managing_countries.yaml
|
||||
# - api/addressing/managing_zones.yml
|
||||
- api/addressing/managing_zones.yml
|
||||
# - api/admin/dashboard.yaml
|
||||
- api/admin/login.yml
|
||||
# - api/admin/security.yml
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue