fix: 移除 BLE 蓝牙依赖,消除 CoreLocation API 引用
- 注释 flutter_blue_plus 和 permission_handler 依赖 - 删除蓝牙设备页、BLE service、omron provider 等 6 个源文件 - 移除路由和设备设置入口 - 清理 2 个 BLE 相关测试文件 - 解决 Transporter 报 NSLocationWhenInUseUsageDescription 缺失 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,116 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:health_app/models/ble_device.dart';
|
||||
import 'package:health_app/pages/chart/trend_page.dart';
|
||||
import 'package:health_app/pages/remaining_pages.dart';
|
||||
import 'package:health_app/services/health_ble_service.dart';
|
||||
|
||||
void main() {
|
||||
test('manual entry keyboard does not relayout the trend dashboard', () {
|
||||
final source = File('lib/pages/chart/trend_page.dart').readAsStringSync();
|
||||
|
||||
expect(source, contains('resizeToAvoidBottomInset: false'));
|
||||
expect(source, contains('class _KeyboardInsetPadding'));
|
||||
expect(source, contains('MediaQuery.viewInsetsOf(context).bottom'));
|
||||
expect(source, contains('child: RepaintBoundary('));
|
||||
});
|
||||
|
||||
test('unknown trend metric falls back to blood pressure', () {
|
||||
expect(normalizeTrendMetricType('unknown_metric'), 'blood_pressure');
|
||||
expect(normalizeTrendMetricType(null), 'blood_pressure');
|
||||
expect(normalizeTrendMetricType('spo2'), 'spo2');
|
||||
});
|
||||
|
||||
test('trend period includes today and the requested preceding days', () {
|
||||
final now = DateTime(2026, 7, 13, 18);
|
||||
final records = [
|
||||
{'date': DateTime(2026, 7, 6, 23), 'value': 70},
|
||||
{'date': DateTime(2026, 7, 7, 0), 'value': 71},
|
||||
{'date': DateTime(2026, 7, 13, 8), 'value': 72},
|
||||
];
|
||||
|
||||
final result = filterTrendRecordsForPeriod(records, 7, now);
|
||||
|
||||
expect(result.map((record) => record['value']), [71, 72]);
|
||||
});
|
||||
|
||||
test('trend values do not show an unnecessary decimal', () {
|
||||
expect(formatTrendNumber(88.0), '88');
|
||||
expect(formatTrendNumber(88.5), '88.5');
|
||||
expect(formatTrendNumber(null), '--');
|
||||
});
|
||||
|
||||
test('blood pressure abnormal label identifies the affected value', () {
|
||||
expect(
|
||||
trendStatusLabel({
|
||||
'systolic': 113,
|
||||
'diastolic': 97,
|
||||
'isAbnormal': true,
|
||||
}, 'blood_pressure'),
|
||||
'舒张压偏高',
|
||||
);
|
||||
expect(
|
||||
trendStatusLabel({
|
||||
'systolic': 122,
|
||||
'diastolic': 89,
|
||||
'isAbnormal': false,
|
||||
}, 'blood_pressure'),
|
||||
'',
|
||||
);
|
||||
});
|
||||
|
||||
test('calendar month switch keeps the selected day when possible', () {
|
||||
expect(
|
||||
calendarDateForMonth(DateTime(2026, 6), DateTime(2026, 7, 13)),
|
||||
DateTime(2026, 6, 13),
|
||||
);
|
||||
expect(
|
||||
calendarDateForMonth(DateTime(2026, 2), DateTime(2026, 1, 31)),
|
||||
DateTime(2026, 2, 28),
|
||||
);
|
||||
});
|
||||
|
||||
test('health archive list input is normalized without conflicting none', () {
|
||||
expect(normalizeArchiveItems('青霉素,海鲜\n花粉'), ['青霉素', '海鲜', '花粉']);
|
||||
expect(normalizeArchiveItems('无'), ['无']);
|
||||
expect(normalizeArchiveItems('无、青霉素'), ['青霉素']);
|
||||
});
|
||||
|
||||
test('static compliance pages include collection and sdk lists', () {
|
||||
expect(staticTextTitle('personalInfoList'), '个人信息收集清单');
|
||||
expect(staticTextContent('personalInfoList'), contains('健康数据'));
|
||||
|
||||
expect(staticTextTitle('thirdPartySdkList'), '第三方 SDK 共享清单');
|
||||
expect(staticTextContent('thirdPartySdkList'), contains('AI'));
|
||||
});
|
||||
|
||||
test('all in-app compliance documents contain readable Chinese', () {
|
||||
final source = File('lib/pages/remaining_pages.dart').readAsStringSync();
|
||||
final start = source.indexOf(
|
||||
'const Map<String, String> _extraStaticTextTitles',
|
||||
);
|
||||
expect(start, isNonNegative);
|
||||
final complianceSection = source.substring(start);
|
||||
|
||||
expect(complianceSection, isNot(contains('锛')));
|
||||
expect(complianceSection, isNot(contains('銆')));
|
||||
expect(complianceSection, isNot(contains('€')));
|
||||
});
|
||||
|
||||
test('ble sync is only implemented for blood pressure devices', () {
|
||||
expect(
|
||||
HealthBleService.isSyncImplemented(BleDeviceType.bloodPressure),
|
||||
true,
|
||||
);
|
||||
expect(HealthBleService.isSyncImplemented(BleDeviceType.glucose), false);
|
||||
expect(
|
||||
HealthBleService.isSyncImplemented(BleDeviceType.weightScale),
|
||||
false,
|
||||
);
|
||||
expect(
|
||||
HealthBleService.isSyncImplemented(BleDeviceType.pulseOximeter),
|
||||
false,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:health_app/models/ble_device.dart';
|
||||
import 'package:health_app/pages/device/device_sync_ui_logic.dart';
|
||||
|
||||
void main() {
|
||||
test('unsupported bound devices are labelled without pretending to sync', () {
|
||||
expect(deviceSyncAvailabilityLabel(BleDeviceType.glucose), '暂不支持自动同步');
|
||||
expect(deviceSyncAvailabilityLabel(BleDeviceType.bloodPressure), isNull);
|
||||
});
|
||||
|
||||
test('device sync errors keep connection and upload failures distinct', () {
|
||||
expect(
|
||||
deviceSyncErrorMessage(
|
||||
const DeviceSyncFailure(DeviceSyncFailureStage.permission),
|
||||
),
|
||||
contains('蓝牙权限'),
|
||||
);
|
||||
expect(
|
||||
deviceSyncErrorMessage(
|
||||
const DeviceSyncFailure(DeviceSyncFailureStage.upload),
|
||||
),
|
||||
contains('上传'),
|
||||
);
|
||||
});
|
||||
|
||||
test('bound device page keeps the automatic scan indicator', () {
|
||||
final page = File(
|
||||
'lib/pages/device/device_management_page.dart',
|
||||
).readAsStringSync();
|
||||
|
||||
expect(page, contains('AnimationController('));
|
||||
expect(page, contains('child: _ScanIndicator('));
|
||||
expect(page, contains('scanning: _scanning'));
|
||||
});
|
||||
|
||||
test('profile exposes a real edit route and keeps phone read only', () {
|
||||
final profile = File(
|
||||
'lib/pages/profile/profile_page.dart',
|
||||
).readAsStringSync();
|
||||
final editor = File(
|
||||
'lib/pages/profile/profile_edit_page.dart',
|
||||
).readAsStringSync();
|
||||
final router = File('lib/core/app_router.dart').readAsStringSync();
|
||||
|
||||
expect(profile, contains("pushRoute(ref, 'profileEdit')"));
|
||||
expect(editor, contains('手机号不可修改'));
|
||||
expect(router, contains("case 'profileEdit':"));
|
||||
});
|
||||
|
||||
test(
|
||||
'drawer does not refetch history when only current conversation changes',
|
||||
() {
|
||||
final provider = File(
|
||||
'lib/providers/conversation_history_provider.dart',
|
||||
).readAsStringSync();
|
||||
final drawer = File('lib/widgets/health_drawer.dart').readAsStringSync();
|
||||
|
||||
expect(
|
||||
provider,
|
||||
isNot(
|
||||
contains(
|
||||
'ref.watch(chatProvider.select((state) => state.conversationId))',
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(drawer, contains('currentConversationId'));
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user