Skip to content

Commit

Permalink
feat: skipNetworkIdle has now a default parameter set to true
Browse files Browse the repository at this point in the history
  • Loading branch information
gulien committed Sep 29, 2024
1 parent 529bf88 commit e8bc519
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
7 changes: 4 additions & 3 deletions src/Modules/ChromiumMultipartFormDataModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ public function failOnConsoleExceptions(): self
}

/**
* Tells Chromium to not wait for its network to be idle.
* Specifies whether Chromium have to wait or not for its network to be
* idle.
*/
public function skipNetworkIdleEvent(): self
public function skipNetworkIdleEvent(bool $skip = true): self
{
$this->formValue('skipNetworkIdleEvent', true);
$this->formValue('skipNetworkIdleEvent', $skip);

return $this;
}
Expand Down
16 changes: 8 additions & 8 deletions tests/Modules/ChromiumPdfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function (
array $extraHttpHeaders = [],
array $failOnHttpStatusCodes = [],
bool $failOnConsoleExceptions = false,
bool $skipNetworkIdleEvent = false,
bool|null $skipNetworkIdleEvent = null,
string|null $pdfa = null,
bool $pdfua = false,
array $metadata = [],
Expand Down Expand Up @@ -197,7 +197,7 @@ function (
array $extraHttpHeaders = [],
array $failOnHttpStatusCodes = [],
bool $failOnConsoleExceptions = false,
bool $skipNetworkIdleEvent = false,
bool|null $skipNetworkIdleEvent = null,
string|null $pdfa = null,
bool $pdfua = false,
array $metadata = [],
Expand Down Expand Up @@ -355,7 +355,7 @@ function (
array $extraHttpHeaders = [],
array $failOnHttpStatusCodes = [],
bool $failOnConsoleExceptions = false,
bool $skipNetworkIdleEvent = false,
bool|null $skipNetworkIdleEvent = null,
string|null $pdfa = null,
bool $pdfua = false,
array $metadata = [],
Expand Down Expand Up @@ -523,7 +523,7 @@ function hydrateChromiumPdfFormData(
array $extraHttpHeaders = [],
array $failOnHttpStatusCodes = [],
bool $failOnConsoleExceptions = false,
bool $skipNetworkIdleEvent = false,
bool|null $skipNetworkIdleEvent = null,
string|null $pdfa = null,
bool $pdfua = false,
array $metadata = [],
Expand Down Expand Up @@ -609,8 +609,8 @@ function hydrateChromiumPdfFormData(
$chromium->failOnConsoleExceptions();
}

if ($skipNetworkIdleEvent) {
$chromium->skipNetworkIdleEvent();
if ($skipNetworkIdleEvent !== null) {
$chromium->skipNetworkIdleEvent($skipNetworkIdleEvent);
}

if ($pdfa !== null) {
Expand Down Expand Up @@ -664,7 +664,7 @@ function expectChromiumPdfOptions(
array $extraHttpHeaders,
array $failOnHttpStatusCodes,
bool $failOnConsoleExceptions,
bool $skipNetworkIdleEvent,
bool|null $skipNetworkIdleEvent,
string|null $pdfa,
bool $pdfua,
array $metadata,
Expand Down Expand Up @@ -737,7 +737,7 @@ function expectChromiumPdfOptions(
}

expect($body)->unless($failOnConsoleExceptions === false, fn ($body) => $body->toContainFormValue('failOnConsoleExceptions', '1'));
expect($body)->unless($skipNetworkIdleEvent === false, fn ($body) => $body->toContainFormValue('skipNetworkIdleEvent', '1'));
expect($body)->unless($skipNetworkIdleEvent === null, fn ($body) => $body->toContainFormValue('skipNetworkIdleEvent', $skipNetworkIdleEvent === true ? '1' : '0'));
expect($body)->unless($pdfa === null, fn ($body) => $body->toContainFormValue('pdfa', $pdfa));
expect($body)->unless($pdfua === false, fn ($body) => $body->toContainFormValue('pdfua', '1'));

Expand Down
16 changes: 8 additions & 8 deletions tests/Modules/ChromiumScreenshotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function (
array $extraHttpHeaders = [],
array $failOnHttpStatusCodes = [],
bool $failOnConsoleExceptions = false,
bool $skipNetworkIdleEvent = false,
bool|null $skipNetworkIdleEvent = null,
array $assets = [],
): void {
$chromium = Gotenberg::chromium('')->screenshot();
Expand Down Expand Up @@ -142,7 +142,7 @@ function (
array $extraHttpHeaders = [],
array $failOnHttpStatusCodes = [],
bool $failOnConsoleExceptions = false,
bool $skipNetworkIdleEvent = false,
bool|null $skipNetworkIdleEvent = null,
array $assets = [],
): void {
$chromium = Gotenberg::chromium('')->screenshot();
Expand Down Expand Up @@ -255,7 +255,7 @@ function (
array $extraHttpHeaders = [],
array $failOnHttpStatusCodes = [],
bool $failOnConsoleExceptions = false,
bool $skipNetworkIdleEvent = false,
bool|null $skipNetworkIdleEvent = null,
array $assets = [],
): void {
$chromium = Gotenberg::chromium('')->screenshot();
Expand Down Expand Up @@ -378,7 +378,7 @@ function hydrateChromiumScreenshotFormData(
array $extraHttpHeaders = [],
array $failOnHttpStatusCodes = [],
bool $failOnConsoleExceptions = false,
bool $skipNetworkIdleEvent = false,
bool|null $skipNetworkIdleEvent = null,
array $assets = [],
): ChromiumScreenshot {
if ($width !== null) {
Expand Down Expand Up @@ -453,8 +453,8 @@ function hydrateChromiumScreenshotFormData(
$chromium->failOnConsoleExceptions();
}

if ($skipNetworkIdleEvent) {
$chromium->skipNetworkIdleEvent();
if ($skipNetworkIdleEvent !== null) {
$chromium->skipNetworkIdleEvent($skipNetworkIdleEvent);
}

if (count($assets) > 0) {
Expand Down Expand Up @@ -487,7 +487,7 @@ function expectChromiumScreenshotOptions(
array $extraHttpHeaders,
array $failOnHttpStatusCodes,
bool $failOnConsoleExceptions,
bool $skipNetworkIdleEvent,
bool|null $skipNetworkIdleEvent,
array $assets,
): void {
expect($body)->unless($width === null, fn ($body) => $body->toContainFormValue('width', $width . ''));
Expand Down Expand Up @@ -531,7 +531,7 @@ function expectChromiumScreenshotOptions(
}

expect($body)->unless($failOnConsoleExceptions === false, fn ($body) => $body->toContainFormValue('failOnConsoleExceptions', '1'));
expect($body)->unless($skipNetworkIdleEvent === false, fn ($body) => $body->toContainFormValue('skipNetworkIdleEvent', '1'));
expect($body)->unless($skipNetworkIdleEvent === null, fn ($body) => $body->toContainFormValue('skipNetworkIdleEvent', $skipNetworkIdleEvent === true ? '1' : '0'));

if (count($assets) <= 0) {
return;
Expand Down

0 comments on commit e8bc519

Please sign in to comment.