2025-12-28 21:01:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\Browser;
|
|
|
|
|
|
|
|
|
|
use Laravel\Dusk\Browser;
|
|
|
|
|
use Tests\DuskTestCase;
|
|
|
|
|
use App\Models\Planner;
|
|
|
|
|
|
|
|
|
|
class EditDishTest extends DuskTestCase
|
|
|
|
|
{
|
2025-12-29 17:38:37 +01:00
|
|
|
use LoginHelpers;
|
|
|
|
|
|
2025-12-28 21:01:44 +01:00
|
|
|
public function testCanAccessEditFeature(): void
|
|
|
|
|
{
|
|
|
|
|
$this->browse(function (Browser $browser) {
|
2025-12-29 17:38:37 +01:00
|
|
|
$this->loginAndGoToDishes($browser)
|
2025-12-28 21:01:44 +01:00
|
|
|
->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) {
|
2025-12-29 17:38:37 +01:00
|
|
|
$this->loginAndGoToDishes($browser)
|
2025-12-28 21:01:44 +01:00
|
|
|
->assertSee('MANAGE DISHES')
|
|
|
|
|
->assertSee('Add Dish');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testDishesPageStructure(): void
|
|
|
|
|
{
|
|
|
|
|
$this->browse(function (Browser $browser) {
|
2025-12-29 17:38:37 +01:00
|
|
|
$this->loginAndGoToDishes($browser)
|
2025-12-28 21:01:44 +01:00
|
|
|
->assertSee('MANAGE DISHES')
|
|
|
|
|
->assertSee('Add Dish');
|
|
|
|
|
|
|
|
|
|
// Check that the dishes CRUD structure is present
|
|
|
|
|
$pageSource = $browser->driver->getPageSource();
|
2025-12-29 17:38:37 +01:00
|
|
|
// Either we have dishes with Edit/Delete buttons OR "No dishes found" message
|
|
|
|
|
if (str_contains($pageSource, 'No dishes found')) {
|
|
|
|
|
$this->assertStringContainsString('No dishes found', $pageSource);
|
|
|
|
|
} else {
|
|
|
|
|
$this->assertStringContainsString('Edit', $pageSource);
|
|
|
|
|
$this->assertStringContainsString('Delete', $pageSource);
|
|
|
|
|
}
|
2025-12-28 21:01:44 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|