This commit is contained in:
Bastian Wagner
2026-07-16 09:49:22 +02:00
commit 543e8273a7
157 changed files with 22761 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import { TestBed } from '@angular/core/testing';
import { of } from 'rxjs';
import { ApiClientService, type UserDto } from '@boilerplate/api-client';
import { AuthService } from './auth.service';
const user: UserDto = {
id: 'u1',
name: 'Ada',
email: 'ada@example.test',
active: true,
lastLoginAt: null,
settings: { tablePageSize: 20, sidebarExpanded: true },
roles: [
{
id: 'r1',
name: 'user',
protected: true,
permissions: [{ id: 'items.read', description: 'items.read' }],
},
],
};
describe('AuthService', () => {
it('derives permissions from roles for navigation decisions', () => {
TestBed.configureTestingModule({
providers: [{ provide: ApiClientService, useValue: { me: () => of(user) } }],
});
const service = TestBed.inject(AuthService);
service.loadMe();
expect(service.has('items.read')).toBe(true);
expect(service.has('users.manage')).toBe(false);
});
});