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

Add Laravel Dusk testing #4497

Open
wants to merge 61 commits into
base: 1.0-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a7e2bd2
Add dusk
lancepioch Oct 26, 2022
f38f8db
Add base tests for dusk
lancepioch Oct 26, 2022
660c85a
Wip
lancepioch Oct 27, 2022
553c4f6
Add testing routes
lancepioch Oct 28, 2022
7db6665
Make sure migrations aren't rolled back
lancepioch Oct 28, 2022
cdf365a
Don't need this anymore
lancepioch Oct 28, 2022
8ee7652
Add main tests
lancepioch Oct 28, 2022
1810d62
Copy this in from docs
lancepioch Oct 28, 2022
a502aca
Add some variables
lancepioch Oct 28, 2022
3a772cb
Build front end
lancepioch Oct 28, 2022
0603350
Disable recaptcha
lancepioch Oct 28, 2022
d59cf52
Use domain from app url
lancepioch Oct 28, 2022
f7ed8af
Get the port out
lancepioch Oct 28, 2022
426c1ce
Add comments
lancepioch Oct 28, 2022
a45d054
Update comment
lancepioch Oct 28, 2022
126c06a
Update comments
lancepioch Oct 28, 2022
b8f50e5
Don't visit the same page twice
lancepioch Oct 28, 2022
edda6f8
Update these to the latest one
lancepioch Oct 28, 2022
56ae6c9
Forcefully generate a new one
lancepioch Oct 28, 2022
68b1f1e
Upload application logs too
lancepioch Oct 28, 2022
1d2a20d
Add temporary test logging
lancepioch Oct 28, 2022
d632fa9
Revert "Add temporary test logging"
lancepioch Oct 28, 2022
93162eb
Other testing
lancepioch Oct 28, 2022
f4312f5
Fix this step
lancepioch Oct 28, 2022
cd764b6
Fingers crossed
lancepioch Oct 28, 2022
ac5f8f8
php-cs-fixer
lancepioch Oct 28, 2022
a149e70
Try custom host
lancepioch Oct 28, 2022
9fbc35e
Revert "Try custom host"
lancepioch Oct 29, 2022
d781a7f
Try whitelisting all ips
lancepioch Oct 29, 2022
e7a0a2e
Cache these things yo
lancepioch Oct 29, 2022
2865ca5
Run composer after cache
lancepioch Oct 29, 2022
f791aec
Try adding curl test
lancepioch Oct 29, 2022
9b09a67
Try running this earlier
lancepioch Oct 29, 2022
82d608d
Switch back to direct ip
lancepioch Oct 29, 2022
f25fe6d
Try flagging it here
lancepioch Oct 29, 2022
f112fec
Does this make a difference?
lancepioch Oct 29, 2022
5692dca
This may make it much more confusing
lancepioch Oct 29, 2022
76af3dc
Remove logging
lancepioch Oct 29, 2022
e4b48c5
Try post requests
lancepioch Oct 29, 2022
408ca6e
Take out unnecessary tests
lancepioch Oct 29, 2022
eb13922
Run another instance
lancepioch Oct 29, 2022
664ef91
Use second instance of built in webserver
lancepioch Oct 29, 2022
6b2ccf8
Allow all for testing
lancepioch Oct 29, 2022
9592ba6
Seriously
lancepioch Oct 29, 2022
aa0b93e
Run cors middleware for testing routes
lancepioch Oct 29, 2022
ce0d6b9
Better naming for artifacts
lancepioch Oct 29, 2022
eb11ef5
Revert
lancepioch Oct 29, 2022
780f6f3
Whitelist these
lancepioch Oct 29, 2022
bc6768f
Try this back in
lancepioch Oct 29, 2022
ff73db3
Don't need this anymore
lancepioch Oct 29, 2022
381c777
Fix on local for now
lancepioch Oct 29, 2022
5ce5f2f
Merge branch '1.0-develop' into dusk
lancepioch Oct 29, 2022
da26f73
Fix my stuff with php-cs-fixer
lancepioch Oct 29, 2022
abadcd2
Fix not my stuff with php-cs-fixer
lancepioch Oct 29, 2022
c5b90e3
Add page for creating users
lancepioch Oct 31, 2022
8612e86
Update composer
lancepioch Feb 19, 2024
ee8f935
Merge branch '1.0-develop' into dusk
lancepioch Feb 20, 2024
b609cf0
Fix styling
lancepioch Feb 20, 2024
fececfb
Fix these
lancepioch Feb 20, 2024
249bdf6
Add redis
lancepioch Feb 20, 2024
b6ca0bd
empty
lancepioch Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/dusk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Dusk
on: [push]
jobs:

dusk-php:
runs-on: ubuntu-latest
env:
APP_URL: "http://127.0.0.1:8000"
APP_ENV: dusk
APP_CORS_ALLOWED_ORIGINS: "*"
DB_USERNAME: root
DB_PASSWORD: root
MAIL_MAILER: log
APP_KEY: "base64:8hOaU5CSjb45bxnFEToJwOsfhOpOvH/g4OWcoJPNyyE="
RECAPTCHA_ENABLED: false
steps:
- uses: actions/checkout@v3
- name: Prepare The Environment
run: cp .env.example .env
- name: Create Database
run: |
sudo systemctl start mysql
mysql --user="root" --password="root" -e "CREATE DATABASE \`panel\` character set UTF8mb4 collate utf8mb4_bin;"

- name: Get Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-8.1-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-8.1-

- name: Install Composer Dependencies
run: composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader

- name: Generate Application Key
run: php artisan key:generate --force --no-interaction

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: "yarn"

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build:production

- name: Install Redis
run: sudo apt-get install redis-server
- name: Start Redis Server
run: redis-server --daemonize yes
- name: Check Redis Server
run: redis-cli ping

- name: Run Laravel Server
run: php artisan serve --no-reload &

- name: Run Laravel Server Pseudo Daemon
run: php artisan serve --no-reload &

- name: Upgrade Chrome Driver
run: php artisan dusk:chrome-driver --detect
- name: Start Chrome Driver
run: ./vendor/laravel/dusk/bin/chromedriver-linux &

- name: Run Dusk Tests
run: php artisan dusk

- name: Upload Screenshots
if: failure()
uses: actions/upload-artifact@v3
with:
name: browser-screenshots
path: tests/Browser/screenshots
- name: Upload Console Logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: browser-console
path: tests/Browser/console
- name: Upload Application Logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: storage-logs
path: storage/logs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ resources/lang/locales.js
/public/hot
result
docker-compose.yaml
.phpunit.cache
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Kernel extends HttpKernel
'auth' => Authenticate::class,
'auth.basic' => AuthenticateWithBasicAuth::class,
'auth.session' => AuthenticateSession::class,
'cors' => HandleCors::class,
'guest' => RedirectIfAuthenticated::class,
'csrf' => VerifyCsrfToken::class,
'throttle' => ThrottleRequests::class,
Expand Down
23 changes: 23 additions & 0 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public function boot(): void
->prefix('/api/remote')
->scopeBindings()
->group(base_path('routes/api-remote.php'));

$this->duskBoot();
});
}

Expand Down Expand Up @@ -107,4 +109,25 @@ protected function configureRateLimiting(): void
)->by($key);
});
}

// Laravel Dusk Browser Testing Route Helpers for the Daemon
private function duskBoot()
{
// Make sure we're only running in the Dusk testing environment
if (!app()->environment('dusk')) {
return;
}

// Simulate Node Ping
Route::get('/api/system', fn () => [
'version' => '1.7.0',
'kernel_version' => '5.4.0-126-generic',
'architecture' => 'amd64',
'os' => 'linux',
'cpu_count' => 2,
]);

// Simulate Successful Server Creation
Route::post('/api/servers', fn () => []);
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"fakerphp/faker": "~1.21.0",
"friendsofphp/php-cs-fixer": "~3.14.4",
"itsgoingd/clockwork": "~5.1.12",
"laravel/dusk": "^7.12",
"laravel/sail": "~1.21.0",
"mockery/mockery": "~1.5.1",
"nunomaduro/collision": "~7.0.5",
Expand Down
146 changes: 144 additions & 2 deletions composer.lock

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

2 changes: 1 addition & 1 deletion config/cors.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* You can enable CORS for 1 or multiple paths.
* Example: ['api/*']
*/
'paths' => ['/api/client', '/api/application', '/api/client/*', '/api/application/*'],
'paths' => ['/api/client', '/api/application', '/api/client/*', '/api/application/*', '/api/servers', '/api/system'],

/*
* Matches the request method. `['*']` allows all methods.
Expand Down
Loading
Loading