Skip to content

Commit c9b8bcf

Browse files
Fixes after review
1 parent 1d81493 commit c9b8bcf

File tree

3 files changed

+30
-58
lines changed

3 files changed

+30
-58
lines changed

src/lib/Behat/BrowserContext/UserNotificationContext.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function iGoToUserNotificationWithDetails(TableNode $notificationDetails)
5555
/**
5656
* @Then the notification appears with details:
5757
*/
58-
public function thereIsNotificationAppearsWithDetails(TableNode $notificationDetails): void
58+
public function notificationAppearsWithDetails(TableNode $notificationDetails): void
5959
{
6060
$type = $notificationDetails->getHash()[0]['Type'];
6161
$author = $notificationDetails->getHash()[0]['Author'];
@@ -75,34 +75,34 @@ public function iOpenNotificationMenu(string $description): void
7575
}
7676

7777
/**
78-
* @When I click :action action
78+
* @When I perform the :action action on the notification
7979
*/
80-
public function iClickActionButton(string $action): void
80+
public function iPerformNotificationAction(string $action): void
8181
{
8282
$this->userNotificationPopup->clickActionButton($action);
8383
}
8484

8585
/**
86-
* @Then the notification action should be :expectedAction
86+
* @Then the notification should have :expectedAction action available
8787
*/
8888
public function verifyNotificationAction(string $expectedAction): void
8989
{
90-
$this->userNotificationPopup->getActionButton($expectedAction);
90+
$this->userNotificationPopup->findActionButton($expectedAction);
9191
}
9292

9393
/**
94-
* @When I click mark all as read button
94+
* @When I mark all notifications as read
9595
*/
96-
public function iClickButton(): void
96+
public function markAllNotificationsAsRead(): void
9797
{
9898
$this->userNotificationPopup->verifyIsLoaded();
9999
$this->userNotificationPopup->clickOnMarkAllAsReadButton();
100100
}
101101

102102
/**
103-
* @When I click view all notifications button
103+
* @When I go to the list of all notifications
104104
*/
105-
public function iClickViewAllNotificationsButton(): void
105+
public function goToAllNotificationsList(): void
106106
{
107107
$this->userNotificationPopup->verifyIsLoaded();
108108
$this->userNotificationPopup->clickViewAllNotificationsButton();
@@ -150,31 +150,31 @@ public function iDeleteNotification(string $notificationTitle): void
150150
}
151151

152152
/**
153-
* @Then I should see the text :text in the notifications popup
153+
* @Then an empty notifications state in the popup should be visible
154154
*/
155-
public function iShouldSeeTextInNotificationsPopup(string $expectedMessage): void
155+
public function emptyNotificationsStateInPopup(): void
156156
{
157-
$this->userNotificationPopup->verifyNoNotificationsMessage($expectedMessage);
157+
$this->userNotificationPopup->assertEmptyStateVisible();
158158
}
159159

160160
/**
161-
* @Then I should see the text :text in the All Notifications view
161+
* @Then an empty notifications state should be visible in the All Notifications view
162162
*/
163-
public function iShouldSeeTextInAllNotificationsView(string $expectedMessage): void
163+
public function emptyNotificationsStateInAllNotificationsView(): void
164164
{
165-
$this->notificationsViewAllPage->verifyNoNotificationsMessage($expectedMessage);
165+
$this->notificationsViewAllPage->assertEmptyStateVisible();
166166
}
167167

168168
/**
169-
* @Then the notifications popup should contain :expectedCount notification
169+
* @Then the notifications popup counter should display :expectedCount
170170
*/
171-
public function thereShouldBeNotificationsInPopup(int $expectedCount): void
171+
public function iShouldSeeNotificationsCountInPopup(int $expectedCount): void
172172
{
173173
$this->userNotificationPopup->verifyNotificationsCount($expectedCount);
174174
}
175175

176176
/**
177-
* @Then there should be :expectedCount notification in the All Notifications view
177+
* @Then I should see :expectedCount notifications in the All Notifications view
178178
*/
179179
public function thereShouldBeNotificationsInAllNotificationsView(int $expectedCount): void
180180
{

src/lib/Behat/Component/UserNotificationPopup.php

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ public function verifyNotification(string $expectedType, string $expectedAuthor,
6464

6565
foreach ($criteria as $criterion) {
6666
if (!$criterion->matches($notification)) {
67-
continue 2; // go to next notification
67+
continue 2;
6868
}
6969
}
7070

7171
if ($shouldExist) {
72-
return; // matching notification found
72+
return;
7373
} else {
7474
throw new \Exception(sprintf(
7575
'Notification of type "%s" with author "%s" and description "%s" should not exist, but was found.',
@@ -92,20 +92,9 @@ public function verifyNotification(string $expectedType, string $expectedAuthor,
9292

9393
public function openNotificationMenu(string $expectedDescription): void
9494
{
95-
$this->getHTMLPage()
96-
->setTimeout(10)
97-
->waitUntilCondition(
98-
new ElementExistsCondition(
99-
$this->getHTMLPage(),
100-
$this->getLocator('notificationDescriptionText')
101-
)
102-
);
103-
104-
$notifications = $this->getHTMLPage()->setTimeout(5)->findAll($this->getLocator('notificationItem'))
105-
->filterBy(new ChildElementTextCriterion($this->getLocator('notificationDescriptionText'), $expectedDescription));
106-
107-
$menuButton = $notifications->first()->find($this->getLocator('notificationMenuButton'));
108-
$menuButton->click();
95+
$this->getHTMLPage()->setTimeout(5)->findAll($this->getLocator('notificationItem'))
96+
->filterBy(new ChildElementTextCriterion($this->getLocator('notificationDescriptionText'), $expectedDescription))
97+
->first()->find($this->getLocator('notificationMenuButton'))->click();
10998

11099
$this->getHTMLPage()
111100
->setTimeout(10)
@@ -119,12 +108,10 @@ public function openNotificationMenu(string $expectedDescription): void
119108

120109
public function clickActionButton(string $buttonText): void
121110
{
122-
$buttons = $this->getHTMLPage()
111+
$this->getHTMLPage()
123112
->setTimeout(10)
124113
->findAll($this->getLocator('notificationMenuItemContent'))
125-
->filterBy(new ElementTextCriterion($buttonText));
126-
127-
$buttons->first()->execute(new MouseOverAndClick());
114+
->filterBy(new ElementTextCriterion($buttonText))->first()->execute(new MouseOverAndClick());
128115

129116
$this->getHTMLPage()
130117
->setTimeout(10)
@@ -136,7 +123,7 @@ public function clickActionButton(string $buttonText): void
136123
);
137124
}
138125

139-
public function getActionButton(string $buttonText): ?ElementInterface
126+
public function findActionButton(string $buttonText): ?ElementInterface
140127
{
141128
$this->getHTMLPage()
142129
->setTimeout(10)
@@ -154,16 +141,9 @@ public function getActionButton(string $buttonText): ?ElementInterface
154141
->first();
155142
}
156143

157-
public function verifyNoNotificationsMessage(string $expectedMessage): void
144+
public function assertEmptyStateVisible(): void
158145
{
159-
$this->getHTMLPage()->setTimeout(20)->waitUntilCondition(
160-
new ElementExistsCondition(
161-
$this->getHTMLPage(),
162-
$this->getLocator('notificationsEmptyText')
163-
)
164-
);
165-
166-
$this->getHTMLPage()->find($this->getLocator('notificationsEmptyText'))->assert()->textEquals($expectedMessage);
146+
$this->getHTMLPage()->setTimeout(5)->find($this->getLocator('notificationsEmptyText'))->assert()->isVisible();
167147
}
168148

169149
public function clickOnMarkAllAsReadButton(): void

src/lib/Behat/Page/NotificationsViewAllPage.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Ibexa\AdminUi\Behat\Component\Dialog;
1414
use Ibexa\AdminUi\Behat\Component\Table\TableBuilder;
1515
use Ibexa\AdminUi\Behat\Component\Table\TableInterface;
16-
use Ibexa\Behat\Browser\Element\Condition\ElementExistsCondition;
1716
use Ibexa\Behat\Browser\Element\Criterion\ChildElementTextCriterion;
1817
use Ibexa\Behat\Browser\Element\Criterion\ElementAttributeCriterion;
1918
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;
@@ -73,16 +72,9 @@ public function getStatusForNotification(string $notificationTitle): string
7372
->find($this->getLocator('rowStatus'))->getText();
7473
}
7574

76-
public function verifyNoNotificationsMessage(string $expectedMessage): void
75+
public function assertEmptyStateVisible(): void
7776
{
78-
$this->getHTMLPage()->setTimeout(10)->waitUntilCondition(
79-
new ElementExistsCondition(
80-
$this->getHTMLPage(),
81-
$this->getLocator('notificationsEmptyText')
82-
)
83-
);
84-
85-
$this->getHTMLPage()->find($this->getLocator('notificationsEmptyText'))->assert()->textEquals($expectedMessage);
77+
$this->getHTMLPage()->setTimeout(5)->find($this->getLocator('notificationsEmptyText'))->assert()->isVisible();
8678
}
8779

8880
public function verifyNotificationsCount(int $expectedCount): void

0 commit comments

Comments
 (0)