Files
WMS/tests/Browser/Concerns/TestsResponsiveBreakpoints.php
T
2026-06-10 14:56:43 +01:00

47 lines
1.4 KiB
PHP

<?php
namespace Tests\Browser\Concerns;
use Closure;
use Laravel\Dusk\Browser;
trait TestsResponsiveBreakpoints
{
/**
* @return array<string, array{width:int, height:int}>
*/
protected function responsiveBreakpoints(): array
{
return [
'desktop' => ['width' => 1440, 'height' => 900],
'laptop' => ['width' => 1280, 'height' => 800],
'tablet_portrait' => ['width' => 768, 'height' => 1024],
'tablet_landscape' => ['width' => 1024, 'height' => 768],
'mobile' => ['width' => 390, 'height' => 844],
'small_mobile' => ['width' => 360, 'height' => 740],
];
}
/**
* Run a browser assertion across every supported WMS viewport.
*
* @param Closure(Browser, string): void $callback
*/
protected function eachBreakpoint(Browser $browser, Closure $callback): void
{
foreach ($this->responsiveBreakpoints() as $name => $size) {
$browser->resize($size['width'], $size['height']);
$callback($browser, $name);
$browser->screenshot("wms-responsive-{$name}");
}
}
/**
* Decide whether the breakpoint should use the off-canvas mobile navigation.
*/
protected function isMobileNavigationBreakpoint(string $breakpoint): bool
{
return in_array($breakpoint, ['tablet_portrait', 'mobile', 'small_mobile'], true);
}
}