1212use Behat \Gherkin \Node \TableNode ;
1313use Ibexa \AdminUi \Behat \Component \UpperMenu ;
1414use Ibexa \AdminUi \Behat \Component \UserNotificationPopup ;
15- use Ibexa \AdminUi \Behat \Page \NotificationsPage ;
15+ use Ibexa \AdminUi \Behat \Page \NotificationsViewAllPage ;
1616use PHPUnit \Framework \Assert ;
1717
1818class UserNotificationContext implements Context
@@ -23,15 +23,13 @@ class UserNotificationContext implements Context
2323 /** @var \Ibexa\AdminUi\Behat\Component\UserNotificationPopup */
2424 private $ userNotificationPopup ;
2525
26- private NotificationsPage $ notificationsPage ;
26+ private NotificationsViewAllPage $ notificationsViewAllPage ;
2727
28- private int $ previousCount ;
29-
30- public function __construct (UpperMenu $ upperMenu , UserNotificationPopup $ userNotificationPopup , NotificationsPage $ notificationsPage )
28+ public function __construct (UpperMenu $ upperMenu , UserNotificationPopup $ userNotificationPopup , NotificationsViewAllPage $ notificationsViewAllPage )
3129 {
3230 $ this ->upperMenu = $ upperMenu ;
3331 $ this ->userNotificationPopup = $ userNotificationPopup ;
34- $ this ->notificationsPage = $ notificationsPage ;
32+ $ this ->notificationsViewAllPage = $ notificationsViewAllPage ;
3533 }
3634
3735 /**
@@ -68,25 +66,12 @@ public function thereIsNotificationAppearsWithDetails(TableNode $notificationDet
6866 $ this ->userNotificationPopup ->verifyNotification ($ type , $ author , $ description , $ date , true );
6967 }
7068
71- /**
72- * @Then no notification appears with details:
73- */
74- public function noNotificationAppearsWithDetails (TableNode $ notificationDetails ): void
75- {
76- $ type = $ notificationDetails ->getHash ()[0 ]['Type ' ];
77- $ author = $ notificationDetails ->getHash ()[0 ]['Author ' ];
78- $ description = $ notificationDetails ->getHash ()[0 ]['Description ' ];
79- $ date = $ notificationDetails ->getHash ()[0 ]['Date ' ];
80-
81- $ this ->userNotificationPopup ->verifyIsLoaded ();
82- $ this ->userNotificationPopup ->verifyNotification ($ type , $ author , $ description , $ date , false );
83- }
84-
8569 /**
8670 * @When I open notification menu with description :description
8771 */
8872 public function iOpenNotificationMenu (string $ description ): void
8973 {
74+ $ this ->userNotificationPopup ->verifyIsLoaded ();
9075 $ this ->userNotificationPopup ->openNotificationMenu ($ description );
9176 }
9277
@@ -99,20 +84,11 @@ public function iClickActionButton(string $action): void
9984 }
10085
10186 /**
102- * @When I store current notification count
103- */
104- public function storeNotificationCount (): void
105- {
106- $ this ->userNotificationPopup ->verifyIsLoaded ();
107- $ this ->previousCount = $ this ->userNotificationPopup ->getNotificationCount ();
108- }
109-
110- /**
111- * @Then the notification count should change in :direction direction
87+ * @Then the notification action should be :expectedAction
11288 */
113- public function verifyNotificationCountChanged (string $ direction ): void
89+ public function verifyNotificationAction (string $ expectedAction ): void
11490 {
115- $ this ->userNotificationPopup ->verifyNotificationCountChanged ( $ this -> previousCount , $ direction );
91+ $ this ->userNotificationPopup ->getActionButton ( $ expectedAction );
11692 }
11793
11894 /**
@@ -138,48 +114,55 @@ public function iClickViewAllNotificationsButton(): void
138114 */
139115 public function thereIsNotificationOnList (string $ notificationTitle ): void
140116 {
141- $ this ->notificationsPage ->verifyIsLoaded ();
142- $ this ->notificationsPage ->verifyNotificationIsOnList ($ notificationTitle );
143- }
144-
145- /**
146- * @Then there is no :notificationTitle notification on list
147- */
148- public function thereIsNoNotificationOnList (string $ notificationTitle ): void
149- {
150- $ this ->notificationsPage ->verifyIsLoaded ();
151- $ this ->notificationsPage ->verifyNotificationIsNotOnList ($ notificationTitle );
117+ $ this ->notificationsViewAllPage ->verifyIsLoaded ();
118+ $ this ->notificationsViewAllPage ->verifyNotificationIsOnList ($ notificationTitle );
152119 }
153120
154121 /**
155122 * @When I mark notification as unread with title :notificationTitle
156123 */
157124 public function iMarkNotificationAsUnread (string $ notificationTitle ): void
158125 {
159- $ this ->notificationsPage ->markAsUnread ($ notificationTitle );
126+ $ this ->notificationsViewAllPage ->markAsUnread ($ notificationTitle );
160127 }
161128
162129 /**
163130 * @Then the notification with title :notificationTitle has status :notificationStatus
164131 */
165132 public function verifyNotificationStatus (string $ notificationTitle , string $ notificationStatus ): void
166133 {
167- Assert::assertEquals ($ notificationStatus , $ this ->notificationsPage ->getStatusForNotification ($ notificationTitle ));
134+ Assert::assertEquals ($ notificationStatus , $ this ->notificationsViewAllPage ->getStatusForNotification ($ notificationTitle ));
168135 }
169136
170137 /**
171138 * @When I go to content of notification with title :notificationTitle
172139 */
173140 public function iGoToContent (string $ notificationTitle ): void
174141 {
175- $ this ->notificationsPage ->goToContent ($ notificationTitle );
142+ $ this ->notificationsViewAllPage ->goToContent ($ notificationTitle );
176143 }
177144
178145 /**
179146 * @When I delete notification with title :notificationTitle
180147 */
181148 public function iDeleteNotification (string $ notificationTitle ): void
182149 {
183- $ this ->notificationsPage ->deleteNotification ($ notificationTitle );
150+ $ this ->notificationsViewAllPage ->deleteNotification ($ notificationTitle );
151+ }
152+
153+ /**
154+ * @Then I should see the text :text in the notifications popup
155+ */
156+ public function iShouldSeeTextInNotificationsPopup (string $ expectedMessage ): void
157+ {
158+ $ this ->userNotificationPopup ->verifyNoNotificationsMessage ($ expectedMessage );
159+ }
160+
161+ /**
162+ * @Then I should see the text :text in the All Notifications view
163+ */
164+ public function iShouldSeeTextInAllNotificationsView (string $ expectedMessage ): void
165+ {
166+ $ this ->notificationsViewAllPage ->verifyNoNotificationsMessage ($ expectedMessage );
184167 }
185168}
0 commit comments