feature - 7 - Add e2e tests for dishes crud
This commit is contained in:
parent
01ee82cbac
commit
ecfadbc2ad
3 changed files with 261 additions and 0 deletions
109
tests/Browser/CreateDishTest.php
Normal file
109
tests/Browser/CreateDishTest.php
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\DuskTestCase;
|
||||
use App\Models\Planner;
|
||||
|
||||
class CreateDishTest extends DuskTestCase
|
||||
{
|
||||
public function testCanAccessDishesPage(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
// Login first
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
->assertPathIs('/dashboard')
|
||||
|
||||
// Navigate to Dishes
|
||||
->clickLink('Dishes')
|
||||
->pause(2000)
|
||||
->assertPathIs('/dishes')
|
||||
->assertSee('MANAGE DISHES')
|
||||
->assertSee('Add Dish');
|
||||
});
|
||||
}
|
||||
|
||||
public function testCanOpenCreateDishModal(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
|
||||
->clickLink('Dishes')
|
||||
->pause(2000)
|
||||
|
||||
// Open create modal
|
||||
->waitFor('button[wire\\:click="create"]', 5)
|
||||
->click('button[wire\\:click="create"]')
|
||||
->pause(1000)
|
||||
->assertSee('Add New Dish')
|
||||
->assertSee('Dish Name')
|
||||
->assertSee('Assign to Users')
|
||||
->assertSee('Create Dish')
|
||||
->assertSee('Cancel');
|
||||
});
|
||||
}
|
||||
|
||||
public function testCreateDishFormValidation(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
|
||||
->clickLink('Dishes')
|
||||
->pause(2000)
|
||||
|
||||
// Open create modal and try to submit without name
|
||||
->waitFor('button[wire\\:click="create"]', 5)
|
||||
->click('button[wire\\:click="create"]')
|
||||
->pause(1000)
|
||||
->waitFor('input[wire\\:model="name"]', 5)
|
||||
->clear('input[wire\\:model="name"]')
|
||||
->press('Create Dish')
|
||||
->pause(2000)
|
||||
->assertSee('required');
|
||||
});
|
||||
}
|
||||
|
||||
public function testCanCancelDishCreation(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
|
||||
->clickLink('Dishes')
|
||||
->pause(2000)
|
||||
|
||||
// Open create modal and cancel
|
||||
->waitFor('button[wire\\:click="create"]', 5)
|
||||
->click('button[wire\\:click="create"]')
|
||||
->pause(1000)
|
||||
->assertSee('Add New Dish')
|
||||
->press('Cancel')
|
||||
->pause(1000)
|
||||
->assertDontSee('Add New Dish');
|
||||
});
|
||||
}
|
||||
}
|
||||
75
tests/Browser/DeleteDishTest.php
Normal file
75
tests/Browser/DeleteDishTest.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\DuskTestCase;
|
||||
use App\Models\Planner;
|
||||
|
||||
class DeleteDishTest extends DuskTestCase
|
||||
{
|
||||
public function testCanAccessDeleteFeature(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
// Login first
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
->assertPathIs('/dashboard')
|
||||
|
||||
// Navigate to Dishes and verify delete functionality exists
|
||||
->clickLink('Dishes')
|
||||
->pause(2000)
|
||||
->assertPathIs('/dishes')
|
||||
->assertSee('MANAGE DISHES');
|
||||
|
||||
// Verify that delete functionality is available by looking for the text in the page source
|
||||
$pageSource = $browser->driver->getPageSource();
|
||||
$this->assertStringContainsString('Delete', $pageSource);
|
||||
});
|
||||
}
|
||||
|
||||
public function testDeleteModalComponents(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
|
||||
->clickLink('Dishes')
|
||||
->pause(2000)
|
||||
->assertSee('MANAGE DISHES')
|
||||
->assertSee('Add Dish');
|
||||
});
|
||||
}
|
||||
|
||||
public function testDeletionSafetyFeatures(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
|
||||
->clickLink('Dishes')
|
||||
->pause(2000);
|
||||
|
||||
// Check that Livewire component includes all CRUD features
|
||||
$pageSource = $browser->driver->getPageSource();
|
||||
$this->assertStringContainsString('MANAGE DISHES', $pageSource);
|
||||
$this->assertStringContainsString('Add Dish', $pageSource);
|
||||
$this->assertStringContainsString('No dishes found', $pageSource);
|
||||
});
|
||||
}
|
||||
}
|
||||
77
tests/Browser/EditDishTest.php
Normal file
77
tests/Browser/EditDishTest.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\DuskTestCase;
|
||||
use App\Models\Planner;
|
||||
|
||||
class EditDishTest extends DuskTestCase
|
||||
{
|
||||
public function testCanAccessEditFeature(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
// Login first
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
->assertPathIs('/dashboard')
|
||||
|
||||
// Navigate to Dishes and verify edit functionality exists
|
||||
->clickLink('Dishes')
|
||||
->pause(2000)
|
||||
->assertPathIs('/dishes')
|
||||
->assertSee('MANAGE DISHES');
|
||||
|
||||
// Verify that edit functionality is available by looking for the text in the page source
|
||||
$pageSource = $browser->driver->getPageSource();
|
||||
$this->assertStringContainsString('Edit', $pageSource);
|
||||
});
|
||||
}
|
||||
|
||||
public function testEditModalComponents(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
|
||||
->clickLink('Dishes')
|
||||
->pause(2000)
|
||||
->assertSee('MANAGE DISHES')
|
||||
->assertSee('Add Dish');
|
||||
});
|
||||
}
|
||||
|
||||
public function testDishesPageStructure(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
|
||||
->clickLink('Dishes')
|
||||
->pause(2000)
|
||||
->assertSee('MANAGE DISHES')
|
||||
->assertSee('Add Dish');
|
||||
|
||||
// Check that the dishes CRUD structure is present
|
||||
$pageSource = $browser->driver->getPageSource();
|
||||
$this->assertStringContainsString('Edit', $pageSource);
|
||||
$this->assertStringContainsString('Delete', $pageSource);
|
||||
$this->assertStringContainsString('No dishes found', $pageSource);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue