Skip to content

Commit

Permalink
[Behat] IBX-4889: Cover file upload with a Visual Test (#715)
Browse files Browse the repository at this point in the history
Implemented SetExpectedContentDraftData method

Co-authored-by: katarzynazawada <>
  • Loading branch information
katarzynazawada authored Mar 6, 2023
1 parent ec9087d commit 9e5dbe2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
27 changes: 25 additions & 2 deletions src/lib/Behat/Page/ContentUpdateItemPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Ibexa\AdminUi\Behat\Component\ContentActionsMenu;
use Ibexa\AdminUi\Behat\Component\Fields\FieldTypeComponent;
use Ibexa\AdminUi\Behat\Component\Notification;
use Ibexa\Behat\API\Facade\ContentFacade;
use Ibexa\Behat\Browser\Element\Condition\ElementExistsCondition;
use Ibexa\Behat\Browser\Element\Condition\ElementHasTextCondition;
use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion;
Expand All @@ -34,17 +35,27 @@ class ContentUpdateItemPage extends Page
/** @var \Ibexa\AdminUi\Behat\Component\Notification */
private $notification;

private string $languageCode;

private string $contentTypeIdentifier;

private string $locationPath;

private ContentFacade $contentFacade;

public function __construct(
Session $session,
Router $router,
ContentActionsMenu $contentActionsMenu,
iterable $fieldTypeComponents,
Notification $notification
Notification $notification,
ContentFacade $contentFacade
) {
parent::__construct($session, $router);
$this->contentActionsMenu = $contentActionsMenu;
$this->fieldTypeComponents = $fieldTypeComponents;
$this->notification = $notification;
$this->contentFacade = $contentFacade;
}

public function verifyIsLoaded(): void
Expand Down Expand Up @@ -111,7 +122,19 @@ protected function specifyLocators(): array

protected function getRoute(): string
{
throw new \Exception('This page cannot be opened on its own!');
return sprintf(
'/content/create/proxy/%s/%s/%d',
$this->contentTypeIdentifier,
$this->languageCode,
$this->contentFacade->getContentByLocationURL($this->locationPath)->contentInfo->getMainLocation()->id
);
}

public function setExpectedContentDraftData(string $contentTypeIdentifier, string $languageCode, string $locationPath): void
{
$this->contentTypeIdentifier = $contentTypeIdentifier;
$this->languageCode = $languageCode;
$this->locationPath = $locationPath;
}

public function getField(string $fieldName): FieldTypeComponent
Expand Down
13 changes: 10 additions & 3 deletions src/lib/Behat/Page/UserUpdatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@
use Behat\Mink\Session;
use Ibexa\AdminUi\Behat\Component\ContentActionsMenu;
use Ibexa\AdminUi\Behat\Component\Notification;
use Ibexa\Behat\API\Facade\ContentFacade;
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;
use Ibexa\Behat\Browser\Routing\Router;
use Traversable;

class UserUpdatePage extends ContentUpdateItemPage
{
public function __construct(Session $session, Router $router, ContentActionsMenu $contentActionsMenu, Traversable $fieldTypeComponents, Notification $notification)
{
parent::__construct($session, $router, $contentActionsMenu, $fieldTypeComponents, $notification);
public function __construct(
Session $session,
Router $router,
ContentActionsMenu $contentActionsMenu,
Traversable $fieldTypeComponents,
Notification $notification,
ContentFacade $contentFacade
) {
parent::__construct($session, $router, $contentActionsMenu, $fieldTypeComponents, $notification, $contentFacade);
$this->locators->replace(
new VisibleCSSLocator(
'formElement',
Expand Down

0 comments on commit 9e5dbe2

Please sign in to comment.