feature - 11 - Add registration test sad paths
This commit is contained in:
parent
9e22c23208
commit
01ee82cbac
2 changed files with 74 additions and 36 deletions
|
|
@ -1,36 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Browser;
|
|
||||||
|
|
||||||
use Laravel\Dusk\Browser;
|
|
||||||
use Tests\DuskTestCase;
|
|
||||||
use App\Models\Planner;
|
|
||||||
|
|
||||||
class RegistrationOnlyTest extends DuskTestCase
|
|
||||||
{
|
|
||||||
public function testUserRegistration(): void
|
|
||||||
{
|
|
||||||
// Generate unique test data with timestamp to avoid conflicts
|
|
||||||
$timestamp = now()->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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
74
tests/Browser/RegistrationTest.php
Normal file
74
tests/Browser/RegistrationTest.php
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Browser;
|
||||||
|
|
||||||
|
use Laravel\Dusk\Browser;
|
||||||
|
use Tests\DuskTestCase;
|
||||||
|
use App\Models\Planner;
|
||||||
|
|
||||||
|
class RegistrationTest extends DuskTestCase
|
||||||
|
{
|
||||||
|
public function testUserRegistration(): void
|
||||||
|
{
|
||||||
|
// Generate unique test data with timestamp to avoid conflicts
|
||||||
|
$timestamp = now()->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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue