Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions features/standard/UrlAliases.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@IbexaOSS @IbexaHeadless @IbexaExperience @IbexaCommerce @javascript
Feature: UrlAliases

Background:
Given I am logged as admin

@test
Scenario: Create an Url Alias
Given a "folder" Content item named "UrlAliases" exists in root
| name | short_name |
| UrlAliases | UrlAliases |
Given I'm on Content view Page for "UrlAliases"
When I switch to "URL" tab in Content structure
And I create a new direct Url Alias called "TestUrlAlias" in "English (United Kingdom)" language
Then there should be a "/testurlalias" Url Alias on the list with "Direct" type
3 changes: 3 additions & 0 deletions src/bundle/Resources/config/services/test/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ services:
Ibexa\AdminUi\Behat\Component\FullView: ~

Ibexa\AdminUi\Behat\Component\DeleteContentDialog: ~

Ibexa\AdminUi\Behat\Component\CreateUrlAliasForm: ~

19 changes: 19 additions & 0 deletions src/lib/Behat/BrowserContext/ContentViewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,23 @@ public function iSendContentToTrash(): void
{
$this->contentViewPage->sendToTrash();
}

/**
* @When I create a new direct Url Alias called :path in :languageName language
*/
public function iCreateNewUrlAlias(string $path, string $languageName): void
{
$this->contentViewPage->createNewDirectUrlAlias($path, $languageName, false);
}

/**
* @Then there should be a :path Url Alias on the list with :type type
*/
public function verifyUrlAliasExists(string $path, string $type): void
{
Assert::assertTrue(
$this->contentViewPage->isUrlAliasOnTheList($path, $type),
sprintf('Url alias "%s" with type "%s" not found', $path, $type)
);
}
}
49 changes: 49 additions & 0 deletions src/lib/Behat/Component/CreateUrlAliasForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

namespace Ibexa\AdminUi\Behat\Component;

use Behat\Mink\Session;
use Ibexa\Behat\Browser\Component\Component;
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;

final class CreateUrlAliasForm extends Component
{
use \Ibexa\Behat\Core\Debug\InteractiveDebuggerTrait;

private IbexaDropdown $ibexaDropdown;

public function __construct(Session $session, IbexaDropdown $ibexaDropdown)
{
parent::__construct($session);
$this->ibexaDropdown = $ibexaDropdown;
}

public function verifyIsLoaded(): void
{
$this->getHTMLPage()->find($this->getLocator('title'))->assert()->textEquals('Create a new URL alias');
}

public function createNewUrlAlias(string $path, string $languageName, bool $isRedirecting): void
{
$this->getHTMLPage()->find($this->getLocator('pathInput'))->setValue($path);
$this->getHTMLPage()->find($this->getLocator('languageDropdown'))->click();
$this->ibexaDropdown->verifyIsLoaded();
$this->ibexaDropdown->selectOption($languageName);
$this->getHTMLPage()->find($this->getLocator('createButton'))->click();
}

protected function specifyLocators(): array
{
return [
new VisibleCSSLocator('title', '#ibexa-modal--custom-url-alias .modal-title'),
new VisibleCSSLocator('createButton', '#custom_url_add_add'),
new VisibleCSSLocator('pathInput', '#custom_url_add_path'),
new VisibleCSSLocator('languageDropdown', '.ibexa-custom-url-from__item .ibexa-dropdown__selection-info'),
];
}
}
27 changes: 26 additions & 1 deletion src/lib/Behat/Page/ContentViewPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
use Ibexa\AdminUi\Behat\Component\ContentActionsMenu;
use Ibexa\AdminUi\Behat\Component\ContentItemAdminPreview;
use Ibexa\AdminUi\Behat\Component\ContentTypePicker;
use Ibexa\AdminUi\Behat\Component\CreateUrlAliasForm;
use Ibexa\AdminUi\Behat\Component\DeleteContentDialog;
use Ibexa\AdminUi\Behat\Component\Dialog;
use Ibexa\AdminUi\Behat\Component\IbexaDropdown;
use Ibexa\AdminUi\Behat\Component\LanguagePicker;
use Ibexa\AdminUi\Behat\Component\SubItemsList;
use Ibexa\AdminUi\Behat\Component\Table\TableBuilder;
use Ibexa\AdminUi\Behat\Component\TranslationDialog;
use Ibexa\AdminUi\Behat\Component\UniversalDiscoveryWidget;
use Ibexa\AdminUi\Behat\Component\UpperMenu;
Expand Down Expand Up @@ -85,6 +87,10 @@

private DeleteContentDialog $deleteContentDialog;

private CreateUrlAliasForm $createUrlAliasForm;

private TableBuilder $tableBuilder;

public function __construct(
Session $session,
Router $router,
Expand All @@ -101,7 +107,9 @@
UniversalDiscoveryWidget $universalDiscoveryWidget,
IbexaDropdown $ibexaDropdown,
UpperMenu $upperMenu,
DeleteContentDialog $deleteContentDialog
DeleteContentDialog $deleteContentDialog,
CreateUrlAliasForm $createUrlAliasForm,
TableBuilder $tableBuilder
) {
parent::__construct($session, $router);
$this->contentActionsMenu = $contentActionsMenu;
Expand All @@ -118,6 +126,8 @@
$this->ibexaDropdown = $ibexaDropdown;
$this->upperMenu = $upperMenu;
$this->deleteContentDialog = $deleteContentDialog;
$this->createUrlAliasForm = $createUrlAliasForm;
$this->tableBuilder = $tableBuilder;
}

public function startCreatingContent(string $contentTypeName, ?string $language = null)
Expand Down Expand Up @@ -294,6 +304,19 @@
return $this->getHTMLPage()->find($this->getLocator('isBookmarked'))->isVisible();
}

public function createNewDirectUrlAlias(string $path, string $languageName, bool $isRedirecting): void
{
$this->getHTMLPage()->find($this->getLocator('addUrlAliasButton'))->click();
$this->createUrlAliasForm->createNewUrlAlias($path, $languageName, $isRedirecting);
}

public function isUrlAliasOnTheList(string $path, string $type): bool
{
$customUrlAliasesTable = $this->tableBuilder->newTable()->withParentLocator($this->getLocator('customUrlAliasesTable'))->build();

Check failure on line 315 in src/lib/Behat/Page/ContentViewPage.php

View workflow job for this annotation

GitHub Actions / Tests (7.4)

Parameter #1 $locator of method Ibexa\AdminUi\Behat\Component\Table\TableBuilder::withParentLocator() expects Ibexa\Behat\Browser\Locator\CSSLocator, Ibexa\Behat\Browser\Locator\LocatorInterface given.

Check failure on line 315 in src/lib/Behat/Page/ContentViewPage.php

View workflow job for this annotation

GitHub Actions / Tests (8.1)

Parameter #1 $locator of method Ibexa\AdminUi\Behat\Component\Table\TableBuilder::withParentLocator() expects Ibexa\Behat\Browser\Locator\CSSLocator, Ibexa\Behat\Browser\Locator\LocatorInterface given.

Check failure on line 315 in src/lib/Behat/Page/ContentViewPage.php

View workflow job for this annotation

GitHub Actions / Tests (8.0)

Parameter #1 $locator of method Ibexa\AdminUi\Behat\Component\Table\TableBuilder::withParentLocator() expects Ibexa\Behat\Browser\Locator\CSSLocator, Ibexa\Behat\Browser\Locator\LocatorInterface given.

return $customUrlAliasesTable->hasElement(['URL' => $path, 'Type' => $type]);
}

protected function specifyLocators(): array
{
return [
Expand All @@ -308,6 +331,8 @@
new VisibleCSSLocator('ibexaDropdownPreview', '.ibexa-raw-content-title__language-form .ibexa-dropdown__selection-info'),
new VisibleCSSLocator('moreTab', '.ibexa-tabs__tab--more'),
new VisibleCSSLocator('popupMenuItem', '.ibexa-popup-menu__item .ibexa-popup-menu__item-content'),
new VisibleCSSLocator('addUrlAliasButton', '#ibexa-tab-location-view-urls [data-bs-target="#ibexa-modal--custom-url-alias"]'),
new VisibleCSSLocator('customUrlAliasesTable', '#ibexa-tab-location-view-urls .ibexa-table'),
];
}

Expand Down
Loading