import 'dart:io';

import 'package:flutter_test/flutter_test.dart';

void main() {
  test('대시보드 화면은 auth timeline fetch 구현을 직접 가지지 않는다', () async {
    final screenFile = File(
      'lib/features/dashboard/presentation/dashboard_screen.dart',
    );
    final source = await screenFile.readAsString();

    expect(source.contains('_fetchAuditLogs('), isFalse);
    expect(source.contains('_loadAuditLogs('), isFalse);
    expect(source.contains('/api/v1/audit/auth/timeline'), isFalse);
  });

  test('나의 App 현황 연동해지 버튼은 단일 라인 텍스트로 렌더링한다', () async {
    final screenFile = File(
      'lib/features/dashboard/presentation/dashboard_screen.dart',
    );
    final source = await screenFile.readAsString();
    final revokeLabelIndex = source.lastIndexOf(
      "tr('ui.userfront.dashboard.revoke.title')",
    );

    expect(revokeLabelIndex, isNonNegative);
    final snippetStart = revokeLabelIndex > 500 ? revokeLabelIndex - 500 : 0;
    final snippetEnd = revokeLabelIndex + 300 < source.length
        ? revokeLabelIndex + 300
        : source.length;
    final revokeButtonSource = source.substring(snippetStart, snippetEnd);

    expect(revokeButtonSource, contains('_singleLineText('));
  });
}
