77 lines
3 KiB
PHP
77 lines
3 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"]', 'test.20251228124357@example.com')
|
||
|
|
->type('input[id="password"]', 'SecurePassword123!')
|
||
|
|
->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"]', 'test.20251228124357@example.com')
|
||
|
|
->type('input[id="password"]', 'SecurePassword123!')
|
||
|
|
->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"]', 'test.20251228124357@example.com')
|
||
|
|
->type('input[id="password"]', 'SecurePassword123!')
|
||
|
|
->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);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|