From 01ee82cbac80f70f34df4e1fdb1ad75e28e5695f Mon Sep 17 00:00:00 2001 From: myrmidex Date: Sun, 28 Dec 2025 20:22:41 +0100 Subject: [PATCH] feature - 11 - Add registration test sad paths --- tests/Browser/RegistrationOnlyTest.php | 36 ------------- tests/Browser/RegistrationTest.php | 74 ++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 36 deletions(-) delete mode 100644 tests/Browser/RegistrationOnlyTest.php create mode 100644 tests/Browser/RegistrationTest.php diff --git a/tests/Browser/RegistrationOnlyTest.php b/tests/Browser/RegistrationOnlyTest.php deleted file mode 100644 index 07c25dc..0000000 --- a/tests/Browser/RegistrationOnlyTest.php +++ /dev/null @@ -1,36 +0,0 @@ -format('YmdHis'); - $testData = [ - 'name' => "Test User {$timestamp}", - 'email' => "test.{$timestamp}@example.com", - 'password' => 'SecurePassword123!', - ]; - - $this->browse(function (Browser $browser) use ($testData) { - $browser->visit('http://dishplanner_app:8000/register') - ->waitFor('input[id="name"]', 5) - ->type('input[id="name"]', $testData['name']) - ->type('input[id="email"]', $testData['email']) - ->type('input[id="password"]', $testData['password']) - ->type('input[id="password_confirmation"]', $testData['password']) - ->screenshot('filled-form') - ->click('button[type="submit"]') - ->pause(3000) // Give more time for processing - ->screenshot('after-submit') - ->assertSee("Welcome {$testData['name']}!") // Verify successful registration and login - ->assertPathIs('/dashboard'); // Should be on dashboard - }); - } -} \ No newline at end of file diff --git a/tests/Browser/RegistrationTest.php b/tests/Browser/RegistrationTest.php new file mode 100644 index 0000000..9bc5a4a --- /dev/null +++ b/tests/Browser/RegistrationTest.php @@ -0,0 +1,74 @@ +format('YmdHis'); + $testData = [ + 'name' => "Test User {$timestamp}", + 'email' => "test.{$timestamp}@example.com", + 'password' => 'SecurePassword123!', + ]; + + $this->browse(function (Browser $browser) use ($testData) { + $browser->visit('http://dishplanner_app:8000/register') + ->waitFor('input[id="name"]', 5) + ->type('input[id="name"]', $testData['name']) + ->type('input[id="email"]', $testData['email']) + ->type('input[id="password"]', $testData['password']) + ->type('input[id="password_confirmation"]', $testData['password']) + ->screenshot('filled-form') + ->click('button[type="submit"]') + ->pause(3000) // Give more time for processing + ->screenshot('after-submit') + ->assertSee("Welcome {$testData['name']}!") // Verify successful registration and login + ->assertPathIs('/dashboard'); // Should be on dashboard + }); + } + + + public function testRegistrationWithExistingEmail(): void + { + $this->browse(function (Browser $browser) { + $browser->driver->manage()->deleteAllCookies(); + $browser->visit('http://dishplanner_app:8000/register') + ->waitFor('input[id="name"]', 5) + ->type('input[id="name"]', 'Another User') + ->type('input[id="email"]', 'test.20251228124357@example.com') // Use existing test email + ->type('input[id="password"]', 'SecurePassword123!') + ->type('input[id="password_confirmation"]', 'SecurePassword123!') + ->click('button[type="submit"]') + ->pause(2000) + ->assertPathIs('/register') + ->assertSee('The email has already been taken') + ->assertGuest(); + }); + } + + public function testRegistrationWithMismatchedPasswords(): void + { + $this->browse(function (Browser $browser) { + $browser->driver->manage()->deleteAllCookies(); + $browser->visit('http://dishplanner_app:8000/register') + ->waitFor('input[id="name"]', 5) + ->type('input[id="name"]', 'Test User') + ->type('input[id="email"]', 'testmismatch@example.com') + ->type('input[id="password"]', 'SecurePassword123!') + ->type('input[id="password_confirmation"]', 'DifferentPassword123!') + ->click('button[type="submit"]') + ->pause(2000) + ->screenshot('password-mismatch-error') + ->assertPathIs('/register') + ->assertSee('password') // Look for any password-related error + ->assertGuest(); + }); + } +} \ No newline at end of file