diff --git a/tests/Browser/AuthBrowserTest.php b/tests/Browser/AuthBrowserTest.php index d233471f..b37036be 100644 --- a/tests/Browser/AuthBrowserTest.php +++ b/tests/Browser/AuthBrowserTest.php @@ -2,14 +2,12 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Concerns\InteractsWithWmsData; use Tests\DuskTestCase; class AuthBrowserTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsData; public function test_login_page_renders_professional_auth_form(): void diff --git a/tests/Browser/DesktopNavigationBrowserTest.php b/tests/Browser/DesktopNavigationBrowserTest.php index 4388140c..95a9209b 100644 --- a/tests/Browser/DesktopNavigationBrowserTest.php +++ b/tests/Browser/DesktopNavigationBrowserTest.php @@ -2,7 +2,6 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Concerns\InteractsWithWmsBrowser; use Tests\Browser\Concerns\InteractsWithWmsData; @@ -10,7 +9,6 @@ use Tests\DuskTestCase; class DesktopNavigationBrowserTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsBrowser; use InteractsWithWmsData; diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php index 4d01aff2..973f7763 100644 --- a/tests/Browser/ExampleTest.php +++ b/tests/Browser/ExampleTest.php @@ -2,14 +2,12 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Concerns\InteractsWithWmsData; use Tests\DuskTestCase; class ExampleTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsData; public function test_public_homepage_is_reachable_in_browser(): void diff --git a/tests/Browser/MobileNavigationBrowserTest.php b/tests/Browser/MobileNavigationBrowserTest.php index f8c0ddc7..ffaf714f 100644 --- a/tests/Browser/MobileNavigationBrowserTest.php +++ b/tests/Browser/MobileNavigationBrowserTest.php @@ -2,7 +2,6 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Concerns\InteractsWithWmsBrowser; use Tests\Browser\Concerns\InteractsWithWmsData; @@ -10,7 +9,6 @@ use Tests\DuskTestCase; class MobileNavigationBrowserTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsBrowser; use InteractsWithWmsData; diff --git a/tests/Browser/PlatformAdministrationBrowserTest.php b/tests/Browser/PlatformAdministrationBrowserTest.php index 9e5cf4ee..5ce247f8 100644 --- a/tests/Browser/PlatformAdministrationBrowserTest.php +++ b/tests/Browser/PlatformAdministrationBrowserTest.php @@ -2,7 +2,6 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Concerns\InteractsWithWmsBrowser; use Tests\Browser\Concerns\InteractsWithWmsData; @@ -10,7 +9,6 @@ use Tests\DuskTestCase; class PlatformAdministrationBrowserTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsBrowser; use InteractsWithWmsData; diff --git a/tests/Browser/PlatformPricingBrowserTest.php b/tests/Browser/PlatformPricingBrowserTest.php index f43068ea..cb481d7b 100644 --- a/tests/Browser/PlatformPricingBrowserTest.php +++ b/tests/Browser/PlatformPricingBrowserTest.php @@ -2,7 +2,6 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Modules\Platform\app\Models\PlatformPrice; use Tests\Browser\Concerns\InteractsWithWmsBrowser; @@ -11,7 +10,6 @@ use Tests\DuskTestCase; class PlatformPricingBrowserTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsBrowser; use InteractsWithWmsData; diff --git a/tests/Browser/ResponsiveBaselineBrowserTest.php b/tests/Browser/ResponsiveBaselineBrowserTest.php index 8561e2ee..ef3a8233 100644 --- a/tests/Browser/ResponsiveBaselineBrowserTest.php +++ b/tests/Browser/ResponsiveBaselineBrowserTest.php @@ -2,7 +2,6 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Concerns\InteractsWithWmsBrowser; use Tests\Browser\Concerns\InteractsWithWmsData; @@ -10,7 +9,6 @@ use Tests\DuskTestCase; class ResponsiveBaselineBrowserTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsBrowser; use InteractsWithWmsData; diff --git a/tests/Browser/WarehouseBrowserTest.php b/tests/Browser/WarehouseBrowserTest.php index 9d7504e2..4d0707ae 100644 --- a/tests/Browser/WarehouseBrowserTest.php +++ b/tests/Browser/WarehouseBrowserTest.php @@ -2,7 +2,6 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Concerns\InteractsWithWmsBrowser; use Tests\Browser\Concerns\InteractsWithWmsData; @@ -10,7 +9,6 @@ use Tests\DuskTestCase; class WarehouseBrowserTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsBrowser; use InteractsWithWmsData; diff --git a/tests/Browser/WmsPricingCrudBrowserTest.php b/tests/Browser/WmsPricingCrudBrowserTest.php index 6a185579..7b76b833 100644 --- a/tests/Browser/WmsPricingCrudBrowserTest.php +++ b/tests/Browser/WmsPricingCrudBrowserTest.php @@ -2,7 +2,6 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Concerns\InteractsWithWmsBrowser; use Tests\Browser\Concerns\InteractsWithWmsData; @@ -10,7 +9,6 @@ use Tests\DuskTestCase; class WmsPricingCrudBrowserTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsBrowser; use InteractsWithWmsData; diff --git a/tests/Browser/WmsResponsiveNavigationTest.php b/tests/Browser/WmsResponsiveNavigationTest.php index 5f2293dd..c62793db 100644 --- a/tests/Browser/WmsResponsiveNavigationTest.php +++ b/tests/Browser/WmsResponsiveNavigationTest.php @@ -2,7 +2,6 @@ namespace Tests\Browser; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Concerns\InteractsWithWmsBrowser; use Tests\Browser\Concerns\InteractsWithWmsData; @@ -10,7 +9,6 @@ use Tests\DuskTestCase; class WmsResponsiveNavigationTest extends DuskTestCase { - use DatabaseMigrations; use InteractsWithWmsBrowser; use InteractsWithWmsData; diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php index c9b44caf..8a258190 100644 --- a/tests/DuskTestCase.php +++ b/tests/DuskTestCase.php @@ -5,19 +5,29 @@ namespace Tests; use Facebook\WebDriver\Chrome\ChromeOptions; use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\Remote\RemoteWebDriver; +use Illuminate\Support\Facades\Artisan; use Laravel\Dusk\TestCase as BaseTestCase; use PHPUnit\Framework\Attributes\BeforeClass; abstract class DuskTestCase extends BaseTestCase { + use CreatesApplication; + + /** + * Prepare for Dusk test execution. + */ #[BeforeClass] public static function prepare(): void { if (! static::runningInSail()) { + static::ensureChromeDriverBinaryAlias(); static::startChromeDriver(['--port=9515']); } } + /** + * Create the RemoteWebDriver instance. + */ protected function driver(): RemoteWebDriver { $options = (new ChromeOptions())->addArguments([ @@ -26,14 +36,65 @@ abstract class DuskTestCase extends BaseTestCase '--window-size=1920,1080', '--no-sandbox', '--disable-dev-shm-usage', + '--disable-search-engine-choice-screen', ]); return RemoteWebDriver::create( - env('DUSK_DRIVER_URL', 'http://localhost:9515'), + $_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515', DesiredCapabilities::chrome()->setCapability( ChromeOptions::CAPABILITY, $options ) ); } + + /** + * Dusk may install a differently named macOS Apple Silicon binary. + * Laravel Dusk still asks for chromedriver-mac-arm, so create that alias safely. + */ + private static function ensureChromeDriverBinaryAlias(): void + { + $binDirectory = base_path('vendor/laravel/dusk/bin'); + $expected = $binDirectory.'/chromedriver-mac-arm'; + + if (is_file($expected)) { + @chmod($expected, 0755); + + return; + } + + if (! is_dir($binDirectory)) { + @mkdir($binDirectory, 0755, true); + } + + try { + Artisan::call('dusk:chrome-driver'); + } catch (\Throwable) { + // + } + + $candidates = array_values(array_filter( + glob($binDirectory.'/chromedriver*') ?: [], + static function (string $path) use ($expected): bool { + return is_file($path) + && $path !== $expected + && ! str_ends_with($path, '.zip') + && ! str_ends_with($path, '.txt'); + } + )); + + usort($candidates, static function (string $left, string $right): int { + $score = static fn (string $path): int => + str_contains($path, 'mac-arm64') ? 0 + : (str_contains($path, 'mac-arm') ? 1 + : (str_contains($path, 'mac') ? 2 : 3)); + + return $score($left) <=> $score($right); + }); + + if ($candidates !== []) { + @copy($candidates[0], $expected); + @chmod($expected, 0755); + } + } }