109 lines
4.2 KiB
PHP
109 lines
4.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Browser;
|
||
|
|
|
||
|
|
use Laravel\Dusk\Browser;
|
||
|
|
use Tests\DuskTestCase;
|
||
|
|
use App\Models\Planner;
|
||
|
|
|
||
|
|
class CreateDishTest extends DuskTestCase
|
||
|
|
{
|
||
|
|
public function testCanAccessDishesPage(): 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
|
||
|
|
->clickLink('Dishes')
|
||
|
|
->pause(2000)
|
||
|
|
->assertPathIs('/dishes')
|
||
|
|
->assertSee('MANAGE DISHES')
|
||
|
|
->assertSee('Add Dish');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testCanOpenCreateDishModal(): 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)
|
||
|
|
|
||
|
|
// Open create modal
|
||
|
|
->waitFor('button[wire\\:click="create"]', 5)
|
||
|
|
->click('button[wire\\:click="create"]')
|
||
|
|
->pause(1000)
|
||
|
|
->assertSee('Add New Dish')
|
||
|
|
->assertSee('Dish Name')
|
||
|
|
->assertSee('Assign to Users')
|
||
|
|
->assertSee('Create Dish')
|
||
|
|
->assertSee('Cancel');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testCreateDishFormValidation(): 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)
|
||
|
|
|
||
|
|
// Open create modal and try to submit without name
|
||
|
|
->waitFor('button[wire\\:click="create"]', 5)
|
||
|
|
->click('button[wire\\:click="create"]')
|
||
|
|
->pause(1000)
|
||
|
|
->waitFor('input[wire\\:model="name"]', 5)
|
||
|
|
->clear('input[wire\\:model="name"]')
|
||
|
|
->press('Create Dish')
|
||
|
|
->pause(2000)
|
||
|
|
->assertSee('required');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testCanCancelDishCreation(): 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)
|
||
|
|
|
||
|
|
// Open create modal and cancel
|
||
|
|
->waitFor('button[wire\\:click="create"]', 5)
|
||
|
|
->click('button[wire\\:click="create"]')
|
||
|
|
->pause(1000)
|
||
|
|
->assertSee('Add New Dish')
|
||
|
|
->press('Cancel')
|
||
|
|
->pause(1000)
|
||
|
|
->assertDontSee('Add New Dish');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|