a0380aef51
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
125 lines
4.1 KiB
Dart
125 lines
4.1 KiB
Dart
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<AppDesign>(
|
|
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<int>(
|
|
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,
|
|
// Glass blends with the comfortable designs and snaps to Compact.
|
|
AppDesign.glass,
|
|
AppDesign.compact,
|
|
AppDesign.glass,
|
|
]) {
|
|
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;
|
|
});
|
|
}
|