Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

test dusk gh

Andras Bacsaibecaf92fd899
diff --git a/.env.development.example b/.env.development.example
index 9419492fe8..d4daed4f74 100644
--- a/.env.development.example
+++ b/.env.development.example
@@ -8,11 +8,6 @@ APP_PORT=8000
APP_DEBUG=true
SSH_MUX_ENABLED=true
-# Selenium Driver URL for Dusk
-DUSK_DRIVER_URL=http://selenium:4444
-DUSK_PASSWORD=password
-
# PostgreSQL Database Configuration
DB_DATABASE=coolify
DB_USERNAME=coolify
diff --git a/.env.dusk.ci b/.env.dusk.ci
new file mode 100644
index 0000000000..9660de7b48
--- /dev/null
+++ b/.env.dusk.ci
@@ -0,0 +1,15 @@
+APP_ENV=production
+APP_NAME="Coolify Staging"
+APP_ID=development
+APP_KEY=
+APP_URL=http://localhost
+APP_PORT=8000
+SSH_MUX_ENABLED=true
+
+# PostgreSQL Database Configuration
+DB_DATABASE=coolify
+DB_USERNAME=coolify
+DB_PASSWORD=password
+DB_HOST=localhost
+DB_PORT=5432
+
diff --git a/.github/workflows/browser-tests.yml b/.github/workflows/browser-tests.yml
new file mode 100644
index 0000000000..fd9d17dbb5
--- /dev/null
+++ b/.github/workflows/browser-tests.yml
@@ -0,0 +1,65 @@
+name: Dusk
+on:
+ push:
+ branches: [ "next" ]
+jobs:
+ dusk:
+ runs-on: ubuntu-latest
+
+ services:
+ redis:
+ image: redis
+ env:
+ REDIS_HOST: localhost
+ REDIS_PORT: 6379
+ ports:
+ - 6379:6379
+ options: >-
+ --health-cmd "redis-cli ping"
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up PostgreSQL
+ run: |
+ sudo systemctl start postgresql
+ sudo -u postgres psql -c "CREATE DATABASE coolify;"
+ sudo -u postgres psql -c "CREATE USER coolify WITH PASSWORD 'password';"
+ sudo -u postgres psql -c "ALTER ROLE coolify SET client_encoding TO 'utf8';"
+ sudo -u postgres psql -c "ALTER ROLE coolify SET default_transaction_isolation TO 'read committed';"
+ sudo -u postgres psql -c "ALTER ROLE coolify SET timezone TO 'UTC';"
+ sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE coolify TO coolify;"
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.2'
+ - name: Copy .env
+ run: cp .env.dusk.ci .env
+ - name: Install Dependencies
+ run: composer install --no-progress --prefer-dist --optimize-autoloader
+ - name: Generate key
+ run: php artisan key:generate
+ - name: Install Chrome binaries
+ run: php artisan dusk:chrome-driver --detect
+ - name: Start Chrome Driver
+ run: ./vendor/laravel/dusk/bin/chromedriver-linux &
+ - name: Build assets
+ run: npm install && npm run build
+ - name: Run Laravel Server
+ run: php artisan serve --no-reload &
+ - name: Execute tests
+ run: php artisan dusk
+ - name: Upload Screenshots
+ if: failure()
+ uses: actions/upload-artifact@v4
+ with:
+ name: screenshots
+ path: tests/Browser/screenshots
+ - name: Upload Console Logs
+ if: failure()
+ uses: actions/upload-artifact@v4
+ with:
+ name: console
+ path: tests/Browser/console
diff --git a/tests/Browser/LoginTest.php b/tests/Browser/LoginTest.php
index ffa83d09bb..cac9a65fe6 100644
--- a/tests/Browser/LoginTest.php
+++ b/tests/Browser/LoginTest.php
@@ -13,18 +13,20 @@ class LoginTest extends DuskTestCase
* Login with the test user and assert that the user is redirected to the dashboard.
*
* @return void
+ *
* @throws Throwable
*/
public function testLogin()
{
- $email = config('testing.dusk_test_email');
- $password = config('testing.dusk_test_password');
+ $email = '[email protected]';
+ $password = 'password';
$this->browse(function (Browser $browser) use ($password, $email) {
$browser->visit('/login')
->type('email', $email)
->type('password', $password)
->press('Login')
- ->assertPathIs('/');
+ ->assertPathIs('/')
+ ->screenshot('login');
});
}
}
diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php
index d909d1c214..1e7a3d4b6b 100644
--- a/tests/DuskTestCase.php
+++ b/tests/DuskTestCase.php
@@ -2,74 +2,24 @@
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;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
- /**
- * Prepare for Dusk test execution.
- *
- * @beforeClass
- */
- public static function prepare(): void
- {
- if (! static::runningInSail()) {
- static::startChromeDriver();
- }
- }
-
- /**
- * Create the RemoteWebDriver instance.
- */
protected function driver(): RemoteWebDriver
{
- $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());
-
return RemoteWebDriver::create(
- $_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515',
- DesiredCapabilities::chrome()->setCapability(
- ChromeOptions::CAPABILITY,
- $options
- )
+ env('DUSK_DRIVER_URL'),
+ DesiredCapabilities::chrome()
);
}
- /**
- * Determine if the browser window should start maximized.
- */
- protected function shouldStartMaximized(): bool
- {
- return isset($_SERVER['DUSK_START_MAXIMIZED']) ||
- isset($_ENV['DUSK_START_MAXIMIZED']);
- }
-
- /**
- * Determine whether the Dusk command has disabled headless mode.
- */
- protected function hasHeadlessDisabled(): bool
- {
- return isset($_SERVER['DUSK_HEADLESS_DISABLED']) ||
- isset($_ENV['DUSK_HEADLESS_DISABLED']);
- }
-
protected function baseUrl()
{
- $app_url = config('app.url');
- $port = config('app.port');
-
- return $app_url.':'.$port;
+ return 'https://staging.heyandras.dev';
}
}
diff --git a/tests/How_To_Use_Dusk.md b/tests/How_To_Use_Dusk.md
deleted file mode 100644
index fc10bff8c1..0000000000
--- a/tests/How_To_Use_Dusk.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# How to use Laravel Dusk in local development
-
-## Pre-requisites
-
-- Google Chrome installed on your machine (for the Chrome driver)
-- everything else is already set up in the project
-
-
-## Running Dusk in local development
-
-In order to use Laravel Dusk in local development, you need to run these commands:
-
-```bash
-docker exec -it coolify php artisan dusk:chrome-driver --detect
-```
-
-The chrome driver will be installed under `./vendor/laravel/dusk/bin/chromedriver-linux`.
-
-Then you need to run the chrome-driver by hand. You can find the driver in the following path:
-```bash
-docker exec -it coolify ./vendor/laravel/dusk/bin/chromedriver-linux --port=9515
-```
-
-### Running the tests on Apple Silicon
-
-If you are using an Apple Silicon machine, you need to install the Chrome driver locally on your machine with the following command:
-
-```bash
-php artisan dusk:chrome-driver --detect
-# then run it with the following command
-./vendor/laravel/dusk/bin/chromedriver-mac-arm --port=9515 130 ↵
-```
-
-### Running the tests
-
-Finally, you can run the tests with the following command:
-```bash
-docker exec -it coolify php artisan dusk
-```
-
-That's it. You should see the tests running in the terminal.
-For proof, you can check the screenshot in the `tests/Browser/screenshots` folder.
-
-```
-
- PASS Tests\Browser\LoginTest
- ✓ login 3.63s
-
- Tests: 1 passed (1 assertions)
- Duration: 3.79s
-
-
-```
\ No newline at end of file