import 'package:cutdex/features/projects/sidebar_category_tabs.dart'; import 'package:cutdex/l10n/app_localizations.dart'; import 'package:cutdex_ui/theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('sidebar categories fit themes, narrow widths and large text', ( tester, ) async { for (final palette in AppPalette.values) { for (final brightness in Brightness.values) { for (final locale in const [Locale('zh'), Locale('en'), Locale('de')]) { for (final width in [120.0, 180.0, 280.0]) { var media = false; await tester.pumpWidget( MaterialApp( theme: AppTheme.desktopWorkspaceTheme( AppTheme.forPalette(palette, brightness), ), locale: locale, localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, home: Scaffold( body: Align( alignment: Alignment.topLeft, child: SizedBox( width: width, child: MediaQuery( data: const MediaQueryData( textScaler: TextScaler.linear(2), ), child: StatefulBuilder( builder: (context, setState) => SidebarCategoryTabs( mediaSelected: media, onSelected: (value) => setState(() => media = value), ), ), ), ), ), ), ), ); await tester.pumpAndSettle(); final header = tester.getRect( find.byKey(const Key('sidebar-category-header')), ); final chat = tester.getRect( find.byKey(const Key('sidebar-tab-chat')), ); final resources = tester.getRect( find.byKey(const Key('sidebar-tab-resources')), ); expect(header.height, 36); expect(chat.height, 28); expect(resources.height, 28); expect(chat.left - header.left, 12); expect(header.right - resources.right, 12); expect(resources.left - chat.right, 4); await tester.tap(find.byKey(const Key('sidebar-tab-resources'))); await tester.pump(); expect(media, isTrue); await tester.tap(find.byKey(const Key('sidebar-tab-chat'))); await tester.pump(); expect(media, isFalse); expect( tester.takeException(), isNull, reason: '$palette $brightness $locale width=$width', ); } } } } }); }