Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#809 wai parameter baseline screenshot #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
23 changes: 15 additions & 8 deletions src/Commands/ScreenshotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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'];

Expand Down