52 lines
No EOL
1.8 KiB
PHP
52 lines
No EOL
1.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Browser;
|
|
|
|
use Laravel\Dusk\Browser;
|
|
use Tests\DuskTestCase;
|
|
use App\Models\Planner;
|
|
|
|
class DeleteDishTest extends DuskTestCase
|
|
{
|
|
use LoginHelpers;
|
|
|
|
public function testCanAccessDeleteFeature(): void
|
|
{
|
|
$this->browse(function (Browser $browser) {
|
|
$this->loginAndGoToDishes($browser)
|
|
->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) {
|
|
$this->loginAndGoToDishes($browser)
|
|
->assertSee('MANAGE DISHES')
|
|
->assertSee('Add Dish');
|
|
});
|
|
}
|
|
|
|
public function testDeletionSafetyFeatures(): void
|
|
{
|
|
$this->browse(function (Browser $browser) {
|
|
$this->loginAndGoToDishes($browser);
|
|
|
|
// Check that Livewire component includes all CRUD features
|
|
$pageSource = $browser->driver->getPageSource();
|
|
$this->assertStringContainsString('MANAGE DISHES', $pageSource);
|
|
$this->assertStringContainsString('Add Dish', $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);
|
|
}
|
|
});
|
|
}
|
|
} |