Files
sure/mobile/test/theme/sure_theme_test.dart
ghost 360989c3a9 feat(mobile): align theme foundation with Sure tokens (#2237)
* feat(mobile): align theme foundation with Sure tokens

Generate typed Flutter token constants from the canonical Sure token JSON and route the app through shared light/dark ThemeData construction. This keeps the first mobile design-system step scoped to foundation wiring and regression tests without restyling screens directly.

* fix(mobile): define Sure error container colors

Populate the manual Flutter ColorScheme error container pair from Sure tokens so validation and connection banners keep visible icon/text contrast. Add theme assertions for both light and dark modes.

* fix(mobile): preserve full-width action buttons
2026-06-11 16:19:15 +02:00

61 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sure_mobile/main.dart';
import 'package:sure_mobile/theme/sure_theme.dart';
import 'package:sure_mobile/theme/sure_tokens.dart';
void main() {
test('light theme uses Sure token values', () {
final theme = SureTheme.light;
expect(theme.brightness, Brightness.light);
expect(theme.textTheme.bodyMedium?.fontFamily, SureTokens.fontSans);
expect(theme.colorScheme.primary, SureTokens.light.link);
expect(theme.colorScheme.secondary, SureTokens.light.info);
expect(theme.colorScheme.surface, SureTokens.light.surface);
expect(theme.colorScheme.onSurface, SureTokens.light.textPrimary);
expect(theme.colorScheme.error, SureTokens.light.destructive);
expect(
theme.colorScheme.errorContainer, SureTokens.light.destructiveSubtle);
expect(theme.colorScheme.onErrorContainer, SureTokens.light.textPrimary);
expect(theme.scaffoldBackgroundColor, SureTokens.light.surface);
expect(theme.cardTheme.color, SureTokens.light.container);
expect(
theme.elevatedButtonTheme.style?.minimumSize?.resolve({}),
const Size(double.infinity, 50),
);
});
test('dark theme uses Sure token values', () {
final theme = SureTheme.dark;
expect(theme.brightness, Brightness.dark);
expect(theme.textTheme.bodyMedium?.fontFamily, SureTokens.fontSans);
expect(theme.colorScheme.primary, SureTokens.dark.link);
expect(theme.colorScheme.secondary, SureTokens.dark.info);
expect(theme.colorScheme.surface, SureTokens.dark.surface);
expect(theme.colorScheme.onSurface, SureTokens.dark.textPrimary);
expect(theme.colorScheme.error, SureTokens.dark.destructive);
expect(theme.colorScheme.errorContainer, SureTokens.dark.destructiveSubtle);
expect(theme.colorScheme.onErrorContainer, SureTokens.dark.textPrimary);
expect(theme.scaffoldBackgroundColor, SureTokens.dark.surface);
expect(theme.cardTheme.color, SureTokens.dark.container);
expect(
theme.elevatedButtonTheme.style?.minimumSize?.resolve({}),
const Size(double.infinity, 50),
);
});
testWidgets('app wires Sure light and dark themes', (tester) async {
SharedPreferences.setMockInitialValues({});
await tester.pumpWidget(const SureApp());
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.theme?.colorScheme.surface, SureTokens.light.surface);
expect(materialApp.darkTheme?.colorScheme.surface, SureTokens.dark.surface);
expect(materialApp.themeMode, ThemeMode.system);
});
}