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

Feature/#262 laravel dusk #402

Draft
wants to merge 11 commits into
base: development
Choose a base branch
from
96 changes: 96 additions & 0 deletions .env.dusk.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# General purpose
APP_NAME=laravel.test
APP_ENV=testing
APP_KEY=base64:oUYPi9KdHzqa5pjSQ8zgyMoPVCcKZKAYtzLzIaM/ysk=
APP_DEBUG=true
APP_URL=http://laravel.test:80
APP_SERVICE=laravel.app
APP_TIMEZONE='Europe/Amsterdam'

# Development tools
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

# Database
DB_CONNECTION=mysql
DB_HOST=host.docker.internal
DB_PORT=3306
DB_DATABASE=conference
DB_USERNAME=sail
DB_PASSWORD=password

# Laravel essentials
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=database
SESSION_LIFETIME=120

# Mail pit
MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

# Laravel Dusk
BROWSER_TYPE=chrome
DUSK_DRIVER=chrome
DUSK_DRIVER_URL='http://selenium:4444'
DUSK_DRIVER_BINARY=null
DUSK_HEADLESS=false
DUSK_PORT=7900
DUSK_HOST=127.0.0.1
DUSK_URL=http://localhost

# Third party API's
VITE_MAPBOX_API_KEY=

# Customizable variables in case the defaults are causing issues. Defaults are filled in.

#WWWUSER=1000
#WWWGROUP=1000

#VITE_PORT=5173

#SAIL_XDEBUG_MODE=off
#SAIL_XDEBUG_CONFIG=client_host=host.docker.internal

#FORWARD_DB_PORT=3306

#FORWARD_MAILPIT_PORT=1025
#FORWARD_MAILPIT_DASHBOARD_PORT=8025


# Stuff held over incase we need it in the future.

#MEMCACHED_HOST=127.0.0.1

#REDIS_HOST=127.0.0.1
#REDIS_PASSWORD=null
#REDIS_PORT=6379

#AWS_ACCESS_KEY_ID=
#AWS_SECRET_ACCESS_KEY=
#AWS_DEFAULT_REGION=us-east-1
#AWS_BUCKET=
#AWS_USE_PATH_STYLE_ENDPOINT=false

#PUSHER_APP_ID=
#PUSHER_APP_KEY=
#PUSHER_APP_SECRET=
#PUSHER_HOST=
#PUSHER_PORT=443
#PUSHER_SCHEME=https
#PUSHER_APP_CLUSTER=mt1

#VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
#VITE_PUSHER_HOST="${PUSHER_HOST}"
#VITE_PUSHER_PORT="${PUSHER_PORT}"
#VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
#VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

# Laravel Dusk
BROWSER_TYPE=chrome
DUSK_DRIVER=firefox
DUSK_DRIVER_BINARY=null
DUSK_HEADLESS=false
DUSK_DISABLE_DISPLAY=true
DUSK_PORT=9515
DUSK_HOST=127.0.0.1
DUSK_URL=http://localhost

# Third party API's
VITE_MAPBOX_API_KEY=

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/dusk": "^8.2",
"laravel/pint": "^1.13",
"laravel/sail": "^1.26",
"mockery/mockery": "^1.6",
Expand Down
142 changes: 140 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
image: sail-8.3/app
extra_hosts:
- 'host.docker.internal:host-gateway'
- 'laravel.test:host-gateway'
ports:
- '${APP_PORT:-80}:80'
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
Expand All @@ -24,6 +25,7 @@ services:
depends_on:
- mysql
- mailpit
- selenium
mysql:
image: 'mysql/mysql-server:8.0'
ports:
Expand Down Expand Up @@ -55,6 +57,18 @@ services:
- '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025'
networks:
- sail
selenium:
image: 'selenium/standalone-chrome'
extra_hosts:
- 'host.docker.internal:host-gateway'
- 'laravel.test:host-gateway'
volumes:
- '/dev/shm:/dev/shm'
ports:
- '${FORWARD_SELENIUM_PORT:-4444}:4444'
- '${FORWARD_SELENIUM_HEADFUL_PORT:-7900}:7900'
networks:
- sail
networks:
sail:
driver: bridge
Expand Down
23 changes: 23 additions & 0 deletions tests/Browser/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Tests\Browser;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
use Throwable;

class ExampleTest extends DuskTestCase
{
/**
* A basic browser test example.
* @throws Throwable
*/
public function testBasicExample(): void
{
$this->browse(function (Browser $browser) {
$browser->visit('/')
->assertSee('We are in IT together Conference');
});
}
}
36 changes: 36 additions & 0 deletions tests/Browser/Pages/HomePage.php
Original file line number Diff line number Diff line change
@@ -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',
];
}
}
Loading
Loading