2025-12-28 21:01:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
2025-12-29 23:36:15 +01:00
|
|
|
namespace Tests\Browser\Dishes;
|
2025-12-28 21:01:44 +01:00
|
|
|
|
|
|
|
|
use Laravel\Dusk\Browser;
|
|
|
|
|
use Tests\DuskTestCase;
|
2025-12-29 23:36:15 +01:00
|
|
|
use Tests\Browser\LoginHelpers;
|
2025-12-28 21:01:44 +01:00
|
|
|
|
2025-12-29 23:36:15 +01:00
|
|
|
class DishDeletionSafetyTest extends DuskTestCase
|
2025-12-28 21:01:44 +01:00
|
|
|
{
|
2025-12-29 17:38:37 +01:00
|
|
|
use LoginHelpers;
|
|
|
|
|
|
2025-12-29 23:36:15 +01:00
|
|
|
protected static $dishDeletionSafetyTestPlanner = null;
|
|
|
|
|
protected static $dishDeletionSafetyTestEmail = null;
|
|
|
|
|
|
|
|
|
|
protected function setUp(): void
|
2025-12-28 21:01:44 +01:00
|
|
|
{
|
2025-12-29 23:36:15 +01:00
|
|
|
parent::setUp();
|
|
|
|
|
// Reset static planner for this specific test class
|
|
|
|
|
self::$testPlanner = self::$dishDeletionSafetyTestPlanner;
|
|
|
|
|
self::$testEmail = self::$dishDeletionSafetyTestEmail;
|
2025-12-28 21:01:44 +01:00
|
|
|
}
|
2025-12-29 23:36:15 +01:00
|
|
|
|
|
|
|
|
protected function tearDown(): void
|
2025-12-28 21:01:44 +01:00
|
|
|
{
|
2025-12-29 23:36:15 +01:00
|
|
|
// Save the planner for next test method in this class
|
|
|
|
|
self::$dishDeletionSafetyTestPlanner = self::$testPlanner;
|
|
|
|
|
self::$dishDeletionSafetyTestEmail = self::$testEmail;
|
|
|
|
|
parent::tearDown();
|
2025-12-28 21:01:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testDeletionSafetyFeatures(): void
|
|
|
|
|
{
|
|
|
|
|
$this->browse(function (Browser $browser) {
|
2025-12-29 17:38:37 +01:00
|
|
|
$this->loginAndGoToDishes($browser);
|
2025-12-28 21:01:44 +01:00
|
|
|
|
|
|
|
|
// Check that Livewire component includes all CRUD features
|
|
|
|
|
$pageSource = $browser->driver->getPageSource();
|
|
|
|
|
$this->assertStringContainsString('MANAGE DISHES', $pageSource);
|
|
|
|
|
$this->assertStringContainsString('Add Dish', $pageSource);
|
2025-12-29 17:38:37 +01:00
|
|
|
// Either we have dishes with Delete button OR "No dishes found" message
|
|
|
|
|
if (str_contains($pageSource, 'No dishes found')) {
|
|
|
|
|
$this->assertStringContainsString('No dishes found', $pageSource);
|
|
|
|
|
} else {
|
|
|
|
|
$this->assertStringContainsString('Delete', $pageSource);
|
|
|
|
|
}
|
2025-12-28 21:01:44 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|