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.

Added a basic login test and also added 2 small variables to dev .env file

ALsJourneycddd4b59f90d
diff --git a/.env.development.example b/.env.development.example
index f9bcd361a0..0f9e4c72e4 100644
--- a/.env.development.example
+++ b/.env.development.example
@@ -13,6 +13,8 @@ TELESCOPE_ENABLED=false
# Selenium Driver URL for Dusk
DUSK_DRIVER_URL=http://selenium:4444
+DUSK_PASSWORD=password
# PostgreSQL Database Configuration
DB_DATABASE=coolify
diff --git a/config/testing.php b/config/testing.php
new file mode 100644
index 0000000000..41b8eadf01
--- /dev/null
+++ b/config/testing.php
@@ -0,0 +1,6 @@
+<?php
+
+return [
+ 'dusk_test_email' => env('DUSK_TEST_EMAIL', '[email protected]'),
+ 'dusk_test_password' => env('DUSK_TEST_PASSWORD', 'password'),
+];
diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php
deleted file mode 100644
index 15dc8f5f12..0000000000
--- a/tests/Browser/ExampleTest.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-namespace Tests\Browser;
-
-use Laravel\Dusk\Browser;
-use Tests\DuskTestCase;
-
-class ExampleTest extends DuskTestCase
-{
- /**
- * A basic browser test example.
- */
- public function testBasicExample(): void
- {
- $this->browse(function (Browser $browser) {
- $browser->visit('/')
- ->assertSee('Laravel');
- });
- }
-}
diff --git a/tests/Browser/LoginTest.php b/tests/Browser/LoginTest.php
new file mode 100644
index 0000000000..ffa83d09bb
--- /dev/null
+++ b/tests/Browser/LoginTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Tests\Browser;
+
+use Laravel\Dusk\Browser;
+use Tests\DuskTestCase;
+use Throwable;
+
+class LoginTest extends DuskTestCase
+{
+ /**
+ * A basic test for the login page.
+ * 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');
+ $this->browse(function (Browser $browser) use ($password, $email) {
+ $browser->visit('/login')
+ ->type('email', $email)
+ ->type('password', $password)
+ ->press('Login')
+ ->assertPathIs('/');
+ });
+ }
+}
diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php
index 8628871a18..d909d1c214 100644
--- a/tests/DuskTestCase.php
+++ b/tests/DuskTestCase.php
@@ -67,6 +67,9 @@ abstract class DuskTestCase extends BaseTestCase
protected function baseUrl()
{
- return rtrim(config('app.url'), '/');
+ $app_url = config('app.url');
+ $port = config('app.port');
+
+ return $app_url.':'.$port;
}
}