ADD laravel dusk
This commit is contained in:
parent
6fedf6a84f
commit
d3817eecc4
@ -32,6 +32,7 @@
|
|||||||
"fakerphp/faker": "^1.23",
|
"fakerphp/faker": "^1.23",
|
||||||
"knuckleswtf/scribe": "^5.0",
|
"knuckleswtf/scribe": "^5.0",
|
||||||
"laravel/boost": "^2.4",
|
"laravel/boost": "^2.4",
|
||||||
|
"laravel/dusk": "^8.5",
|
||||||
"laravel/pail": "^1.2.2",
|
"laravel/pail": "^1.2.2",
|
||||||
"laravel/sail": "^1.41",
|
"laravel/sail": "^1.41",
|
||||||
"mockery/mockery": "^1.6",
|
"mockery/mockery": "^1.6",
|
||||||
|
|||||||
142
composer.lock
generated
142
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "e0f1d8d7662b5a589c4fb33e4fb321a6",
|
"content-hash": "ec185cb1fddcfd26057ef51f712c4c19",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "ahmedhakeem/extra",
|
"name": "ahmedhakeem/extra",
|
||||||
@ -13260,6 +13260,80 @@
|
|||||||
},
|
},
|
||||||
"time": "2026-03-25T16:37:40+00:00"
|
"time": "2026-03-25T16:37:40+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "laravel/dusk",
|
||||||
|
"version": "v8.5.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/laravel/dusk.git",
|
||||||
|
"reference": "f9f75666bed46d1ebca13792447be6e753f4e790"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/laravel/dusk/zipball/f9f75666bed46d1ebca13792447be6e753f4e790",
|
||||||
|
"reference": "f9f75666bed46d1ebca13792447be6e753f4e790",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"ext-zip": "*",
|
||||||
|
"guzzlehttp/guzzle": "^7.5",
|
||||||
|
"illuminate/console": "^10.0|^11.0|^12.0|^13.0",
|
||||||
|
"illuminate/support": "^10.0|^11.0|^12.0|^13.0",
|
||||||
|
"php": "^8.1",
|
||||||
|
"php-webdriver/webdriver": "^1.15.2",
|
||||||
|
"symfony/console": "^6.2|^7.0|^8.0",
|
||||||
|
"symfony/finder": "^6.2|^7.0|^8.0",
|
||||||
|
"symfony/process": "^6.2|^7.0|^8.0",
|
||||||
|
"vlucas/phpdotenv": "^5.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"laravel/framework": "^10.0|^11.0|^12.0|^13.0",
|
||||||
|
"mockery/mockery": "^1.6",
|
||||||
|
"orchestra/testbench-core": "^8.19|^9.17|^10.8|^11.0",
|
||||||
|
"phpstan/phpstan": "^1.10",
|
||||||
|
"phpunit/phpunit": "^10.1|^11.0|^12.0.1",
|
||||||
|
"psy/psysh": "^0.11.12|^0.12",
|
||||||
|
"symfony/yaml": "^6.2|^7.0|^8.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-pcntl": "Used to gracefully terminate Dusk when tests are running."
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Laravel\\Dusk\\DuskServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Laravel\\Dusk\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Taylor Otwell",
|
||||||
|
"email": "taylor@laravel.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Laravel Dusk provides simple end-to-end testing and browser automation.",
|
||||||
|
"keywords": [
|
||||||
|
"laravel",
|
||||||
|
"testing",
|
||||||
|
"webdriver"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/laravel/dusk/issues",
|
||||||
|
"source": "https://github.com/laravel/dusk/tree/v8.5.0"
|
||||||
|
},
|
||||||
|
"time": "2026-03-21T11:50:49+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/mcp",
|
"name": "laravel/mcp",
|
||||||
"version": "v0.6.4",
|
"version": "v0.6.4",
|
||||||
@ -14469,6 +14543,72 @@
|
|||||||
},
|
},
|
||||||
"time": "2025-12-22T13:21:32+00:00"
|
"time": "2025-12-22T13:21:32+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "php-webdriver/webdriver",
|
||||||
|
"version": "1.16.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-webdriver/php-webdriver.git",
|
||||||
|
"reference": "ac0662863aa120b4f645869f584013e4c4dba46a"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/ac0662863aa120b4f645869f584013e4c4dba46a",
|
||||||
|
"reference": "ac0662863aa120b4f645869f584013e4c4dba46a",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-curl": "*",
|
||||||
|
"ext-json": "*",
|
||||||
|
"ext-zip": "*",
|
||||||
|
"php": "^7.3 || ^8.0",
|
||||||
|
"symfony/polyfill-mbstring": "^1.12",
|
||||||
|
"symfony/process": "^5.0 || ^6.0 || ^7.0 || ^8.0"
|
||||||
|
},
|
||||||
|
"replace": {
|
||||||
|
"facebook/webdriver": "*"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ergebnis/composer-normalize": "^2.20.0",
|
||||||
|
"ondram/ci-detector": "^4.0",
|
||||||
|
"php-coveralls/php-coveralls": "^2.4",
|
||||||
|
"php-mock/php-mock-phpunit": "^2.0",
|
||||||
|
"php-parallel-lint/php-parallel-lint": "^1.2",
|
||||||
|
"phpunit/phpunit": "^9.3",
|
||||||
|
"squizlabs/php_codesniffer": "^3.5",
|
||||||
|
"symfony/var-dumper": "^5.0 || ^6.0 || ^7.0 || ^8.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-simplexml": "For Firefox profile creation"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"lib/Exception/TimeoutException.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Facebook\\WebDriver\\": "lib/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.",
|
||||||
|
"homepage": "https://github.com/php-webdriver/php-webdriver",
|
||||||
|
"keywords": [
|
||||||
|
"Chromedriver",
|
||||||
|
"geckodriver",
|
||||||
|
"php",
|
||||||
|
"selenium",
|
||||||
|
"webdriver"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/php-webdriver/php-webdriver/issues",
|
||||||
|
"source": "https://github.com/php-webdriver/php-webdriver/tree/1.16.0"
|
||||||
|
},
|
||||||
|
"time": "2025-12-28T23:57:40+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phpdocumentor/reflection-common",
|
"name": "phpdocumentor/reflection-common",
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
|
|||||||
21
tests/Browser/ExampleTest.php
Normal file
21
tests/Browser/ExampleTest.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Browser;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
|
use Laravel\Dusk\Browser;
|
||||||
|
use Tests\DuskTestCase;
|
||||||
|
|
||||||
|
class ExampleTest extends DuskTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A basic browser test example.
|
||||||
|
*/
|
||||||
|
public function test_basic_example(): void
|
||||||
|
{
|
||||||
|
$this->browse(function (Browser $browser) {
|
||||||
|
$browser->visit('/')
|
||||||
|
->assertSee('Laravel');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
36
tests/Browser/Pages/HomePage.php
Normal file
36
tests/Browser/Pages/HomePage.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Browser\Pages;
|
||||||
|
|
||||||
|
use Laravel\Dusk\Browser;
|
||||||
|
|
||||||
|
class HomePage extends Page
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the URL for the page.
|
||||||
|
*/
|
||||||
|
public function url(): string
|
||||||
|
{
|
||||||
|
return '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assert that the browser is on the page.
|
||||||
|
*/
|
||||||
|
public function assert(Browser $browser): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the element shortcuts for the page.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function elements(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'@element' => '#selector',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
20
tests/Browser/Pages/Page.php
Normal file
20
tests/Browser/Pages/Page.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Browser\Pages;
|
||||||
|
|
||||||
|
use Laravel\Dusk\Page as BasePage;
|
||||||
|
|
||||||
|
abstract class Page extends BasePage
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the global element shortcuts for the site.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function siteElements(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'@element' => '#selector',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
2
tests/Browser/console/.gitignore
vendored
Normal file
2
tests/Browser/console/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
2
tests/Browser/source/.gitignore
vendored
Normal file
2
tests/Browser/source/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
48
tests/DuskTestCase.php
Normal file
48
tests/DuskTestCase.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
|
use Facebook\WebDriver\Chrome\ChromeOptions;
|
||||||
|
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
||||||
|
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Laravel\Dusk\TestCase as BaseTestCase;
|
||||||
|
use PHPUnit\Framework\Attributes\BeforeClass;
|
||||||
|
|
||||||
|
abstract class DuskTestCase extends BaseTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Prepare for Dusk test execution.
|
||||||
|
*/
|
||||||
|
#[BeforeClass]
|
||||||
|
public static function prepare(): void
|
||||||
|
{
|
||||||
|
if (! static::runningInSail()) {
|
||||||
|
static::startChromeDriver(['--port=9515']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the RemoteWebDriver instance.
|
||||||
|
*/
|
||||||
|
protected function driver(): RemoteWebDriver
|
||||||
|
{
|
||||||
|
$options = (new ChromeOptions)->addArguments(collect([
|
||||||
|
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
|
||||||
|
'--disable-search-engine-choice-screen',
|
||||||
|
'--disable-smooth-scrolling',
|
||||||
|
])->unless($this->hasHeadlessDisabled(), function (Collection $items) {
|
||||||
|
return $items->merge([
|
||||||
|
'--disable-gpu',
|
||||||
|
'--headless=new',
|
||||||
|
]);
|
||||||
|
})->all());
|
||||||
|
|
||||||
|
return RemoteWebDriver::create(
|
||||||
|
$_ENV['DUSK_DRIVER_URL'] ?? env('DUSK_DRIVER_URL') ?? 'http://localhost:9515',
|
||||||
|
DesiredCapabilities::chrome()->setCapability(
|
||||||
|
ChromeOptions::CAPABILITY, $options
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user