import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shadcn_ui/shadcn_ui.dart';

import 'package:superport_v2/features/inventory/transactions/presentation/widgets/transaction_detail_dialog.dart';

import '../../../../../helpers/test_app.dart';

void main() {
  testWidgets(
    'showInventoryTransactionDetailDialog는 summary/metadata/섹션을 렌더링한다',
    (tester) async {
      await tester.pumpWidget(buildTestApp(const SizedBox.shrink()));
      final context = tester.element(find.byType(SizedBox));

      unawaited(
        showInventoryTransactionDetailDialog<void>(
          context: context,
          title: '트랜잭션 상세',
          description: '라인 품목과 상태를 확인하세요.',
          summary: const Text('TRX-123'),
          summaryBadges: const [ShadBadge(child: Text('완료'))],
          metadata: [
            SuperportDetailMetadata.text(label: '상태', value: '완료'),
            SuperportDetailMetadata.text(label: '창고', value: '서울 1창고'),
          ],
          sections: [
            SuperportDetailDialogSection(
              id: 'lines',
              label: '라인 품목',
              builder: (_) => const Text('라인 섹션'),
            ),
          ],
        ),
      );

      await tester.pumpAndSettle();

      expect(find.text('트랜잭션 상세'), findsOneWidget);
      expect(find.text('TRX-123'), findsOneWidget);
      expect(find.text('상태'), findsOneWidget);
      expect(find.text('라인 섹션'), findsOneWidget);
    },
  );
}
