From 6e5e23cbb7983ba1634c20fdca08387a70c13a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Thu, 19 Sep 2024 23:30:01 +0200 Subject: [PATCH] Add acceptance test for automation analytics stats in the flow with if/else steps included [MAILPOET-6230] --- .../acceptance/Automation/AnalyticsCest.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mailpoet/tests/acceptance/Automation/AnalyticsCest.php b/mailpoet/tests/acceptance/Automation/AnalyticsCest.php index 9413eb216e..4d4282aaf6 100644 --- a/mailpoet/tests/acceptance/Automation/AnalyticsCest.php +++ b/mailpoet/tests/acceptance/Automation/AnalyticsCest.php @@ -7,6 +7,7 @@ use MailPoet\Automation\Engine\Data\AutomationRun; use MailPoet\Automation\Engine\Data\Step; use MailPoet\Automation\Engine\Data\Subject; use MailPoet\Automation\Integrations\Core\Actions\DelayAction; +use MailPoet\Automation\Integrations\Core\Actions\IfElseAction; use MailPoet\Automation\Integrations\MailPoet\Actions\SendEmailAction; use MailPoet\Automation\Integrations\MailPoet\Subjects\SubscriberSubject; use MailPoet\DI\ContainerWrapper; @@ -35,11 +36,14 @@ class AnalyticsCest { $this->newsletter1 = $this->createNewsletter("Email 1"); $this->newsletter2 = $this->createNewsletter("Email 2"); $createdAt = (new \DateTimeImmutable())->modify('-2 years'); + $delayAction = new Step(uniqid(), Step::TYPE_ACTION, DelayAction::KEY, ['delay_type' => 'MINUTES', 'delay' => 1], []); $factory = (new DataFactories\Automation()) ->withName('Someone Subscribed Automation') ->withSomeoneSubscribesTrigger() ->withSendEmailStep($this->newsletter1) + ->withIfElseStep($delayAction) ->withDelayAction() + ->withIfElseStep() ->withSendEmailStep($this->newsletter2) ->withStatusActive() ->withCreatedAt($createdAt); @@ -178,6 +182,8 @@ class AnalyticsCest { $delayStep = null; $firstEmailStep = null; $secondEmailStep = null; + $firstIfElseStep = null; + $secondIfElseStep = null; foreach ($automationSteps as $step) { if ($step->getKey() === DelayAction::KEY) { $delayStep = $step->getId(); @@ -188,6 +194,13 @@ class AnalyticsCest { if ($step->getKey() === SendEmailAction::KEY && $step->getArgs()['email_id'] === $this->newsletter2->getId()) { $secondEmailStep = $step->getId(); } + if ($step->getKey() === IfElseAction::KEY) { + if ($step->getNextStepIds()[1] !== null) { + $firstIfElseStep = $step->getId(); + } else { + $secondIfElseStep = $step->getId(); + } + } } // 1 subscriber is waiting at core:delay $this->createRunForSubscriber($this->createSubscriber(), $delayStep, AutomationRun::STATUS_RUNNING); @@ -200,10 +213,20 @@ class AnalyticsCest { $i->see('0% (0) waiting', '#step-' . $firstEmailStep); $i->see('100% (3) completed', '.mailpoet-automation-analytics-separator-' . $firstEmailStep); + $i->scrollTo('.mailpoet-automation-analytics-separator-' . $firstIfElseStep); + $i->see('0% (0) waiting', '#step-' . $firstIfElseStep); + $i->see('100% (3) completed', '.mailpoet-automation-analytics-separator-' . $firstIfElseStep); + $i->see('0% (0) completed', '.mailpoet-automation-analytics-separator-' . $firstIfElseStep); + $i->scrollTo('.mailpoet-automation-analytics-separator-' . $delayStep); $i->see('33% (1) waiting', '#step-' . $delayStep); $i->see('67% (2) completed', '.mailpoet-automation-analytics-separator-' . $delayStep); + $i->scrollTo('.mailpoet-automation-analytics-separator-' . $secondIfElseStep); + $i->see('0% (0) waiting', '#step-' . $secondIfElseStep); + $i->see('67% (2) completed', '.mailpoet-automation-analytics-separator-' . $secondIfElseStep); + $i->see('0% (0) completed', '.mailpoet-automation-analytics-separator-' . $secondIfElseStep); + $i->scrollTo('.mailpoet-automation-editor-automation-end'); $i->see('0% (0) waiting', '#step-' . $secondEmailStep); $i->see('67% (2) completed', '.mailpoet-automation-analytics-separator-' . $secondEmailStep);