app/tests/Browser/EditDishTest.php
myrmidex 77817bca14 feature - 8 - Trim down fields from user form
+ move auth forms from livewire to blade
2025-12-29 02:57:25 +01:00

77 lines
No EOL
2.9 KiB
PHP

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