Files
AI-Health/health_app/test/audit_fix_guardrails_test.dart

75 lines
2.3 KiB
Dart

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:health_app/pages/history/conversation_history_page.dart';
import 'package:health_app/pages/notifications/notification_center_page.dart';
void main() {
test('notification opening continues when acknowledge fails', () async {
var opened = false;
final acknowledged = await acknowledgeBeforeNotificationOpen(
acknowledge: () async => throw Exception('offline'),
open: () => opened = true,
);
expect(acknowledged, isFalse);
expect(opened, isTrue);
});
test(
'conversation dismiss is rejected when backend deletion fails',
() async {
expect(
await deleteConversationForDismiss(
() async => throw Exception('delete failed'),
),
isFalse,
);
expect(await deleteConversationForDismiss(() async {}), isTrue);
},
);
test('doctor picker does not keep a stale list for the whole app session', () {
final source = File('lib/providers/data_providers.dart').readAsStringSync();
final adminSource = File(
'lib/pages/admin/admin_add_doctor_page.dart',
).readAsStringSync();
expect(
source,
matches(
RegExp(
r'final doctorListProvider\s*=\s*FutureProvider\.autoDispose<List<Map<String, dynamic>>>',
),
),
);
expect(adminSource, contains('ref.invalidate(doctorListProvider)'));
});
test('home header buttons use a larger touch area', () {
final source = File('lib/pages/home/home_page.dart').readAsStringSync();
final buttonSource = source.substring(
source.indexOf('class _HeaderIconButton'),
);
expect(buttonSource, contains('width: elderMode ? 54 : 44'));
expect(buttonSource, contains('height: elderMode ? 54 : 44'));
});
test('settings logout action is white with dark text', () {
final source = File(
'lib/pages/settings/settings_pages.dart',
).readAsStringSync();
final logoutButtonStart = source.indexOf('ElevatedButton.icon(');
final logoutButtonEnd = source.indexOf(
'Future<void> _deleteAccount',
logoutButtonStart,
);
final logoutButton = source.substring(logoutButtonStart, logoutButtonEnd);
expect(logoutButton, contains('backgroundColor: Colors.white'));
expect(logoutButton, contains('foregroundColor: AppColors.textPrimary'));
});
}