Files
xianyan/test/l10n/translation_coverage_test.dart
Developer ca68fe29c7 chore: 批量整理优化项目代码与配置
- 新增模型目录占位文件与翻译类型拆分
- 调整路由配置与桌面端窗口初始化
- 移除多处冗余图表配置项
- 重构右侧面板注册表与三栏布局组件
- 添加智能AppBar、拖拽书签等新功能组件
- 优化安卓编译配置与多平台插件注册
- 新增翻译覆盖率测试与共享组件
- 格式化代码与修复静态分析警告
2026-05-29 10:08:02 +08:00

80 lines
2.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/// ============================================================
/// 闲言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');
}
}
}
}
});
});
}