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

feat: skipNetworkIdle has now a default parameter set to true #49

Merged
merged 1 commit into from
Sep 29, 2024
Merged
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
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