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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/admin-ui.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

276 changes: 276 additions & 0 deletions .idea/php.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions .idea/phpunit.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions features/standard/UrlAliases.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@IbexaOSS @IbexaHeadless @IbexaExperience @IbexaCommerce @javascript @test
Feature: UrlAliases

Background:
Given I am logged as admin

Scenario: Create a redirect 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 Url Alias called "RedirectUrlAlias" in "English (United Kingdom)" language with redirect "true"
Then there should be a "/redirecturlalias" Url Alias on the list with "Redirect" type

Scenario: Create a direct 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 Url Alias called "DirectUrlAlias" in "English (United Kingdom)" language with redirect "false"
Then there should be a "/directurlalias" 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 @@ -60,4 +60,7 @@ services:

Ibexa\AdminUi\Behat\Component\DeleteContentDialog: ~

Ibexa\AdminUi\Behat\Component\CreateUrlAliasModal: ~

Ibexa\AdminUi\Behat\Component\TrashSearch: ~

22 changes: 21 additions & 1 deletion src/lib/Behat/BrowserContext/ContentViewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
{
$this->contentViewPage->sendToTrash();
}

/**
* @Then I should see the alert :alertMessage appear
*/
Expand All @@ -177,4 +177,24 @@
$this->contentViewPage->verifyIsLoaded();
$this->contentViewPage->verifyMessage($alertMessage);
}

/**
* @When I create a new Url Alias called :path in :languageName language with redirect :redirect
*/
public function iCreateNewUrlAlias(string $path, string $languageName, string $redirect_string): void
{
$redirect = filter_var($redirect_string, FILTER_VALIDATE_BOOLEAN);
$this->contentViewPage->createNewUrlAlias($path, $languageName, $redirect);
}

/**
* @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)
);

}
54 changes: 54 additions & 0 deletions src/lib/Behat/Component/CreateUrlAliasModal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

Check warning on line 1 in src/lib/Behat/Component/CreateUrlAliasModal.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.0)

Found violation(s) of type: single_blank_line_before_namespace

Check warning on line 1 in src/lib/Behat/Component/CreateUrlAliasModal.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.0)

Found violation(s) of type: header_comment

Check warning on line 1 in src/lib/Behat/Component/CreateUrlAliasModal.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.0)

Found violation(s) of type: braces

Check warning on line 1 in src/lib/Behat/Component/CreateUrlAliasModal.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.0)

Found violation(s) of type: class_attributes_separation

/**
* @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 CreateUrlAliasModal 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 $redirect): void
{
$this->getHTMLPage()->find($this->getLocator('pathInput'))->setValue($path);
$this->getHTMLPage()->find($this->getLocator('languageDropdown'))->click();
$this->ibexaDropdown->verifyIsLoaded();
$this->ibexaDropdown->selectOption($languageName);
$redirectToggleState = $this->getHTMLPage()->find($this->getLocator('redirectToggle'));
//$this->setInteractiveBreakpoint(get_defined_vars());
if ($redirect !== $redirectToggleState->hasClass('ibexa-toggle--is-checked')) {
$this->getHTMLPage()->find($this->getLocator('redirectToggle'))->click();
}
$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'),
new VisibleCSSLocator('redirectToggle', '.ibexa-custom-url-from__item .ibexa-toggle'),
];
}
}
29 changes: 28 additions & 1 deletion src/lib/Behat/Page/ContentViewPage.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check warning on line 1 in src/lib/Behat/Page/ContentViewPage.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.0)

Found violation(s) of type: braces

Check warning on line 1 in src/lib/Behat/Page/ContentViewPage.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.0)

Found violation(s) of type: class_attributes_separation

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
Expand All @@ -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\CreateUrlAliasModal;
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 All @@ -34,6 +36,7 @@

class ContentViewPage extends Page
{
use \Ibexa\Behat\Core\Debug\InteractiveDebuggerTrait;
/** @var \Ibexa\AdminUi\Behat\Component\ContentActionsMenu Element representing the right menu */
private $contentActionsMenu;

Expand Down Expand Up @@ -85,6 +88,10 @@

private DeleteContentDialog $deleteContentDialog;

private CreateUrlAliasModal $createUrlAliasModal;

private TableBuilder $tableBuilder;

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

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

public function createNewUrlAlias(string $path, string $languageName, bool $redirect): void
{
$this->getHTMLPage()->find($this->getLocator('addUrlAliasButton'))->click();
// $this->setInteractiveBreakpoint(get_defined_vars());
$this->CreateUrlAliasModal->createNewUrlAlias($path, $languageName, $redirect);
}

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

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

protected function specifyLocators(): array
{
return [
Expand All @@ -308,6 +333,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'),
new VisibleCSSLocator('alertTitle', '.ibexa-alert__title'),
];
}
Expand Down
Loading