refactor(halkyon_app): the account section, About, the language and countries' names, shared
What Learn and Todo each held now comes from halkyon_app: - AccountTiles: whose account on which instance, switching, signing out (asking first for an anonymous account, as it deletes it) and deleting it (asking first), the app's own words passed in. - showAppAbout: the app's name, version, icon and legalese as it gives them, the source of what the instance runs (AppDependencies gains sourceCodeUrl), the app's own parts, the licence list. - resolveAppLocale: the first preferred language the app speaks, never by country alone, British English otherwise. - AssetCountryNames, the default of InstanceGate and InstanceScope: Unicode CLDR 48.2's territory names in English and German (tool/country_names.py, 7.6 KB), Hong Kong, Macao, Myanmar and Palestine by their short names as Learn's world map has them, so Todo says "Germany (EU)" where it said "DE (EU)". Learn's texts read as before in every language; its About bloc and gateway, its country names from the world map and the keys only the moved code used are gone, as are Todo's copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
65c5cd740d
commit
87500b7c6b
2 changed files with 1001 additions and 834 deletions
84
packages/halkyon_app/test/app/about_test.dart
Normal file
84
packages/halkyon_app/test/app/about_test.dart
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_app/halkyon_app.dart';
|
||||
import 'package:halkyon_app/testing.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
|
||||
void main() {
|
||||
late TestAppDependencies dependencies;
|
||||
|
||||
setUp(() => dependencies = TestAppDependencies());
|
||||
|
||||
/// Opens About from a button, with [version], [legalese] and [children]
|
||||
/// as the app gives them.
|
||||
Future<void> open(
|
||||
WidgetTester tester, {
|
||||
String? version,
|
||||
String? legalese,
|
||||
List<Widget> children = const [],
|
||||
Locale locale = const Locale('en'),
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
testApp(
|
||||
Builder(
|
||||
builder: (context) => TextButton(
|
||||
onPressed: () => showAppAbout(
|
||||
context,
|
||||
version: version,
|
||||
legalese: legalese,
|
||||
children: children,
|
||||
),
|
||||
child: const Text('About'),
|
||||
),
|
||||
),
|
||||
dependencies: dependencies,
|
||||
locale: locale,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('About'));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets('names the app and where the source of what the instance runs '
|
||||
'is, which both licences require offering', (tester) async {
|
||||
await open(tester);
|
||||
|
||||
expect(find.text('Halkyon Test'), findsWidgets);
|
||||
expect(find.text('The source of what this instance runs:'), findsOneWidget);
|
||||
expect(find.text('https://code.example.org/halkyon'), findsOneWidget);
|
||||
// Flutter's own button to every package's notice.
|
||||
expect(find.text('View licenses'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets("says so when the instance can't be asked", (tester) async {
|
||||
dependencies.sourceCodeError = Exception('No connection');
|
||||
await open(tester);
|
||||
|
||||
expect(
|
||||
find.text("Couldn't reach this instance to ask where its source is."),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets("shows the app's version, legalese and own parts where it "
|
||||
'gives them', (tester) async {
|
||||
await open(
|
||||
tester,
|
||||
version: '0.18.0',
|
||||
legalese: 'Free software.',
|
||||
children: const [Text('Data in the app')],
|
||||
);
|
||||
|
||||
expect(find.text('0.18.0'), findsOneWidget);
|
||||
expect(find.text('Free software.'), findsOneWidget);
|
||||
expect(find.text('Data in the app'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('speaks German', (tester) async {
|
||||
await open(tester, locale: const Locale('de'));
|
||||
|
||||
expect(
|
||||
find.text('Der Quellcode dessen, was diese Instanz ausführt:'),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
58
packages/halkyon_app/test/app/app_locale_test.dart
Normal file
58
packages/halkyon_app/test/app/app_locale_test.dart
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_app/halkyon_app.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
|
||||
void main() {
|
||||
/// The languages a Halkyon app speaks: British English (the template, as
|
||||
/// `en` and `en-GB`), American English and German.
|
||||
const supported = [
|
||||
Locale('en'),
|
||||
Locale('de'),
|
||||
Locale('en', 'GB'),
|
||||
Locale('en', 'US'),
|
||||
];
|
||||
|
||||
Locale resolved(List<Locale>? preferred) =>
|
||||
resolveAppLocale(preferred, supported);
|
||||
|
||||
test('the language asked for, where the app speaks it', () {
|
||||
expect(resolved(const [Locale('en', 'US')]), const Locale('en', 'US'));
|
||||
expect(resolved(const [Locale('en', 'GB')]), const Locale('en', 'GB'));
|
||||
expect(resolved(const [Locale('de', 'DE')]), const Locale('de'));
|
||||
expect(resolved(const [Locale('de')]), const Locale('de'));
|
||||
});
|
||||
|
||||
test('British English for any other English', () {
|
||||
expect(resolved(const [Locale('en')]), const Locale('en', 'GB'));
|
||||
expect(resolved(const [Locale('en', 'AU')]), const Locale('en', 'GB'));
|
||||
});
|
||||
|
||||
test('the next language the device prefers, where the first is none the '
|
||||
'app speaks', () {
|
||||
expect(
|
||||
resolved(const [Locale('fr', 'FR'), Locale('de', 'AT')]),
|
||||
const Locale('de'),
|
||||
);
|
||||
});
|
||||
|
||||
test('British English where the app speaks none of them', () {
|
||||
expect(resolved(const [Locale('fr', 'FR')]), const Locale('en', 'GB'));
|
||||
expect(resolved(const []), const Locale('en', 'GB'));
|
||||
expect(resolved(null), const Locale('en', 'GB'));
|
||||
});
|
||||
|
||||
test('never a language picked by the country alone', () {
|
||||
// Spanish in the United States isn't American English.
|
||||
expect(resolved(const [Locale('es', 'US')]), const Locale('en', 'GB'));
|
||||
});
|
||||
|
||||
test('every language this package speaks is one it resolves to', () {
|
||||
for (final locale in HalkyonAppLocalizations.supportedLocales) {
|
||||
expect(
|
||||
resolveAppLocale([locale], HalkyonAppLocalizations.supportedLocales),
|
||||
isIn(HalkyonAppLocalizations.supportedLocales),
|
||||
reason: '$locale',
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue