1212use Behat \Gherkin \Node \TableNode ;
1313use Ibexa \AdminUi \Behat \Component \UpperMenu ;
1414use Ibexa \AdminUi \Behat \Component \UserNotificationPopup ;
15+ use Ibexa \AdminUi \Behat \Page \NotificationsPage ;
1516use PHPUnit \Framework \Assert ;
1617
1718class UserNotificationContext implements Context
@@ -22,10 +23,15 @@ class UserNotificationContext implements Context
2223 /** @var \Ibexa\AdminUi\Behat\Component\UserNotificationPopup */
2324 private $ userNotificationPopup ;
2425
25- public function __construct (UpperMenu $ upperMenu , UserNotificationPopup $ userNotificationPopup )
26+ private NotificationsPage $ notificationsPage ;
27+
28+ private int $ previousCount ;
29+
30+ public function __construct (UpperMenu $ upperMenu , UserNotificationPopup $ userNotificationPopup , NotificationsPage $ notificationsPage )
2631 {
2732 $ this ->upperMenu = $ upperMenu ;
2833 $ this ->userNotificationPopup = $ userNotificationPopup ;
34+ $ this ->notificationsPage = $ notificationsPage ;
2935 }
3036
3137 /**
@@ -49,9 +55,9 @@ public function iGoToUserNotificationWithDetails(TableNode $notificationDetails)
4955 }
5056
5157 /**
52- * @Then an unread notification appears with details:
58+ * @Then the notification appears with details:
5359 */
54- public function thereIsUnreadNotificationAppearsWithDetails (TableNode $ notificationDetails ): void
60+ public function thereIsNotificationAppearsWithDetails (TableNode $ notificationDetails ): void
5561 {
5662 $ type = $ notificationDetails ->getHash ()[0 ]['Type ' ];
5763 $ author = $ notificationDetails ->getHash ()[0 ]['Author ' ];
@@ -87,8 +93,93 @@ public function iOpenNotificationMenuNotification(string $description): void
8793 /**
8894 * @When I click :action action
8995 */
90- public function iDeleteTheNotification (): void
96+ public function iClickActionButton (string $ action ): void
97+ {
98+ $ this ->userNotificationPopup ->clickActionButton ($ action );
99+ }
100+
101+ /**
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
112+ */
113+ public function verifyNotificationCountChanged (string $ direction ): void
114+ {
115+ $ this ->userNotificationPopup ->verifyNotificationCountChanged ($ this ->previousCount , $ direction );
116+ }
117+
118+ /**
119+ * @When I click mark all as read button
120+ */
121+ public function iClickButton (): void
122+ {
123+ $ this ->userNotificationPopup ->verifyIsLoaded ();
124+ $ this ->userNotificationPopup ->clickOnMarkAllAsReadButton ();
125+ }
126+
127+ /**
128+ * @When I click view all notifications button
129+ */
130+ public function iClickViewAllNotificationsButton (): void
131+ {
132+ $ this ->userNotificationPopup ->verifyIsLoaded ();
133+ $ this ->userNotificationPopup ->clickViewAllNotificationsButton ();
134+ }
135+
136+ /**
137+ * @Then there is :notificationTitle notification on list
138+ */
139+ public function thereIsNotificationOnList (string $ notificationTitle ): void
140+ {
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 );
152+ }
153+
154+ /**
155+ * @When I marked as unread notification with title :notificationTitle
156+ */
157+ public function iMarkedNotificationAsUnread (string $ notificationTitle ): void
158+ {
159+ $ this ->notificationsPage ->markAsUnread ($ notificationTitle );
160+ }
161+
162+ /**
163+ * @Then the notification with title :notificationTitle has status :notificationStatus
164+ */
165+ public function verifyNotificationStatus (string $ notificationTitle , string $ notificationStatus ): void
166+ {
167+ Assert::assertEquals ($ notificationStatus , $ this ->notificationsPage ->getStatusForNotification ($ notificationTitle ));
168+ }
169+
170+ /**
171+ * @When I go to content of notification with title :notificationTitle
172+ */
173+ public function iGoToContent (string $ notificationTitle ): void
174+ {
175+ $ this ->notificationsPage ->goToContent ($ notificationTitle );
176+ }
177+
178+ /**
179+ * @When I deleted notification with title :notificationTitle
180+ */
181+ public function iDeleteNotification (string $ notificationTitle ): void
91182 {
92- $ this ->userNotificationPopup -> clickButton ( ' Delete ' );
183+ $ this ->notificationsPage -> deleteNotification ( $ notificationTitle );
93184 }
94185}
0 commit comments