opsdash-app/opsdash/tests/php/Service/OverviewSelectionServiceTest.php
Blade34242 162e03e5b2 Refactor opsdash presets, widgets registry, onboarding
- Move presets endpoints to PresetsController and add unit tests\n- Split widgets registry into per-widget modules and add render-context composable\n- Break OnboardingWizard into step components/state\n- Rebuild Vite assets and add smoke target
2025-12-14 10:55:21 +07:00

48 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\Opsdash\Tests\Service;
use OCA\Opsdash\Service\OverviewSelectionService;
use PHPUnit\Framework\TestCase;
class OverviewSelectionServiceTest extends TestCase {
public function testResolveInitialSelectionDefaultsToIncludeAllWhenUnsetAndNotProvided(): void {
$service = new OverviewSelectionService();
$result = $service->resolveInitialSelection('__UNSET__', false, null);
$this->assertFalse($result['hasSaved']);
$this->assertTrue($result['includeAll']);
$this->assertSame([], $result['savedIds']);
$this->assertSame([], $result['selectedIds']);
$final = $service->finalizeSelectedIds(true, ['a', 'b'], $result['selectedIds']);
$this->assertSame(['a', 'b'], $final);
}
public function testResolveInitialSelectionUsesSavedIdsWhenPresent(): void {
$service = new OverviewSelectionService();
$result = $service->resolveInitialSelection('a,b,,c', false, null);
$this->assertTrue($result['hasSaved']);
$this->assertFalse($result['includeAll']);
$this->assertSame(['a', 'b', 'c'], $result['savedIds']);
$this->assertSame(['a', 'b', 'c'], $result['selectedIds']);
}
public function testResolveInitialSelectionRespectsExplicitEmptyRequest(): void {
$service = new OverviewSelectionService();
$result = $service->resolveInitialSelection('a,b', true, []);
$this->assertTrue($result['hasSaved']);
$this->assertFalse($result['includeAll']);
$this->assertSame([], $result['selectedIds']);
}
public function testResolveInitialSelectionParsesCsvWhenProvided(): void {
$service = new OverviewSelectionService();
$result = $service->resolveInitialSelection('__UNSET__', true, 'a,b,a,');
$this->assertFalse($result['hasSaved']);
$this->assertFalse($result['includeAll']);
$this->assertSame(['a', 'b'], $result['selectedIds']);
}
}