fix(theme): stabilize tenant switch theme propagation and toggle race handling

Task: REVIEW-USER-THEME-001
This commit is contained in:
2026-03-07 20:14:29 +01:00
parent e3a0c0eb37
commit fb6f87374f
10 changed files with 596 additions and 0 deletions

View File

@@ -73,4 +73,36 @@ class AuthSessionTenantContextServiceTest extends TestCase
$this->assertFalse((bool) $_SESSION['no_active_tenant']);
$this->assertSame(7, (int) ($_SESSION['current_tenant']['id'] ?? 0));
}
public function testHydratePreservesThemeAndPolicyFieldsInSession(): void
{
$availableTenants = [
[
'id' => 3,
'uuid' => 'tenant-3',
'default_theme' => 'dark',
'allow_user_theme' => '0',
],
];
$userTenantContextService = $this->createMock(UserTenantContextService::class);
$userTenantContextService->method('getAvailableTenants')->willReturn($availableTenants);
$userTenantContextService->method('getAvailableDepartmentsByTenant')->willReturn([]);
$userTenantContextService->method('getCurrentTenant')->willReturn($availableTenants[0]);
$savedFilterGateway = $this->createMock(AuthSavedFilterGateway::class);
$savedFilterGateway->method('listAddressBookFilters')->willReturn([]);
$service = new AuthSessionTenantContextService(
$userTenantContextService,
$savedFilterGateway,
new SessionStore()
);
$service->hydrateForUser(10);
$tenant = $_SESSION['current_tenant'] ?? [];
$this->assertSame('dark', $tenant['default_theme'] ?? null);
$this->assertSame('0', $tenant['allow_user_theme'] ?? null);
}
}