Templates: shared list rows, named detail bar, compact create, 720 cap

This commit is contained in:
2026-10-31 05:20:00 +00:00
parent 06f6eda360
commit d49ab0667b
8 changed files with 275 additions and 130 deletions
@@ -6,6 +6,9 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/templates/screen.dart';
import 'package:pipelines_app/features/templates/ui/template_detail.dart';
import 'package:pipelines_app/features/templates/ui/template_gallery.dart'
show templateAvatarKey;
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import '../data/template_test_support.dart' show source;
import 'template_gallery_test_support.dart';
@@ -31,15 +34,19 @@ void main() {
expect(find.byKey(templatesGalleryKey), findsOneWidget);
expect(find.text('Release workflow'), findsOneWidget);
expect(find.text('Ship a version'), findsOneWidget);
expect(find.text('2 stages'), findsNWidgets(2));
// One subtitle line: the description, then the parsed stage count.
expect(find.text('Ship a version · 2 stages'), findsOneWidget);
expect(find.text('No display name · 2 stages'), findsOneWidget);
expect(find.text('(unnamed template)'), findsOneWidget);
expect(find.byKey(templatesLoadingKey), findsNothing);
// The app's shared rows with an initial avatar; no chevrons or tiles.
expect(find.byType(AppListRow), findsNWidgets(2));
expect(find.byKey(templateAvatarKey('release')), findsOneWidget);
expect(find.byType(ListTile), findsNothing);
expect(find.byIcon(Icons.chevron_right), findsNothing);
});
testWidgets('stage count is unavailable when server parsing refuses', (
tester,
) async {
testWidgets('an unknown stage count is left out of the row', (tester) async {
final gateway =
GalleryGateway((type, fields) async => templatesReply(galleryTemplates))
..validationHandler = (type, fields) async {
@@ -48,8 +55,9 @@ void main() {
await pumpGallery(tester, gateway);
expect(find.text('stage count unavailable'), findsNWidgets(2));
expect(find.text('0 stages'), findsNothing);
expect(find.textContaining('stage count'), findsNothing);
expect(find.textContaining('stages'), findsNothing);
expect(find.text('Ship a version'), findsOneWidget);
expect(gateway.callsOf('validate'), hasLength(2));
expect(
gateway.callsOf('validate').first.fields['source'],
@@ -162,9 +170,20 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(templateDetailKey), findsOneWidget);
// The bar's title pill names the template; the body does not repeat it.
final bar = find.byType(SegmentedBar);
expect(
find.descendant(of: bar, matching: find.text('Release workflow')),
findsOneWidget,
);
expect(
find.descendant(of: bar, matching: find.text('Ship a version')),
findsOneWidget,
);
expect(find.text('Release workflow'), findsOneWidget);
expect(find.text('Ship a version'), findsOneWidget);
expect(find.text('Key'), findsOneWidget);
expect(find.text('Key'), findsNothing);
expect(find.byKey(templateKeyKey), findsOneWidget);
expect(find.text('Includes a schedule'), findsOneWidget);
expect(find.text(templateSourceLabel), findsOneWidget);
expect(selectableSource(source), findsOneWidget);
@@ -230,7 +249,8 @@ void main() {
);
await pumpGallery(tester, gateway, cupertino: true);
expect(find.byType(CupertinoListTile), findsNWidgets(2));
expect(find.byType(AppListRow), findsNWidgets(2));
expect(find.byType(CupertinoListTile), findsNothing);
expect(find.byType(Scaffold), findsNothing);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
@@ -247,7 +267,7 @@ void main() {
await tester.tap(find.byKey(templatesBackKey));
await tester.pumpAndSettle();
expect(find.byType(CupertinoListTile), findsNWidgets(2));
expect(find.byType(AppListRow), findsNWidgets(2));
});
testWidgets(
@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/templates/screen.dart';
import 'package:pipelines_app/features/templates/ui/template_detail.dart';
import 'package:pipelines_app/features/templates/ui/template_gallery.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import '../data/template_test_support.dart' show source;
import 'template_gallery_test_support.dart';
/// The gallery and an open template on a wide window: the column stops at the
/// Settings reading width, start-aligned; the bar names the open template and
/// the Create action is a compact button, not a full-width bar.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host: rows and detail are capped at 720 on a wide window', (
tester,
) async {
final gateway = GalleryGateway(
(type, fields) async => templatesReply(galleryTemplates),
);
await pumpGallery(
tester,
gateway,
cupertino: cupertino,
size: const Size(1200, 800),
);
final row = tester.getRect(find.byKey(templateRowKey('release')));
expect(row.left, 0);
expect(row.width, templatesContentMaxWidth);
expect(find.text('Templates'), findsOneWidget);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
final bar = find.byType(SegmentedBar);
expect(
find.descendant(of: bar, matching: find.text('Release workflow')),
findsOneWidget,
);
expect(find.text('Templates'), findsNothing);
final create = tester.getRect(find.byKey(templateCreateActionKey));
expect(create.left, 16);
// Its own width, not stretched across the 688 content column.
expect(create.width, lessThan(templatesContentMaxWidth - 32));
final body = tester.getRect(selectableSource(source));
expect(body.right, lessThanOrEqualTo(templatesContentMaxWidth));
expect(tester.takeException(), isNull);
});
testWidgets('$host: the detail fits 320 at 2x text', (tester) async {
final gateway = GalleryGateway(
(type, fields) async => templatesReply(galleryTemplates),
);
await pumpGallery(
tester,
gateway,
cupertino: cupertino,
size: const Size(320, 800),
textScale: 2,
);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
expect(find.byKey(templateCreateActionKey), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
}