import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/chat/domain/chat_transcript.dart'; import 'package:pipelines_app/features/chat/ui/transcript/chat_message_view.dart'; import 'package:pipelines_app/ui/theme/app_design.dart'; final _rows = transcriptRows([ for (var i = 0; i < 6; i++) ...[ { 'id': 'u$i', 'role': 'user', 'parts': [ {'type': 'text', 'text': 'Step $i'}, ], }, { 'id': 'a$i', 'role': 'assistant', 'parts': [ { 'type': 'tool', 'id': 't$i', 'name': 'Bash', 'state': { 'status': 'completed', 'input': {'command': 'go test'}, }, }, {'type': 'text', 'text': 'Fixed `x`.\n\n- one\n\n```go\nreturn 1\n```'}, ], }, ], ]); /// A live design switch to and from Compact animates the theme without an /// error in any frame. A component theme that set a text-theme style failed /// to lerp against Default's unset one, and in the browser the broken /// frames stopped the app drawing. void main() { testWidgets('switching to and from Compact lerps every frame cleanly', ( tester, ) async { debugDefaultTargetPlatformOverride = TargetPlatform.linux; final design = ValueNotifier(AppDesign.compact); await tester.pumpWidget( ValueListenableBuilder( valueListenable: design, builder: (_, d, _) => MaterialApp( theme: d.dark(), darkTheme: d.dark(), home: Scaffold( floatingActionButton: FloatingActionButton.extended( onPressed: () {}, icon: const Icon(Icons.add), label: const Text('New run'), ), body: Row( children: [ NavigationRail( destinations: const [ NavigationRailDestination( icon: Icon(Icons.add), label: Text('a'), ), NavigationRailDestination( icon: Icon(Icons.add), label: Text('b'), ), ], selectedIndex: 0, ), Expanded( child: ListView( children: [ IconButton(onPressed: () {}, icon: const Icon(Icons.add)), IconButton.filled( onPressed: () {}, icon: const Icon(Icons.add), ), Checkbox(value: true, onChanged: (_) {}), Switch(value: true, onChanged: (_) {}), const ListTile(title: Text('t'), subtitle: Text('s')), const TextField(), Chip(label: const Text('c'), onDeleted: () {}), SegmentedButton( segments: const [ ButtonSegment(value: 1, label: Text('one')), ButtonSegment(value: 2, label: Text('two')), ], selected: const {1}, ), for (final row in _rows) ChatMessageView(row: row), ], ), ), ], ), ), ), ), ); await tester.pumpAndSettle(); for (var round = 0; round < 3; round++) { for (final other in [ AppDesign.standard, AppDesign.terminal, AppDesign.paper, AppDesign.compact, ]) { design.value = other; for (var f = 0; f < 20; f++) { await tester.pump(const Duration(milliseconds: 16)); final e = tester.takeException(); if (e != null) fail('to ${other.id} frame $f: $e'); } } } debugDefaultTargetPlatformOverride = null; }); }