Files
pipelines/app/test/ui/theme/app_font_theme_test.dart
T
alan 8ed3998dd5 Design: Terminal is the default when none is stored; Default is now Classic
An unset (or unknown) design id resolves to Terminal, in the controller's
initial value, AppDesign.fromId and the boot spinner. A stored choice,
including Classic's stable 'default' id, is respected. The picker calls the
original Material look Classic so no row reads 'Default'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 21:33:05 +00:00

69 lines
2.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/app.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/theme/app_design_controller.dart';
import 'package:pipelines_app/ui/theme/app_font.dart';
import 'package:pipelines_app/ui/theme/app_font_controller.dart';
import 'package:pipelines_app/ui/theme/app_font_store.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
void main() {
test('Material themes take the family and keep sizes and weights', () {
for (final build in <ThemeData Function({String? fontFamily})>[
appLightTheme,
appDarkTheme,
]) {
final system = build().textTheme;
final inter = build(fontFamily: 'Inter').textTheme;
expect(build().textTheme.bodyMedium?.fontFamily, isNot('Inter'));
for (final (a, b) in <(TextStyle?, TextStyle?)>[
(system.bodyMedium, inter.bodyMedium),
(system.titleMedium, inter.titleMedium),
(system.labelLarge, inter.labelLarge),
(system.headlineSmall, inter.headlineSmall),
]) {
expect(b?.fontFamily, 'Inter');
expect(b?.fontSize, a?.fontSize);
expect(b?.fontWeight, a?.fontWeight);
}
}
});
testWidgets('the Material host switches font live, without a restart', (
tester,
) async {
final fonts = AppFontController(
store: MemoryAppFontStore(),
loader: (family, assets) async {},
);
// Classic follows the interface font (Terminal keeps its monospace).
final designs = AppDesignController(store: MemoryAppDesignStore('default'));
await designs.restore();
String? family;
await tester.pumpWidget(
MyApp(
fonts: fonts,
designs: designs,
destination: AppDestination.settings,
destinationBodies: <AppDestination, WidgetBuilder>{
AppDestination.settings: (context) => Builder(
builder: (context) {
family = DefaultTextStyle.of(context).style.fontFamily;
return const Text('body');
},
),
},
),
);
final before = family;
expect(before, isNot('IBM Plex Sans'));
await fonts.select(AppFont.ibmPlexSans);
await tester.pumpAndSettle();
expect(family, 'IBM Plex Sans');
await fonts.select(AppFont.system);
await tester.pumpAndSettle();
expect(family, before);
});
}