75 lines
No EOL
2.9 KiB
PHP
75 lines
No EOL
2.9 KiB
PHP
<?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"]', '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')
|
|
->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"]', 'admin@test.com')
|
|
->type('input[id="password"]', 'password')
|
|
->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"]', 'admin@test.com')
|
|
->type('input[id="password"]', 'password')
|
|
->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);
|
|
});
|
|
}
|
|
} |