From 12c35ea0a979ba135ac405b05a9570e1864919d1 Mon Sep 17 00:00:00 2001 From: Mihai Mazuro Date: Fri, 6 Sep 2024 01:18:31 +0300 Subject: [PATCH] #809 wai parameter baseline screenshot --- README.md | 2 +- src/Commands/ScreenshotCommand.php | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9ea801f..6ae25a2 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ PAGE_NUMBER is number of the page results (starts from 0) There are two commands available to work with baseline set ```shell script -diffy screenshot:create-baseline PROJECT_ID ENVIRONMENT --wait # will create set of screenshots and set them as baseline right away +diffy screenshot:create-baseline PROJECT_ID ENVIRONMENT # will create set of screenshots and set them as baseline right away diffy screenshot:set-baseline PROJECT_ID SCREENSHOT_ID # set screenshots SCREENSHOT_ID as a baseline ``` diff --git a/src/Commands/ScreenshotCommand.php b/src/Commands/ScreenshotCommand.php index 87f5400..f1f3df9 100644 --- a/src/Commands/ScreenshotCommand.php +++ b/src/Commands/ScreenshotCommand.php @@ -67,14 +67,21 @@ public function createScreenshot($projectId, $environment, array $options = ['wa sleep($sleep); $i = 0; $screenshot = Screenshot::retrieve($screenshotId); - while ($i < $max_wait / $sleep) { - if ($screenshot->isCompleted()) { - break; + if ($max_wait !== 1200) { + while ($i < $max_wait / $sleep) { + if ($screenshot->isCompleted()) { + break; + } + sleep($sleep); + $screenshot->refresh(); + + $i += $sleep; + } + } else { + while (!$screenshot->isCompleted()) { + sleep($sleep); + $screenshot->refresh(); } - sleep($sleep); - $screenshot->refresh(); - - $i += $sleep; } } @@ -184,7 +191,7 @@ public function createScreenshotUpload($projectId, string $configurationPath) * @usage screenshot:create-baseline 342 production Take screenshot from production on project 342. * @usage screenshot:create-baseline 342 production --wait Take the screenshot and wait till they are completed. */ - public function createScreenshotBaseline($projectId, $environment, array $options = ['wait' => false, 'max-wait' => 1200]) + public function createScreenshotBaseline($projectId, $environment, array $options = ['wait' => true, 'max-wait' => 1200]) { $apiKey = Config::getConfig()['key'];