- 新增模型目录占位文件与翻译类型拆分 - 调整路由配置与桌面端窗口初始化 - 移除多处冗余图表配置项 - 重构右侧面板注册表与三栏布局组件 - 添加智能AppBar、拖拽书签等新功能组件 - 优化安卓编译配置与多平台插件注册 - 新增翻译覆盖率测试与共享组件 - 格式化代码与修复静态分析警告
80 lines
2.7 KiB
Dart
80 lines
2.7 KiB
Dart
/// ============================================================
|
||
/// 闲言APP — 翻译覆盖率检测测试
|
||
/// 创建时间: 2026-05-29
|
||
/// 更新时间: 2026-05-29
|
||
/// 作用: CI翻译覆盖率检测,确保各语言翻译完整度
|
||
/// 上次更新: 初始创建
|
||
/// ============================================================
|
||
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
import 'package:xianyan/l10n/translation_coverage.dart';
|
||
|
||
void main() {
|
||
group('TranslationCoverage', () {
|
||
test('totalFieldCount should be positive', () {
|
||
expect(TranslationCoverage.totalFieldCount, greaterThan(0));
|
||
});
|
||
|
||
test('zh_CN should have 100% coverage', () {
|
||
expect(TranslationCoverage.getProgressPercent('zh_CN'), equals(100));
|
||
});
|
||
|
||
test('all languages should have at least 50% coverage', () {
|
||
final report = TranslationCoverage.fullReport();
|
||
for (final entry in report.entries) {
|
||
final percent = entry.value['percent'] as int;
|
||
expect(
|
||
percent,
|
||
greaterThanOrEqualTo(50),
|
||
reason: '${entry.key} has only $percent% coverage',
|
||
);
|
||
}
|
||
});
|
||
|
||
test('no language should have zero translations', () {
|
||
final report = TranslationCoverage.fullReport();
|
||
for (final entry in report.entries) {
|
||
final translated = entry.value['translated'] as int;
|
||
expect(
|
||
translated,
|
||
greaterThan(0),
|
||
reason: '${entry.key} has zero translations',
|
||
);
|
||
}
|
||
});
|
||
|
||
test('coverage report should include all languages', () {
|
||
final report = TranslationCoverage.fullReport();
|
||
expect(report.containsKey('zh_CN'), isTrue);
|
||
expect(report.containsKey('en'), isTrue);
|
||
expect(report.containsKey('ja'), isTrue);
|
||
expect(report.containsKey('zh_TW'), isTrue);
|
||
expect(report.containsKey('es'), isTrue);
|
||
expect(report.containsKey('ar'), isTrue);
|
||
expect(report.containsKey('bn'), isTrue);
|
||
expect(report.containsKey('hi'), isTrue);
|
||
expect(report.containsKey('pt'), isTrue);
|
||
expect(report.containsKey('ru'), isTrue);
|
||
expect(report.containsKey('fr'), isTrue);
|
||
});
|
||
|
||
test('checkCoverage should detect empty fields', () {
|
||
final report = TranslationCoverage.fullReport();
|
||
for (final entry in report.entries) {
|
||
if (entry.key != 'zh_CN') {
|
||
final missing = entry.value['missing'] as List;
|
||
if (missing.isNotEmpty) {
|
||
print('${entry.key}: ${missing.length} missing fields');
|
||
for (final field in missing.take(5)) {
|
||
print(' - $field');
|
||
}
|
||
if (missing.length > 5) {
|
||
print(' ... and ${missing.length - 5} more');
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
});
|
||
}
|