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

[Behat] Viewing product image - API scenario covered #13851

Merged
merged 2 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Viewing a product's image on a product details page
And the store has a product "Lamborghini Gallardo Model"
And this product has an image "lamborghini.jpg" with "main" type

@ui @javascript
@ui @javascript @api
Scenario: Viewing a product's image on a product details page
When I check this product's details
Then I should see the product name "Lamborghini Gallardo Model"
Expand Down
15 changes: 15 additions & 0 deletions src/Sylius/Behat/Context/Api/Shop/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,14 @@ public function theVisitorShouldSeeAsThePriceOfTheProductInTheChannel(
));
}

/**
* @Then I should see a main image
*/
public function iShouldSeeAMainImage()
ernestWarwas marked this conversation as resolved.
Show resolved Hide resolved
{
Assert::true($this->hasProductWithMainImage());
}

private function hasProductWithPrice(
array $products,
int $price,
Expand Down Expand Up @@ -503,4 +511,11 @@ private function hasProductWithNameAndShortDescription(array $products, string $

return false;
}

private function hasProductWithMainImage(): bool
{
$images = $this->responseChecker->getValue($this->client->getLastResponse(), 'images');

return $images[0]['type'] === 'main' && $images[0]['path'];
}
}