dishplanner/tests/Browser/Dishes/EditDishTest.php

75 lines
2.3 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Tests\Browser\Dishes;
2026-08-17 13:30:49 +02:00
use App\Models\Planner;
use Laravel\Dusk\Browser;
use Tests\Browser\LoginHelpers;
2026-08-17 13:30:49 +02:00
use Tests\DuskTestCase;
class EditDishTest extends DuskTestCase
{
2025-12-29 17:38:37 +01:00
use LoginHelpers;
2026-08-17 13:30:49 +02:00
protected static $editDishTestPlanner = null;
2026-08-17 13:30:49 +02:00
protected static $editDishTestEmail = null;
2026-08-17 13:30:49 +02:00
protected function setUp(): void
{
parent::setUp();
// Reset static planner for this specific test class
self::$testPlanner = self::$editDishTestPlanner;
self::$testEmail = self::$editDishTestEmail;
}
2026-08-17 13:30:49 +02:00
protected function tearDown(): void
{
// Save the planner for next test method in this class
self::$editDishTestPlanner = self::$testPlanner;
self::$editDishTestEmail = self::$testEmail;
parent::tearDown();
}
2026-08-17 13:30:49 +02:00
public function test_can_access_edit_feature(): void
{
$this->browse(function (Browser $browser) {
2025-12-29 17:38:37 +01:00
$this->loginAndGoToDishes($browser)
2026-08-17 13:30:49 +02:00
->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);
});
}
2026-08-17 13:30:49 +02:00
public function test_edit_modal_components(): void
{
$this->browse(function (Browser $browser) {
2025-12-29 17:38:37 +01:00
$this->loginAndGoToDishes($browser)
2026-08-17 13:30:49 +02:00
->assertSee('MANAGE DISHES')
->assertSee('Add Dish');
});
}
2026-08-17 13:30:49 +02:00
public function test_dishes_page_structure(): void
{
$this->browse(function (Browser $browser) {
2025-12-29 17:38:37 +01:00
$this->loginAndGoToDishes($browser)
2026-08-17 13:30:49 +02:00
->assertSee('MANAGE DISHES')
->assertSee('Add Dish');
// Check that the dishes CRUD structure is present
$pageSource = $browser->driver->getPageSource();
2025-12-29 17:38:37 +01:00
// Either we have dishes with Edit/Delete buttons OR "No dishes found" message
if (str_contains($pageSource, 'No dishes found')) {
$this->assertStringContainsString('No dishes found', $pageSource);
} else {
$this->assertStringContainsString('Edit', $pageSource);
$this->assertStringContainsString('Delete', $pageSource);
}
});
}
2026-08-17 13:30:49 +02:00
}