[PromotionCoupon] Enable todo api scenario for filtering by code

This commit is contained in:
Kamil Grygierzec 2024-07-29 15:38:42 +02:00
parent 7958895598
commit c14937cff9
No known key found for this signature in database
GPG key ID: 7F54EE42DAD4B9E9
2 changed files with 36 additions and 3 deletions

View file

@ -19,7 +19,7 @@ Feature: Filtering coupons
And this coupon expires on "20-02-2023"
And I am logged in as an administrator
@ui @todo-api
@api @ui
Scenario: Filtering coupons by code
Given I am browsing coupons of this promotion
When I filter by code containing "X"

View file

@ -49,8 +49,21 @@ final class ManagingPromotionCouponsContext implements Context
{
$this->client->index(Resources::PROMOTION_COUPONS);
$this->client->addFilter(
'promotion',
$this->iriConverter->getIriFromResourceInSection($promotion, 'admin'),
'promotion.code',
$promotion->getCode(),
);
$this->client->filter();
}
/**
* @When I filter by code containing :phrase
*/
public function iFilterByCodeContaining(string $phrase): void
{
$this->client->index(Resources::PROMOTION_COUPONS);
$this->client->addFilter(
'code',
$phrase,
);
$this->client->filter();
}
@ -632,6 +645,26 @@ final class ManagingPromotionCouponsContext implements Context
);
}
/**
* @Then I should see a single promotion coupon in the list
*/
public function iShouldSeeASinglePromotionCouponInTheList(): void
{
Assert::same($this->responseChecker->countCollectionItems($this->client->getLastResponse()), 1);
}
/**
* @Then I should see the promotion coupon :coupon in the list
*/
public function iShouldSeeThePromotionCouponInTheList(PromotionCouponInterface $coupon): void
{
Assert::true($this->responseChecker->hasItemWithValue(
$this->client->getLastResponse(),
'code',
$coupon->getCode(),
));
}
private function sortBy(string $order, string $field): void
{
$this->client->sort([$field => str_starts_with($order, 'de') ? 'desc' : 'asc']);