30d2d8c4f4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
135 lines
4.8 KiB
Dart
135 lines
4.8 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 High contrast animates the theme (or
|
|
/// snaps it, beside a dense design) without an error in any frame: a
|
|
/// component text style from the unlocalized text theme cannot blend with
|
|
/// another design's default (High contrast sets none on buttons).
|
|
void main() {
|
|
testWidgets('switching to and from High contrast lerps every frame cleanly', (
|
|
tester,
|
|
) async {
|
|
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
|
|
final design = ValueNotifier(AppDesign.highContrast);
|
|
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: (_) {}),
|
|
FilledButton(onPressed: () {}, child: const Text('f')),
|
|
OutlinedButton(onPressed: () {}, child: const Text('o')),
|
|
TextButton(onPressed: () {}, child: const Text('t')),
|
|
MenuItemButton(onPressed: () {}, child: const Text('m')),
|
|
const Badge(label: Text('3'), child: Icon(Icons.add)),
|
|
const Tooltip(message: 'tip', child: Text('tip')),
|
|
const DefaultTabController(
|
|
length: 2,
|
|
child: TabBar(
|
|
tabs: [
|
|
Tab(text: 'a'),
|
|
Tab(text: 'b'),
|
|
],
|
|
),
|
|
),
|
|
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 [
|
|
for (final d in AppDesign.values)
|
|
if (d != AppDesign.highContrast) ...[d, AppDesign.highContrast],
|
|
]) {
|
|
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;
|
|
});
|
|
}
|