2023-04-03 08:31:04 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests;
|
|
|
|
|
|
2024-10-17 19:18:37 +00:00
|
|
|
use Facebook\WebDriver\Chrome\ChromeOptions;
|
2023-04-03 08:31:04 +00:00
|
|
|
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
|
|
|
|
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
2024-10-17 19:18:37 +00:00
|
|
|
use Illuminate\Support\Collection;
|
2023-04-03 08:31:04 +00:00
|
|
|
use Laravel\Dusk\TestCase as BaseTestCase;
|
|
|
|
|
|
|
|
|
|
abstract class DuskTestCase extends BaseTestCase
|
|
|
|
|
{
|
|
|
|
|
use CreatesApplication;
|
|
|
|
|
|
2024-10-17 19:18:37 +00:00
|
|
|
/**
|
|
|
|
|
* Prepare for Dusk test execution.
|
|
|
|
|
*
|
|
|
|
|
* @beforeClass
|
|
|
|
|
*/
|
|
|
|
|
public static function prepare(): void
|
|
|
|
|
{
|
|
|
|
|
if (! static::runningInSail()) {
|
|
|
|
|
static::startChromeDriver();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create the RemoteWebDriver instance.
|
|
|
|
|
*/
|
2023-04-03 08:31:04 +00:00
|
|
|
protected function driver(): RemoteWebDriver
|
|
|
|
|
{
|
2024-10-17 19:18:37 +00:00
|
|
|
$options = (new ChromeOptions)->addArguments(collect([
|
|
|
|
|
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
|
|
|
|
|
])->unless($this->hasHeadlessDisabled(), function (Collection $items) {
|
|
|
|
|
return $items->merge([
|
|
|
|
|
'--disable-gpu',
|
|
|
|
|
'--headless=new',
|
|
|
|
|
]);
|
|
|
|
|
})->all());
|
|
|
|
|
|
2023-04-03 08:31:04 +00:00
|
|
|
return RemoteWebDriver::create(
|
2024-10-17 19:20:55 +00:00
|
|
|
'http://localhost:4444',
|
2024-10-17 19:18:37 +00:00
|
|
|
DesiredCapabilities::chrome()->setCapability(
|
|
|
|
|
ChromeOptions::CAPABILITY,
|
|
|
|
|
$options
|
|
|
|
|
)
|
2023-04-03 08:31:04 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-17 19:18:37 +00:00
|
|
|
/**
|
|
|
|
|
* Determine if the browser window should start maximized.
|
|
|
|
|
*/
|
2023-08-08 09:51:36 +00:00
|
|
|
protected function baseUrl()
|
2023-04-03 08:31:04 +00:00
|
|
|
{
|
2024-10-17 19:26:06 +00:00
|
|
|
return 'http://localhost:8000';
|
2023-04-03 08:31:04 +00:00
|
|
|
}
|
|
|
|
|
}
|