fix(theme): stabilize tenant switch theme propagation and toggle race handling
Task: REVIEW-USER-THEME-001
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user