Colour the turn change chip's counts

"3 files changed +9 −2" now shows additions in green and removals in red,
using the run Changes colours, in light and dark themes.
This commit is contained in:
2026-11-09 19:01:09 +00:00
parent 73e55b0b0c
commit 15939fcf09
3 changed files with 75 additions and 6 deletions
@@ -1,3 +1,4 @@
import 'package:pipelines_app/features/changes/widgets/change_style.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -210,4 +211,39 @@ void main() {
expect(find.text('lib/a.dart'), findsOneWidget);
});
}
testWidgets('additions are green and removals red in the chip', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: ChatTurnDiffChip(
summary: const {'files': 3, 'additions': 9, 'deletions': 2},
load: () async => const {},
),
),
),
);
final context = tester.element(find.byType(ChatTurnDiffChip));
final rich = tester.widget<RichText>(
find.descendant(
of: find.byType(ChatTurnDiffChip),
matching: find.byWidgetPredicate(
(w) => w is RichText && w.text.toPlainText().contains('changed'),
),
),
);
expect(rich.text.toPlainText(), '3 files changed +9 −2');
final colours = <String, Color?>{};
rich.text.visitChildren((span) {
if (span is TextSpan && span.text != null) {
colours[span.text!] = span.style?.color;
}
return true;
});
expect(colours['+9'], addedColor(context));
expect(colours['−2'], removedColor(context));
expect(addedColor(context), isNot(removedColor(context)));
});
}