Skip to content

Commit

Permalink
IBX-7357: Adjusted Authors & Details tabs to modes specification (#1058)
Browse files Browse the repository at this point in the history
* IBX-7357: Adjusted Authors & Details tabs to modes specification

* [Behat] Adapted tests

---------

Co-authored-by: Marek Nocoń <[email protected]>
  • Loading branch information
ViniTou and mnocon authored Jan 8, 2024
1 parent 9323d21 commit da3422e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 33 deletions.
11 changes: 8 additions & 3 deletions src/lib/Behat/Component/UpperMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ public function setFocusMode(bool $expectedModeStatus): void

if ($expectedModeStatus != $isEnabled) {
$this->getHTMLPage()->find($this->getLocator('userFocusMode'))->click();

return;
} else {
$this->getHTMLPage()->find($this->getLocator('userSettingsToggle'))->click();
}

$this->getHTMLPage()->find($this->getLocator('userSettingsToggle'))->click();
if ($expectedModeStatus) {
$this->getHTMLPage()->find($this->getLocator('focusModeBadge'))->assert()->textEquals('Focus mode');
} else {
$this->getHTMLPage()->findAll($this->getLocator('focusModeBadge'))->assert()->isEmpty();
}
}

public function verifyIsLoaded(): void
Expand All @@ -77,6 +81,7 @@ protected function specifyLocators(): array
new VisibleCSSLocator('searchButton', '.ibexa-main-header .ibexa-input-text-wrapper__action-btn--search'),
new VisibleCSSLocator('userFocusEnabled', '[name="focus_mode_change"] .ibexa-toggle__label--on'),
new VisibleCSSLocator('userFocusMode', '[name="focus_mode_change"] .ibexa-toggle__switcher'),
new VisibleCSSLocator('focusModeBadge', '.ibexa-user-mode-badge'),
];
}
}
19 changes: 0 additions & 19 deletions src/lib/Behat/Page/ContentViewPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,6 @@ public function choosePreview(string $language): void
public function setFocusMode(bool $expectedModeStatus): void
{
$this->upperMenu->setFocusMode($expectedModeStatus);

// TODO: Rework this after Focus mode label is visible next to Ibexa's logo
$focusModeExcludedTab = 'Technical details';

if ($expectedModeStatus) {
$this->getHTMLPage()
->setTimeout(3)
->findAll($this->getLocator('tab'))
->filterBy(new ElementTextCriterion($focusModeExcludedTab))
->assert()
->isEmpty();
} else {
$this->getHTMLPage()
->setTimeout(3)
->findAll($this->getLocator('tab'))
->getByCriterion(new ElementTextCriterion($focusModeExcludedTab))
->assert()
->isVisible();
}
}

public function goToSubItem(string $contentItemName): void
Expand Down
9 changes: 1 addition & 8 deletions src/lib/Tab/LocationView/AuthorsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@
namespace Ibexa\AdminUi\Tab\LocationView;

use Ibexa\AdminUi\Specification\UserExists;
use Ibexa\AdminUi\Specification\UserMode\IsFocusModeEnabled;
use Ibexa\AdminUi\UserSetting\FocusMode;
use Ibexa\Contracts\AdminUi\Tab\AbstractEventDispatchingTab;
use Ibexa\Contracts\AdminUi\Tab\ConditionalTabInterface;
use Ibexa\Contracts\AdminUi\Tab\OrderedTabInterface;
use Ibexa\Contracts\Core\Repository\UserService;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
use Ibexa\User\UserSetting\UserSettingService;
use JMS\TranslationBundle\Annotation\Desc;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -29,19 +26,15 @@ class AuthorsTab extends AbstractEventDispatchingTab implements OrderedTabInterf

private UserService $userService;

private UserSettingService $userSettingService;

public function __construct(
Environment $twig,
TranslatorInterface $translator,
UserService $userService,
UserSettingService $userSettingService,
EventDispatcherInterface $eventDispatcher
) {
parent::__construct($twig, $translator, $eventDispatcher);

$this->userService = $userService;
$this->userSettingService = $userSettingService;
}

public function getIdentifier(): string
Expand Down Expand Up @@ -92,7 +85,7 @@ public function getTemplateParameters(array $contextParameters = []): array

public function evaluate(array $parameters): bool
{
return IsFocusModeEnabled::fromUserSettings($this->userSettingService)->isSatisfiedBy(FocusMode::FOCUS_MODE_ON);
return true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Tab/LocationView/DetailsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getName(): string

public function getOrder(): int
{
return 200;
return 750;
}

public function evaluate(array $parameters): bool
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/Tab/LocationView/AuthorsTabVisibilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ protected function createTabForVisibilityInGivenUserModeTest(UserSettingService
$this->createMock(Environment::class),
$this->createMock(TranslatorInterface::class),
$this->createMock(UserService::class),
$userSettingService,
$this->createMock(EventDispatcherInterface::class)
);
}

public function dataProviderForTestTabVisibilityInGivenUserMode(): iterable
{
yield 'focus mode on' => [FocusMode::FOCUS_MODE_ON, [], true];
yield 'focus mode off' => [FocusMode::FOCUS_MODE_OFF, [], false];
yield 'focus mode off' => [FocusMode::FOCUS_MODE_OFF, [], true];
}
}

0 comments on commit da3422e

Please sign in to comment.