import 'package:flutter_test/flutter_test.dart';
import 'package:health_app/pages/report/report_pages.dart';

void main() {
  test('report polling backs off and stops after the retry budget', () {
    expect(reportAnalysisPollDelay(1), const Duration(seconds: 4));
    expect(reportAnalysisPollDelay(3), const Duration(seconds: 8));
    expect(reportAnalysisPollDelay(6), const Duration(seconds: 12));
    expect(reportAnalysisPollDelay(16), isNull);
  });

  test('report state starts in an explicit loading phase', () {
    expect(ReportState().isLoadingReports, isTrue);
    expect(ReportState().reportsError, isNull);
  });

  test('original report type prefers metadata and falls back to the url', () {
    expect(isPdfReport('Pdf', '/uploads/report.bin'), isTrue);
    expect(isPdfReport('Image', '/uploads/report.pdf'), isTrue);
    expect(isPdfReport('Image', '/uploads/report.jpg'), isFalse);
  });
}
