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

[Admin][Taxon] Implements media management #16245

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ Feature: Adding images to an existing taxon
And the store classifies its products as "T-Shirts"
And I am logged in as an administrator

@todo @ui @mink:chromedriver @api
@ui @mink:chromedriver @api
Scenario: Adding a single image to an existing taxon
When I want to modify the "T-Shirts" taxon
And I attach the "t-shirts.jpg" image with "banner" type to this taxon
And I save my changes to the images
Then I should be notified that it has been successfully uploaded
And this taxon should have an image with "banner" type

@todo @ui @mink:chromedriver @api
@ui @mink:chromedriver @api
Scenario: Adding a single image to an existing taxon without specifying the type
When I want to modify the "T-Shirts" taxon
And I attach the "t-shirts.jpg" image to this taxon
And I save my changes to the images
Then I should be notified that it has been successfully uploaded
And this taxon should have only one image

@todo @ui @mink:chromedriver @api
@ui @mink:chromedriver @api
Scenario: Adding multiple images to an existing taxon
When I want to modify the "T-Shirts" taxon
And I attach the "t-shirts.jpg" image with "banner" type to this taxon
Expand All @@ -35,7 +35,7 @@ Feature: Adding images to an existing taxon
And this taxon should have an image with "banner" type
And it should also have an image with "thumbnail" type

@todo @ui @javascript @api
@ui @mink:chromedriver @api
Scenario: Adding multiple images of the same type to an existing taxon
When I want to modify the "T-Shirts" taxon
And I attach the "t-shirts.jpg" image with "banner" type to this taxon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ Feature: Adding a new taxon with images
Given the store is available in "English (United States)"
And I am logged in as an administrator

@todo @ui @mink:chromedriver @no-api
@ui @mink:chromedriver @no-api
Scenario: Adding a new taxon with a single image
When I want to create a new taxon
And I specify its code as "t-shirts"
And I name it "T-Shirts" in "English (United States)"
And I set its slug to "t-shirts"
And I attach the "t-shirts.jpg" image with "banner" type
And I add it
Then I should be notified that it has been successfully created
And the "T-Shirts" taxon should appear in the registry
And this taxon should have an image with "banner" type

@todo @ui @mink:chromedriver @no-api
@ui @mink:chromedriver @no-api
Scenario: Adding a new taxon with multiple images
When I want to create a new taxon
And I specify its code as "t-shirts"
And I name it "T-Shirts" in "English (United States)"
And I set its slug to "t-shirts"
And I attach the "t-shirts.jpg" image with "banner" type
And I attach the "t-shirts.jpg" image with "thumbnail" type
And I add it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Changing images of an existing taxon
And the store classifies its products as "T-Shirts"
And I am logged in as an administrator

@todo @ui @mink:chromedriver @no-api
@ui @mink:chromedriver @no-api
Scenario: Changing a single image of a taxon
Given the "T-Shirts" taxon has an image "ford.jpg" with "banner" type
When I want to modify the "T-Shirts" taxon
Expand All @@ -18,7 +18,7 @@ Feature: Changing images of an existing taxon
Then I should be notified that it has been successfully edited
And this taxon should have an image with "banner" type

@todo @ui @javascript @api
@ui @mink:chromedriver @api
Scenario: Changing the type of image of a taxon
Given the "T-Shirts" taxon has an image "ford.jpg" with "thumbnail" type
And the "T-Shirts" taxon also has an image "t-shirts.jpg" with "banner" type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Removing images of an existing taxon
And the store classifies its products as "T-Shirts"
And I am logged in as an administrator

@todo @ui @javascript @api
@ui @mink:chromedriver @api
Scenario: Removing a single image of a taxon
Given the "T-Shirts" taxon has an image "t-shirts.jpg" with "banner" type
When I want to modify the "T-Shirts" taxon
Expand All @@ -18,7 +18,7 @@ Feature: Removing images of an existing taxon
Then I should be notified that the changes have been successfully applied
And this taxon should not have any images

@todo @ui @javascript @api
@ui @mink:chromedriver @api
Scenario: Removing all images of a taxon
Given the "T-Shirts" taxon has an image "t-shirts.jpg" with "banner" type
And the "T-Shirts" taxon also has an image "t-shirts.jpg" with "thumbnail" type
Expand All @@ -29,7 +29,7 @@ Feature: Removing images of an existing taxon
Then I should be notified that the changes have been successfully applied
And this taxon should not have any images

@todo @ui @mink:chromedriver @api
@ui @mink:chromedriver @api
Scenario: Removing only one image of a taxon
Given the "T-Shirts" taxon has an image "t-shirts.jpg" with "banner" type
And the "T-Shirts" taxon also has an image "t-shirts.jpg" with "thumbnail" type
Expand All @@ -40,7 +40,7 @@ Feature: Removing images of an existing taxon
And this taxon should have an image with "thumbnail" type
But this taxon should not have any images with "banner" type

@todo @ui @javascript @api
@ui @mink:chromedriver @api
Scenario: Removing only one image of a taxon when all images have same type
Given the "T-Shirts" taxon has an image "t-shirts.jpg" with "banner" type
And the "T-Shirts" taxon also has an image "mugs.jpg" with "banner" type
Expand All @@ -50,7 +50,7 @@ Feature: Removing images of an existing taxon
Then I should be notified that the changes have been successfully applied
And this taxon should have only one image

@todo @ui @mink:chromedriver @no-api
@ui @mink:chromedriver @no-api
Scenario: Adding multiple images and removing a single image of a taxon
When I want to modify the "T-Shirts" taxon
And I attach the "t-shirts.jpg" image with "banner" type
Expand Down
64 changes: 30 additions & 34 deletions src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Behat\Behat\Context\Context;
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPageInterface;
use Sylius\Behat\Context\Ui\Admin\Helper\ValidationTrait;
use Sylius\Behat\Element\Admin\Taxon\FormElementInterface;
use Sylius\Behat\NotificationType;
use Sylius\Behat\Page\Admin\Product\UpdateSimpleProductPageInterface;
use Sylius\Behat\Page\Admin\Taxon\CreateForParentPageInterface;
Expand All @@ -34,14 +35,15 @@ final class ManagingTaxonsContext implements Context
use ValidationTrait;

public function __construct(
private SharedStorageInterface $sharedStorage,
private CreatePageInterface $createPage,
private CreateForParentPageInterface $createForParentPage,
private UpdatePageInterface $updatePage,
private CurrentPageResolverInterface $currentPageResolver,
private NotificationCheckerInterface $notificationChecker,
private JavaScriptTestHelper $testHelper,
private UpdateSimpleProductPageInterface $updateSimpleProductPage,
private readonly SharedStorageInterface $sharedStorage,
private readonly CreatePageInterface $createPage,
private readonly CreateForParentPageInterface $createForParentPage,
private readonly UpdatePageInterface $updatePage,
private readonly FormElementInterface $formElement,
private readonly CurrentPageResolverInterface $currentPageResolver,
private readonly NotificationCheckerInterface $notificationChecker,
private readonly JavaScriptTestHelper $testHelper,
private readonly UpdateSimpleProductPageInterface $updateSimpleProductPage,
) {
}

Expand Down Expand Up @@ -86,23 +88,19 @@ public function iSpecifyItsCodeAs(?string $code = null): void
* @When I rename it to :name in :language
* @When I do not specify its name
*/
public function iNameItIn(?string $name = null, $language = 'en_US')
public function iNameItIn(?string $name = null, $language = 'en_US'): void
{
$currentPage = $this->resolveCurrentPage();

$currentPage->nameIt($name ?? '', $language);
$this->formElement->nameIt($name ?? '', $language);
}

/**
* @When I set its slug to :slug
* @When I do not specify its slug
* @When I set its slug to :slug in :language
*/
public function iSetItsSlugToIn(?string $slug = null, $language = 'en_US')
public function iSetItsSlugToIn(?string $slug = null, $language = 'en_US'): void
{
$currentPage = $this->resolveCurrentPage();

$currentPage->specifySlug($slug ?? '', $language);
$this->formElement->slugIt($slug ?? '', $language);
}

/**
Expand Down Expand Up @@ -172,10 +170,10 @@ public function iSaveMyChanges()
/**
* @Then /^the ("[^"]+" taxon) should appear in the registry$/
*/
public function theTaxonShouldAppearInTheRegistry(TaxonInterface $taxon)
public function theTaxonShouldAppearInTheRegistry(TaxonInterface $taxon): void
{
$this->updatePage->open(['id' => $taxon->getId()]);
Assert::true($this->updatePage->hasResourceValues(['code' => $taxon->getCode()]));
Assert::same($this->formElement->getCode(), $taxon->getCode());
}

/**
Expand Down Expand Up @@ -309,9 +307,7 @@ public function iShouldSeeTaxonsInTheList($number)
*/
public function iAttachImageWithType(string $path, ?string $type = null): void
{
$currentPage = $this->resolveCurrentPage();

$currentPage->attachImage($path, $type);
$this->formElement->attachImage($path, $type);
}

/**
Expand All @@ -327,68 +323,68 @@ public function iShouldSeeTheTaxonNamedInTheList($name)
*/
public function thisTaxonShouldHaveAnImageWithType(string $type): void
{
Assert::true($this->updatePage->isImageWithTypeDisplayed($type));
Assert::true($this->formElement->isImageWithTypeDisplayed($type));
}

/**
* @Then /^(?:this taxon|it) should not have(?:| also) any images with "([^"]*)" type$/
*/
public function thisTaxonShouldNotHaveAnImageWithType($code)
{
Assert::false($this->updatePage->isImageWithTypeDisplayed($code));
Assert::false($this->formElement->isImageWithTypeDisplayed($code));
}

/**
* @When /^I(?:| also) remove an image with "([^"]*)" type$/
*/
public function iRemoveAnImageWithType(string $type): void
{
$this->updatePage->removeImageWithType($type);
$this->formElement->removeImageWithType($type);
}

/**
* @When I remove the first image
*/
public function iRemoveTheFirstImage()
public function iRemoveTheFirstImage(): void
{
$this->updatePage->removeFirstImage();
$this->formElement->removeFirstImage();
}

/**
* @Then /^(this taxon) should not have any images$/
*/
public function thisTaxonShouldNotHaveAnyImages(TaxonInterface $taxon)
public function thisTaxonShouldNotHaveAnyImages(TaxonInterface $taxon): void
{
$this->iWantToModifyATaxon($taxon);

Assert::same($this->updatePage->countImages(), 0);
Assert::same($this->formElement->countImages(), 0);
}

/**
* @When I change the image with the :type type to :path
*/
public function iChangeItsImageToPathForTheType($path, $type)
public function iChangeItsImageToPathForTheType($path, $type): void
{
$this->updatePage->changeImageWithType($type, $path);
$this->formElement->changeImageWithType($type, $path);
}

/**
* @When I change the first image type to :type
*/
public function iChangeTheFirstImageTypeTo($type)
public function iChangeTheFirstImageTypeTo($type): void
{
$this->updatePage->modifyFirstImageType($type);
$this->formElement->modifyFirstImageType($type);
}

/**
* @Then /^(this taxon) should have only one image$/
* @Then /^(this taxon) should(?:| still) have (\d+) images?$/
*/
public function thereShouldStillBeOnlyOneImageInThisTaxon(TaxonInterface $taxon, $count = 1)
public function thereShouldStillBeOnlyOneImageInThisTaxon(TaxonInterface $taxon, $count = 1): void
{
$this->iWantToModifyATaxon($taxon);

Assert::same($this->updatePage->countImages(), (int) $count);
Assert::same($this->formElement->countImages(), (int) $count);
}

/**
Expand Down