import 'package:flutter_test/flutter_test.dart';
import 'package:tdc114plus/src/features/organization/domain/organization_models.dart';

void main() {
  test('TenantListResponse parses organization filter tenants', () {
    final response = TenantListResponse.fromJson({
      'items': [
        {
          'id': 'tenant-uuid',
          'name': 'Hanmac',
          'slug': 'hanmac',
          'type': 'COMPANY',
          'parentId': 'family-root',
          'memberCount': 120,
          'totalMemberCount': 350,
        },
      ],
      'generatedAt': '2026-07-02T12:00:00Z',
    });

    expect(response.items.first.slug, 'hanmac');
    expect(response.items.first.totalMemberCount, 350);
  });

  test('OrgChartSnapshot parses tenants, employees, and cache metadata', () {
    final snapshot = OrgChartSnapshot.fromJson({
      'tenants': [
        {
          'id': 'tenant-uuid',
          'name': 'Engineering',
          'slug': 'engineering',
          'type': 'ORGANIZATION',
          'parentId': 'company-tenant-uuid',
          'memberCount': 12,
          'totalMemberCount': 38,
        },
      ],
      'employees': [
        {
          'id': 'user-uuid',
          'name': 'User One',
          'phoneNumber': '+821012345678',
          'phoneDisplay': '010-1234-5678',
          'tenantId': 'tenant-uuid',
          'tenantName': 'Engineering',
          'tenantSlug': 'engineering',
          'department': 'Engineering',
          'grade': 'Lead',
          'position': 'Manager',
          'jobTitle': 'Developer',
          'status': 'active',
        },
      ],
      'generatedAt': '2026-07-02T12:00:00Z',
      'cache': {'source': 'redis', 'hit': true, 'ttlSeconds': 300},
    });

    expect(snapshot.tenants.first.type, 'ORGANIZATION');
    expect(snapshot.employees.first.tenantSlug, 'engineering');
    expect(snapshot.cache?.source, 'redis');
  });
}
