feature - 8 - Fix e2e tests
This commit is contained in:
parent
8336df4551
commit
53840d5ced
5 changed files with 69 additions and 86 deletions
|
|
@ -70,4 +70,22 @@ public function testCanCancelDishCreation(): void
|
||||||
->assertDontSee('Add New Dish');
|
->assertDontSee('Add New Dish');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCanCreateDishSuccessfully(): void
|
||||||
|
{
|
||||||
|
$this->browse(function (Browser $browser) {
|
||||||
|
$dishName = 'Test Dish ' . uniqid();
|
||||||
|
|
||||||
|
$this->loginAndGoToDishes($browser)
|
||||||
|
->waitFor('button[wire\\:click="create"]', 5)
|
||||||
|
->click('button[wire\\:click="create"]')
|
||||||
|
->pause(1000)
|
||||||
|
->waitFor('input[wire\\:model="name"]', 5)
|
||||||
|
->type('input[wire\\:model="name"]', $dishName)
|
||||||
|
->press('Create Dish')
|
||||||
|
->pause(3000) // Wait for Livewire to process
|
||||||
|
->assertSee($dishName) // Should see the dish in the list
|
||||||
|
->assertSee('Dish created successfully'); // Flash message
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8,22 +8,12 @@
|
||||||
|
|
||||||
class DeleteDishTest extends DuskTestCase
|
class DeleteDishTest extends DuskTestCase
|
||||||
{
|
{
|
||||||
|
use LoginHelpers;
|
||||||
|
|
||||||
public function testCanAccessDeleteFeature(): void
|
public function testCanAccessDeleteFeature(): void
|
||||||
{
|
{
|
||||||
$this->browse(function (Browser $browser) {
|
$this->browse(function (Browser $browser) {
|
||||||
// Login first
|
$this->loginAndGoToDishes($browser)
|
||||||
$browser->driver->manage()->deleteAllCookies();
|
|
||||||
$browser->visit('http://dishplanner_app:8000/login')
|
|
||||||
->waitFor('input[id="email"]', 5)
|
|
||||||
->type('input[id="email"]', 'admin@test.com')
|
|
||||||
->type('input[id="password"]', 'password')
|
|
||||||
->press('Login')
|
|
||||||
->pause(2000)
|
|
||||||
->assertPathIs('/dashboard')
|
|
||||||
|
|
||||||
// Navigate to Dishes and verify delete functionality exists
|
|
||||||
->clickLink('Dishes')
|
|
||||||
->pause(2000)
|
|
||||||
->assertPathIs('/dishes')
|
->assertPathIs('/dishes')
|
||||||
->assertSee('MANAGE DISHES');
|
->assertSee('MANAGE DISHES');
|
||||||
|
|
||||||
|
|
@ -36,16 +26,7 @@ public function testCanAccessDeleteFeature(): void
|
||||||
public function testDeleteModalComponents(): void
|
public function testDeleteModalComponents(): void
|
||||||
{
|
{
|
||||||
$this->browse(function (Browser $browser) {
|
$this->browse(function (Browser $browser) {
|
||||||
$browser->driver->manage()->deleteAllCookies();
|
$this->loginAndGoToDishes($browser)
|
||||||
$browser->visit('http://dishplanner_app:8000/login')
|
|
||||||
->waitFor('input[id="email"]', 5)
|
|
||||||
->type('input[id="email"]', 'admin@test.com')
|
|
||||||
->type('input[id="password"]', 'password')
|
|
||||||
->press('Login')
|
|
||||||
->pause(2000)
|
|
||||||
|
|
||||||
->clickLink('Dishes')
|
|
||||||
->pause(2000)
|
|
||||||
->assertSee('MANAGE DISHES')
|
->assertSee('MANAGE DISHES')
|
||||||
->assertSee('Add Dish');
|
->assertSee('Add Dish');
|
||||||
});
|
});
|
||||||
|
|
@ -54,22 +35,18 @@ public function testDeleteModalComponents(): void
|
||||||
public function testDeletionSafetyFeatures(): void
|
public function testDeletionSafetyFeatures(): void
|
||||||
{
|
{
|
||||||
$this->browse(function (Browser $browser) {
|
$this->browse(function (Browser $browser) {
|
||||||
$browser->driver->manage()->deleteAllCookies();
|
$this->loginAndGoToDishes($browser);
|
||||||
$browser->visit('http://dishplanner_app:8000/login')
|
|
||||||
->waitFor('input[id="email"]', 5)
|
|
||||||
->type('input[id="email"]', 'admin@test.com')
|
|
||||||
->type('input[id="password"]', 'password')
|
|
||||||
->press('Login')
|
|
||||||
->pause(2000)
|
|
||||||
|
|
||||||
->clickLink('Dishes')
|
|
||||||
->pause(2000);
|
|
||||||
|
|
||||||
// Check that Livewire component includes all CRUD features
|
// Check that Livewire component includes all CRUD features
|
||||||
$pageSource = $browser->driver->getPageSource();
|
$pageSource = $browser->driver->getPageSource();
|
||||||
$this->assertStringContainsString('MANAGE DISHES', $pageSource);
|
$this->assertStringContainsString('MANAGE DISHES', $pageSource);
|
||||||
$this->assertStringContainsString('Add Dish', $pageSource);
|
$this->assertStringContainsString('Add Dish', $pageSource);
|
||||||
$this->assertStringContainsString('No dishes found', $pageSource);
|
// Either we have dishes with Delete button OR "No dishes found" message
|
||||||
|
if (str_contains($pageSource, 'No dishes found')) {
|
||||||
|
$this->assertStringContainsString('No dishes found', $pageSource);
|
||||||
|
} else {
|
||||||
|
$this->assertStringContainsString('Delete', $pageSource);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8,22 +8,12 @@
|
||||||
|
|
||||||
class EditDishTest extends DuskTestCase
|
class EditDishTest extends DuskTestCase
|
||||||
{
|
{
|
||||||
|
use LoginHelpers;
|
||||||
|
|
||||||
public function testCanAccessEditFeature(): void
|
public function testCanAccessEditFeature(): void
|
||||||
{
|
{
|
||||||
$this->browse(function (Browser $browser) {
|
$this->browse(function (Browser $browser) {
|
||||||
// Login first
|
$this->loginAndGoToDishes($browser)
|
||||||
$browser->driver->manage()->deleteAllCookies();
|
|
||||||
$browser->visit('http://dishplanner_app:8000/login')
|
|
||||||
->waitFor('input[id="email"]', 5)
|
|
||||||
->type('input[id="email"]', 'admin@test.com')
|
|
||||||
->type('input[id="password"]', 'password')
|
|
||||||
->press('Login')
|
|
||||||
->pause(2000)
|
|
||||||
->assertPathIs('/dashboard')
|
|
||||||
|
|
||||||
// Navigate to Dishes and verify edit functionality exists
|
|
||||||
->clickLink('Dishes')
|
|
||||||
->pause(2000)
|
|
||||||
->assertPathIs('/dishes')
|
->assertPathIs('/dishes')
|
||||||
->assertSee('MANAGE DISHES');
|
->assertSee('MANAGE DISHES');
|
||||||
|
|
||||||
|
|
@ -36,16 +26,7 @@ public function testCanAccessEditFeature(): void
|
||||||
public function testEditModalComponents(): void
|
public function testEditModalComponents(): void
|
||||||
{
|
{
|
||||||
$this->browse(function (Browser $browser) {
|
$this->browse(function (Browser $browser) {
|
||||||
$browser->driver->manage()->deleteAllCookies();
|
$this->loginAndGoToDishes($browser)
|
||||||
$browser->visit('http://dishplanner_app:8000/login')
|
|
||||||
->waitFor('input[id="email"]', 5)
|
|
||||||
->type('input[id="email"]', 'admin@test.com')
|
|
||||||
->type('input[id="password"]', 'password')
|
|
||||||
->press('Login')
|
|
||||||
->pause(2000)
|
|
||||||
|
|
||||||
->clickLink('Dishes')
|
|
||||||
->pause(2000)
|
|
||||||
->assertSee('MANAGE DISHES')
|
->assertSee('MANAGE DISHES')
|
||||||
->assertSee('Add Dish');
|
->assertSee('Add Dish');
|
||||||
});
|
});
|
||||||
|
|
@ -54,24 +35,19 @@ public function testEditModalComponents(): void
|
||||||
public function testDishesPageStructure(): void
|
public function testDishesPageStructure(): void
|
||||||
{
|
{
|
||||||
$this->browse(function (Browser $browser) {
|
$this->browse(function (Browser $browser) {
|
||||||
$browser->driver->manage()->deleteAllCookies();
|
$this->loginAndGoToDishes($browser)
|
||||||
$browser->visit('http://dishplanner_app:8000/login')
|
|
||||||
->waitFor('input[id="email"]', 5)
|
|
||||||
->type('input[id="email"]', 'admin@test.com')
|
|
||||||
->type('input[id="password"]', 'password')
|
|
||||||
->press('Login')
|
|
||||||
->pause(2000)
|
|
||||||
|
|
||||||
->clickLink('Dishes')
|
|
||||||
->pause(2000)
|
|
||||||
->assertSee('MANAGE DISHES')
|
->assertSee('MANAGE DISHES')
|
||||||
->assertSee('Add Dish');
|
->assertSee('Add Dish');
|
||||||
|
|
||||||
// Check that the dishes CRUD structure is present
|
// Check that the dishes CRUD structure is present
|
||||||
$pageSource = $browser->driver->getPageSource();
|
$pageSource = $browser->driver->getPageSource();
|
||||||
$this->assertStringContainsString('Edit', $pageSource);
|
// Either we have dishes with Edit/Delete buttons OR "No dishes found" message
|
||||||
$this->assertStringContainsString('Delete', $pageSource);
|
if (str_contains($pageSource, 'No dishes found')) {
|
||||||
$this->assertStringContainsString('No dishes found', $pageSource);
|
$this->assertStringContainsString('No dishes found', $pageSource);
|
||||||
|
} else {
|
||||||
|
$this->assertStringContainsString('Edit', $pageSource);
|
||||||
|
$this->assertStringContainsString('Delete', $pageSource);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -106,14 +106,15 @@ public function testCanUpdateUser(): void
|
||||||
->clear('input[wire\\:model="name"]')
|
->clear('input[wire\\:model="name"]')
|
||||||
->type('input[wire\\:model="name"]', $updatedName)
|
->type('input[wire\\:model="name"]', $updatedName)
|
||||||
->press('Update User')
|
->press('Update User')
|
||||||
|
->pause(3000); // Wait for Livewire to process
|
||||||
|
|
||||||
// Wait for Livewire to process the update
|
// First, verify the database was actually updated
|
||||||
->pause(3000) // Give plenty of time for Livewire to complete
|
$user = \App\Models\User::find($userId);
|
||||||
->assertSee('User updated successfully')
|
$this->assertEquals($updatedName, $user->name, 'User name was not updated in database');
|
||||||
|
|
||||||
|
// Then check for the success message
|
||||||
|
$browser->assertSee('User updated successfully');
|
||||||
|
|
||||||
// Verify the updated name is visible in the list
|
|
||||||
->assertSee($updatedName)
|
|
||||||
->assertDontSee($originalName);
|
|
||||||
} else {
|
} else {
|
||||||
$this->fail('Could not find user ID for editing');
|
$this->fail('Could not find user ID for editing');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,13 @@ class LoginTest extends DuskTestCase
|
||||||
public function testSuccessfulLogin(): void
|
public function testSuccessfulLogin(): void
|
||||||
{
|
{
|
||||||
$this->browse(function (Browser $browser) {
|
$this->browse(function (Browser $browser) {
|
||||||
|
$browser->driver->manage()->deleteAllCookies();
|
||||||
$browser->visit('http://dishplanner_app:8000/login')
|
$browser->visit('http://dishplanner_app:8000/login')
|
||||||
->waitFor('input[id="email"]', 5)
|
->waitFor('input[id="email"]', 5)
|
||||||
->type('input[id="email"]', 'admin@test.com')
|
->type('input[id="email"]', 'admin@test.com')
|
||||||
->type('input[id="password"]', 'password')
|
->type('input[id="password"]', 'password')
|
||||||
->press('Login')
|
->press('Login')
|
||||||
->pause(3000)
|
->waitForLocation('/dashboard', 10)
|
||||||
->assertPathIs('/dashboard')
|
->assertPathIs('/dashboard')
|
||||||
->assertAuthenticated()
|
->assertAuthenticated()
|
||||||
->visit('http://dishplanner_app:8000/logout');
|
->visit('http://dishplanner_app:8000/logout');
|
||||||
|
|
@ -39,17 +40,27 @@ public function testLoginWithWrongCredentials(): void
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoginWithBlankFields(): void
|
public function testLoginFormRequiredFields(): void
|
||||||
{
|
{
|
||||||
$this->browse(function (Browser $browser) {
|
$this->browse(function (Browser $browser) {
|
||||||
$browser->driver->manage()->deleteAllCookies();
|
$browser->driver->manage()->deleteAllCookies();
|
||||||
$browser->visit('http://dishplanner_app:8000/login')
|
$browser->visit('http://dishplanner_app:8000/login')
|
||||||
->waitFor('input[id="email"]', 5)
|
->waitFor('input[id="email"]', 5);
|
||||||
->press('Login')
|
|
||||||
->pause(2000)
|
// Check that both fields have the required attribute
|
||||||
->assertPathIs('/login')
|
$browser->assertAttribute('input[id="email"]', 'required', 'true');
|
||||||
->assertSee('The email field is required')
|
$browser->assertAttribute('input[id="password"]', 'required', 'true');
|
||||||
->assertGuest();
|
|
||||||
|
// Verify email field is type email
|
||||||
|
$browser->assertAttribute('input[id="email"]', 'type', 'email');
|
||||||
|
|
||||||
|
// Verify password field is type password
|
||||||
|
$browser->assertAttribute('input[id="password"]', 'type', 'password');
|
||||||
|
|
||||||
|
// Test that we stay on login page if we try to submit with empty fields
|
||||||
|
$browser->press('Login')
|
||||||
|
->pause(500)
|
||||||
|
->assertPathIs('/login');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue