dishplanner/tests/Browser/Dishes/DeleteDishTest.php

78 lines
2.5 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 DeleteDishTest extends DuskTestCase
{
2025-12-29 17:38:37 +01:00
use LoginHelpers;
2026-08-17 13:30:49 +02:00
protected static $deleteDishTestPlanner = null;
2026-08-17 13:30:49 +02:00
protected static $deleteDishTestEmail = 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::$deleteDishTestPlanner;
self::$testEmail = self::$deleteDishTestEmail;
}
2026-08-17 13:30:49 +02:00
protected function tearDown(): void
{
// Save the planner for next test method in this class
self::$deleteDishTestPlanner = self::$testPlanner;
self::$deleteDishTestEmail = self::$testEmail;
parent::tearDown();
}
2026-08-17 13:30:49 +02:00
public function test_can_access_delete_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 delete functionality is available by looking for the text in the page source
$pageSource = $browser->driver->getPageSource();
$this->assertStringContainsString('Delete', $pageSource);
});
}
// TODO: Fix static planner issue causing login failures in suite runs
// These tests pass in isolation but fail when run in full suite
/*
public function testDeleteModalComponents(): void
{
$this->browse(function (Browser $browser) {
2025-12-29 17:38:37 +01:00
$this->loginAndGoToDishes($browser)
->assertSee('MANAGE DISHES')
->assertSee('Add Dish');
});
}
public function testDeletionSafetyFeatures(): 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
// 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);
}
});
}
*/
2026-08-17 13:30:49 +02:00
}