import { describe, it, expect } from 'vitest';
import {
  PERMISSION_ADVERTISEMENT_VIEW,
  PERMISSION_ADVERTISEMENT_CREATE,
  PERMISSION_ADVERTISEMENT_EDIT,
  PERMISSION_ADVERTISEMENT_DELETE,
  PERMISSION_ADVERTISEMENT_MANAGE,
  PERMISSIONS,
  ALL_PERMISSIONS,
  Permission
} from '../../src/constants/permissions.constants';
import {
  ROLE_SUPER_ADMIN,
  ROLE_ADMIN,
  ROLES,
  DEFAULT_ROLE_PERMISSIONS,
  RoleName
} from '../../src/constants/roles.constants';

describe('Permission Constants', () => {
  it('should have correct advertisement permission constants', () => {
    expect(PERMISSION_ADVERTISEMENT_VIEW).toBe('advertisement:view');
    expect(PERMISSION_ADVERTISEMENT_CREATE).toBe('advertisement:create');
    expect(PERMISSION_ADVERTISEMENT_EDIT).toBe('advertisement:edit');
    expect(PERMISSION_ADVERTISEMENT_DELETE).toBe('advertisement:delete');
    expect(PERMISSION_ADVERTISEMENT_MANAGE).toBe('advertisement:manage');
  });

  it('should have all permissions in PERMISSIONS object', () => {
    expect(PERMISSIONS.ADVERTISEMENT_VIEW).toBe('advertisement:view');
    expect(PERMISSIONS.ADVERTISEMENT_CREATE).toBe('advertisement:create');
    expect(PERMISSIONS.ADVERTISEMENT_EDIT).toBe('advertisement:edit');
    expect(PERMISSIONS.ADVERTISEMENT_DELETE).toBe('advertisement:delete');
    expect(PERMISSIONS.ADVERTISEMENT_MANAGE).toBe('advertisement:manage');
  });

  it('should have all permissions in ALL_PERMISSIONS array', () => {
    expect(ALL_PERMISSIONS).toHaveLength(5);
    expect(ALL_PERMISSIONS).toContain('advertisement:view');
    expect(ALL_PERMISSIONS).toContain('advertisement:create');
    expect(ALL_PERMISSIONS).toContain('advertisement:edit');
    expect(ALL_PERMISSIONS).toContain('advertisement:delete');
    expect(ALL_PERMISSIONS).toContain('advertisement:manage');
  });

  it('should have Permission type', () => {
    const permission: Permission = 'advertisement:view';
    expect(permission).toBe('advertisement:view');
  });
});

describe('Role Constants', () => {
  it('should have correct role constants', () => {
    expect(ROLE_SUPER_ADMIN).toBe('super-admin');
    expect(ROLE_ADMIN).toBe('admin');
  });

  it('should have all roles in ROLES object', () => {
    expect(ROLES.SUPER_ADMIN).toBe('super-admin');
    expect(ROLES.ADMIN).toBe('admin');
  });

  it('should have correct default role permissions', () => {
    expect(DEFAULT_ROLE_PERMISSIONS[ROLE_SUPER_ADMIN]).toEqual(['advertisement:manage']);
    expect(DEFAULT_ROLE_PERMISSIONS[ROLE_ADMIN]).toEqual([]);
  });

  it('should have RoleName type', () => {
    const superAdmin: RoleName = 'super-admin';
    const admin: RoleName = 'admin';
    expect(superAdmin).toBe('super-admin');
    expect(admin).toBe('admin');
  });
});