Files
clide/test/a11y/i18n_coverage_test.dart
T
jpmschweitzerandClaude Opus 4.8 9d7ab35a19 test(i18n): cover the i18n facade, selector, manifest routing + locale (T-462)
Tests for the epic's new code so the 95% floor holds: ClideSettings.i18n
string/interpolated null-safe + localizedCommandTitle; settings-renderer
localization (section/field/help/select/file, project-scope tag, didUpdateWidget);
extension-activation rollback + settings-contribution unregister; the Dutch
gate check; RootShell applying app.locale on boot; and prompt/conversation
tool-body + file-ref coverage. Also harden the menu toggle re-tap (capture the
button point while stable, then tapAt) so it no longer throws getCenter under
the serial coverage load.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 18:26:30 +02:00

55 lines
2.4 KiB
Dart

import 'dart:ui';
import 'package:clide/kernel/kernel.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter_test/flutter_test.dart';
/// Asserts every bundled i18n catalog is well-formed and every key the
/// Tier-0 built-ins ask for actually resolves.
///
/// The second check is important: in a text-driven i18n system missing
/// keys show the placeholder, so a runtime lookup test wouldn't "fail"
/// on a typo — we have to assert the keys exist up front.
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
/// (namespace, key) pairs referenced by Tier-0 built-ins. Extend when
/// new keys land.
const referenced = <String, List<String>>{
'builtin.welcome': ['title', 'subtitle', 'open-project', 'open-project.hint', 'tab.title'],
'builtin.ipc-status': ['connected', 'connected.hint', 'disconnected', 'disconnected.hint'],
'builtin.theme-picker': ['modal.title', 'modal.cancel', 'modal.cancel.hint', 'row.select.hint'],
'builtin.default-layout': ['command.reset', 'preset.classic'],
};
group('i18n coverage (Tier 0)', () {
for (final entry in referenced.entries) {
final ns = entry.key;
test('$ns catalog contains every referenced key', () async {
final loader = AssetCatalogLoader(bundle: rootBundle);
final catalog = await loader.load(ns, const Locale('en', 'US'));
expect(catalog, isNotEmpty, reason: 'catalog for "$ns" failed to load (asset path wrong?)');
for (final key in entry.value) {
expect(catalog.containsKey(key), isTrue, reason: 'namespace "$ns" catalog is missing key "$key"');
}
});
}
});
// The bundled Dutch pack (T-462) must load and cover the same Tier-0 keys, so
// a locale switch never falls back to English for a built-in label.
group('i18n coverage — Dutch pack (nl-NL)', () {
for (final entry in referenced.entries) {
final ns = entry.key;
test('$ns nl_NL catalog covers every referenced key', () async {
final loader = AssetCatalogLoader(bundle: rootBundle);
final catalog = await loader.load(ns, const Locale('nl', 'NL'));
expect(catalog, isNotEmpty, reason: 'nl_NL catalog for "$ns" failed to load');
for (final key in entry.value) {
expect(catalog.containsKey(key), isTrue, reason: 'nl_NL "$ns" missing key "$key"');
}
});
}
});
}