opsdash-app/opsdash/tests/php/Service/DashboardDefaultsServiceTest.php
blade34242 a0123eb662
All checks were successful
Nextcloud Server Tests / version-consistency (push) Successful in 50s
Nextcloud Server Tests / matrix-config (push) Successful in 39s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.2 (stable31, 8.2) (push) Successful in 19m40s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.3 (stable31, 8.3) (push) Successful in 20m4s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.2 (stable32, 8.2) (push) Successful in 19m20s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.3 (stable32, 8.3) (push) Successful in 16m58s
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.2 (stable33, 8.2) (push) Successful in 18m46s
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.3 (stable33, 8.3) (push) Successful in 19m37s
Nextcloud Server Tests / Nextcloud stable34 / PHP 8.2 (stable34, 8.2) (push) Successful in 18m21s
Nextcloud Server Tests / Nextcloud stable34 / PHP 8.3 (stable34, 8.3) (push) Successful in 19m13s
Respect customized dashboard layouts
2026-07-18 14:50:19 +07:00

50 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\Opsdash\Tests\Service;
use OCA\Opsdash\Service\DashboardDefaultsService;
use PHPUnit\Framework\TestCase;
final class DashboardDefaultsServiceTest extends TestCase {
public function testStandardPresetExcludesWorkspaceWidgets(): void {
$service = new DashboardDefaultsService();
$tabs = $service->createDefaultTabs('standard');
$widgets = $tabs['tabs'][0]['widgets'] ?? [];
$this->assertNotContains('deck_stats', array_column($widgets, 'type'));
$this->assertNotContains('deck_cards', array_column($widgets, 'type'));
}
public function testProTabsUseWorkspaceForDeckAndCalendarStats(): void {
$service = new DashboardDefaultsService();
$tabs = $service->createDefaultTabs('pro');
$workspace = array_values(array_filter(
$tabs['tabs'] ?? [],
static fn (array $tab): bool => ($tab['label'] ?? '') === 'Workspace',
));
$this->assertCount(1, $workspace);
$types = array_column($workspace[0]['widgets'] ?? [], 'type');
$this->assertContains('deck_stats', $types);
$this->assertContains('calendar_stats', $types);
}
public function testStandardTabsFollowGoalStrategy(): void {
$service = new DashboardDefaultsService();
$singleTypes = array_column($service->createDefaultTabs('standard', 'total_only')['tabs'][0]['widgets'], 'type');
$calendarTypes = array_column($service->createDefaultTabs('standard', 'total_plus_categories')['tabs'][0]['widgets'], 'type');
$fullTypes = array_column($service->createDefaultTabs('standard', 'full_granular')['tabs'][0]['widgets'], 'type');
$this->assertSame(['targets_v2', 'time_summary_overview', 'dayoff_trend'], $singleTypes);
$this->assertContains('calendar_table', $calendarTypes);
$this->assertCount(6, $calendarTypes);
$this->assertNotContains('balance_index', $calendarTypes);
$this->assertContains('balance_index', $fullTypes);
$this->assertContains('category_mix_trend', $fullTypes);
}
}