diff --git a/features/admin/statistics.feature b/features/admin/statistics.feature index 1ab134b851..32386f01ae 100644 --- a/features/admin/statistics.feature +++ b/features/admin/statistics.feature @@ -47,7 +47,7 @@ Feature: Statistics And 4 more new customers have paid 5 orders placed for total of "$5,000.37" And 2 more new customers have paid 2 orders placed for total of "$5,000.37" When I view statistics for "United States" channel and previous year split by month - And I view statistics for "United States" channel and next year split by month + And I view statistics for "United States" channel and next year Then I should see 6 new customers And I should see 7 paid orders And there should be total sales of "$10,000.74" diff --git a/src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php b/src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php index 0bade6702e..87cb513af4 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php @@ -76,6 +76,26 @@ final class DashboardContext implements Context }; } + /** + * @When /^I view statistics for ("[^"]+" channel) and (previous|next) year$/ + * + * @throws UnexpectedPageException + */ + public function iViewStatisticsForPreviousPeriod( + ChannelInterface $channel, + string $period, + ): void { + if (!$this->dashboardPage->isOpen(['channel' => $channel->getCode()])) { + $this->dashboardPage->open(['channel' => $channel->getCode()]); + } + + match ($period) { + 'previous' => $this->dashboardPage->choosePreviousPeriod(), + 'next' => $this->dashboardPage->chooseNextPeriod(), + default => null, + }; + } + /** * @When I choose :channelName channel */