|
16 | 16 | use Behat\Behat\Context\Context; |
17 | 17 | use Sylius\Behat\NotificationType; |
18 | 18 | use Sylius\Behat\Service\NotificationCheckerInterface; |
| 19 | +use Sylius\Behat\TestAssertionHelper; |
| 20 | +use Sylius\Behat\TestAssertionHelperInterface; |
| 21 | +use Webmozart\Assert\Assert; |
19 | 22 |
|
20 | 23 | final class NotificationContext implements Context |
21 | 24 | { |
22 | 25 | /** @var NotificationCheckerInterface */ |
23 | 26 | private $notificationChecker; |
24 | 27 |
|
25 | | - public function __construct(NotificationCheckerInterface $notificationChecker) |
| 28 | + /** @var TestAssertionHelperInterface */ |
| 29 | + private $assertionHelper; |
| 30 | + |
| 31 | + public function __construct(NotificationCheckerInterface $notificationChecker, TestAssertionHelperInterface $assertionHelper) |
26 | 32 | { |
27 | 33 | $this->notificationChecker = $notificationChecker; |
| 34 | + $this->assertionHelper = $assertionHelper; |
28 | 35 | } |
29 | 36 |
|
30 | 37 | /** |
31 | 38 | * @Then I should be notified that it has been successfully created |
32 | 39 | */ |
33 | 40 | public function iShouldBeNotifiedItHasBeenSuccessfullyCreated() |
34 | 41 | { |
35 | | - $this->notificationChecker->checkNotification('has been successfully created.', NotificationType::success()); |
| 42 | + $this->assertionHelper->waitUntilAssertionPasses( |
| 43 | + 3, |
| 44 | + function (): void { |
| 45 | + $this->notificationChecker->checkNotification('has been successfully created.', NotificationType::success()); |
| 46 | + } |
| 47 | + ); |
36 | 48 | } |
37 | 49 |
|
38 | 50 | /** |
39 | 51 | * @Then I should be notified that it has been successfully edited |
40 | 52 | */ |
41 | 53 | public function iShouldBeNotifiedThatItHasBeenSuccessfullyEdited() |
42 | 54 | { |
43 | | - $this->notificationChecker->checkNotification('has been successfully updated.', NotificationType::success()); |
| 55 | + $this->assertionHelper->waitUntilAssertionPasses( |
| 56 | + 3, |
| 57 | + function (): void { |
| 58 | + $this->notificationChecker->checkNotification('has been successfully updated.', NotificationType::success()); |
| 59 | + } |
| 60 | + ); |
44 | 61 | } |
45 | 62 |
|
46 | 63 | /** |
47 | 64 | * @Then I should be notified that it has been successfully deleted |
48 | 65 | */ |
49 | 66 | public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted() |
50 | 67 | { |
51 | | - $this->notificationChecker->checkNotification('has been successfully deleted.', NotificationType::success()); |
| 68 | + $this->assertionHelper->waitUntilAssertionPasses( |
| 69 | + 3, |
| 70 | + function (): void { |
| 71 | + $this->notificationChecker->checkNotification('has been successfully deleted.', NotificationType::success()); |
| 72 | + } |
| 73 | + ); |
52 | 74 | } |
53 | 75 |
|
54 | 76 | /** |
55 | 77 | * @Then I should be notified that they have been successfully deleted |
56 | 78 | */ |
57 | 79 | public function iShouldBeNotifiedThatTheyHaveBeenSuccessfullyDeleted() |
58 | 80 | { |
59 | | - $this->notificationChecker->checkNotification('have been successfully deleted.', NotificationType::success()); |
| 81 | + $this->assertionHelper->waitUntilAssertionPasses( |
| 82 | + 3, |
| 83 | + function (): void { |
| 84 | + $this->notificationChecker->checkNotification('have been successfully deleted.', NotificationType::success()); |
| 85 | + } |
| 86 | + ); |
60 | 87 | } |
61 | 88 | } |
0 commit comments