Files
sxchnge/frontend/packages/sxchnge_theme/example/test/integration_test.dart
T
Stephan D d9318053e8 Prepare product layout and reusable Flutter theme
Relocate the existing Astro website and preserve its assets and hosting configuration. Add the consumer/backend scaffold and themed Flutter package with consumer tests. Related to #1.
2026-09-11 15:36:58 +02:00

52 lines
1.8 KiB
Dart

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sxchnge_theme_example/main.dart';
void main() {
testWidgets('consumer bundles the package font and its license', (
tester,
) async {
await tester.pumpWidget(const ThemeExample());
final manifest =
jsonDecode(await rootBundle.loadString('FontManifest.json')) as List;
final family = manifest.cast<Map>().singleWhere(
(font) => font['family'] == 'packages/sxchnge_theme/Onest',
);
final asset = (family['fonts'] as List).first['asset'] as String;
expect((await rootBundle.load(asset)).lengthInBytes, greaterThan(1000));
expect(
await rootBundle.loadString(
'packages/sxchnge_theme/assets/fonts/OFL.txt',
),
contains('SIL OPEN FONT LICENSE'),
);
});
for (final mode in [ThemeMode.light, ThemeMode.dark]) {
testWidgets(
'$mode renders on a narrow screen with large text and accepts input',
(tester) async {
tester.view.physicalSize = const Size(320, 900);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = 2;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
await tester.pumpWidget(ThemeExample(mode: mode));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
await tester.enterText(find.byType(TextField).first, '125.50');
expect(find.text('125.50'), findsOneWidget);
await tester.ensureVisible(find.text('Continue'));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
},
);
}
}