app/tests/Browser/EditDishTest.php

53 lines
1.8 KiB
PHP
Raw Normal View History

<?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;
public function testCanAccessEditFeature(): void
{
$this->browse(function (Browser $browser) {
2025-12-29 17:38:37 +01:00
$this->loginAndGoToDishes($browser)
->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)
->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)
->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);
}
});
}
}