Share one list row across runs, pipelines, chat, search and schedules
AppListRow (Material + Cupertino) with avatar, bold title and trailing time, one muted line, one overflow menu style, inset dividers, selected and emphasised states and a compact mode. Pipelines get a legible initial avatar, schedule rows shrink to two lines with Edit/Pause/Delete in an overflow menu, and the shell chat list scrolls behind the bar.
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:ui' show Tristate;
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:pipelines_app/features/chat/screen.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
@@ -175,39 +176,24 @@ void main() {
|
||||
selected,
|
||||
reason: '$destination: $rowKey after opening $key',
|
||||
);
|
||||
// Every list uses the shared row and its highlight.
|
||||
final context = tester.element(row);
|
||||
if (cupertino) {
|
||||
final color = destination == 'Runs'
|
||||
? tester.widget<CupertinoButton>(row).color
|
||||
: tester.widget<CupertinoListTile>(row).backgroundColor;
|
||||
expect(
|
||||
color,
|
||||
selected
|
||||
? CupertinoColors.tertiarySystemFill.resolveFrom(
|
||||
context,
|
||||
)
|
||||
: isNull,
|
||||
);
|
||||
} else if (destination == 'Runs') {
|
||||
final id = rowKey.split('-').last;
|
||||
expect(
|
||||
tester
|
||||
.widget<Material>(
|
||||
find.byKey(ValueKey('run-row-surface-$id')),
|
||||
expect(tester.widget<AppListRow>(row).selected, selected);
|
||||
final surface = find.descendant(
|
||||
of: row,
|
||||
matching: find.byKey(appListRowSurfaceKey),
|
||||
);
|
||||
expect(
|
||||
cupertino
|
||||
? tester.widget<ColoredBox>(surface).color
|
||||
: tester.widget<Material>(surface).color,
|
||||
selected
|
||||
? AppListRow.selectedColor(
|
||||
context,
|
||||
cupertino: cupertino,
|
||||
)
|
||||
.color,
|
||||
selected
|
||||
? Theme.of(context).colorScheme.secondaryContainer
|
||||
: Colors.transparent,
|
||||
);
|
||||
} else {
|
||||
final tile = tester.widget<ListTile>(row);
|
||||
expect(tile.selected, selected);
|
||||
expect(
|
||||
tile.selectedTileColor,
|
||||
Theme.of(context).colorScheme.secondaryContainer,
|
||||
);
|
||||
}
|
||||
: const Color(0x00000000),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (destination == 'Chat') {
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/application/app_session.dart';
|
||||
import 'package:pipelines_app/application/pipelines_destination.dart';
|
||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||
@@ -202,7 +203,9 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(find.text('hash-alpha'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('pipeline-row-1'))).selected,
|
||||
tester
|
||||
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
|
||||
.selected,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
@@ -229,7 +232,9 @@ void main() {
|
||||
expect(find.text('Reconnecting to Pipelines…'), findsNothing);
|
||||
expect(find.text('hash-alpha'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('pipeline-row-1'))).selected,
|
||||
tester
|
||||
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
|
||||
.selected,
|
||||
isTrue,
|
||||
reason: 'A reconnect must not remount the screen or drop the selection.',
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -53,7 +54,7 @@ void main() {
|
||||
await _pumpShell(tester, size);
|
||||
expect(find.text('Select a chat to open it here.'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('chat-row-a'))).selected,
|
||||
tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
@@ -66,11 +67,11 @@ void main() {
|
||||
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
|
||||
expect(find.text('Second chat'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('chat-row-a'))).selected,
|
||||
tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('chat-row-b'))).selected,
|
||||
tester.widget<AppListRow>(find.byKey(const Key('chat-row-b'))).selected,
|
||||
isFalse,
|
||||
);
|
||||
// The shell bar keeps the list's controls; the pane bar has the chat's
|
||||
@@ -91,11 +92,11 @@ void main() {
|
||||
expect(find.byKey(const ValueKey('chat-thread-a')), findsNothing);
|
||||
expect(find.byKey(const ValueKey('chat-thread-b')), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('chat-row-a'))).selected,
|
||||
tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('chat-row-b'))).selected,
|
||||
tester.widget<AppListRow>(find.byKey(const Key('chat-row-b'))).selected,
|
||||
isTrue,
|
||||
);
|
||||
expect(navigator.canPop(), isFalse);
|
||||
@@ -123,7 +124,7 @@ void main() {
|
||||
await tester.pageBack();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('chat-row-a'))).selected,
|
||||
tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:ui' show Tristate;
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
|
||||
|
||||
import 'chat_test_harness.dart';
|
||||
@@ -59,24 +60,23 @@ void main() {
|
||||
Tristate.isTrue,
|
||||
active,
|
||||
);
|
||||
if (cupertino) {
|
||||
final tile = tester.widget<CupertinoListTile>(row);
|
||||
expect(
|
||||
tile.backgroundColor,
|
||||
active
|
||||
? CupertinoColors.tertiarySystemFill.resolveFrom(
|
||||
tester.element(row),
|
||||
)
|
||||
: isNull,
|
||||
);
|
||||
} else {
|
||||
final tile = tester.widget<ListTile>(row);
|
||||
expect(tile.selected, active);
|
||||
expect(
|
||||
tile.selectedTileColor,
|
||||
Theme.of(tester.element(row)).colorScheme.secondaryContainer,
|
||||
);
|
||||
}
|
||||
expect(tester.widget<AppListRow>(row).selected, active);
|
||||
final surface = find.descendant(
|
||||
of: row,
|
||||
matching: find.byKey(appListRowSurfaceKey),
|
||||
);
|
||||
final color = cupertino
|
||||
? tester.widget<ColoredBox>(surface).color
|
||||
: tester.widget<Material>(surface).color;
|
||||
expect(
|
||||
color,
|
||||
active
|
||||
? AppListRow.selectedColor(
|
||||
tester.element(row),
|
||||
cupertino: cupertino,
|
||||
)
|
||||
: const Color(0x00000000),
|
||||
);
|
||||
}
|
||||
|
||||
expectRow('a', true);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_row_style.dart';
|
||||
|
||||
/// A grouped Cupertino list, the host the web client runs on macOS/iOS.
|
||||
/// The Cupertino list, the host the web client runs on macOS/iOS.
|
||||
Future<void> _pumpRows(
|
||||
WidgetTester tester,
|
||||
List<JsonMap> sessions, {
|
||||
@@ -193,7 +194,7 @@ void main() {
|
||||
|
||||
// Unread is bold with an accent time and dot; read rows are not.
|
||||
expect(_styleOf(tester, 'Unread chat').fontWeight, FontWeight.w700);
|
||||
expect(_styleOf(tester, 'Read chat').fontWeight, FontWeight.w500);
|
||||
expect(_styleOf(tester, 'Read chat').fontWeight, FontWeight.w600);
|
||||
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
|
||||
final accent = CupertinoTheme.of(
|
||||
tester.element(find.text('5 min ago')),
|
||||
@@ -216,10 +217,10 @@ void main() {
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(CupertinoListTile), findsNWidgets(2));
|
||||
expect(find.byType(AppListRow), findsNWidgets(2));
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(const Key('chat-row-s2'))).dy,
|
||||
greaterThan(
|
||||
greaterThanOrEqualTo(
|
||||
tester.getBottomLeft(find.byKey(const Key('chat-row-s1'))).dy,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
|
||||
import 'expand_closed.dart';
|
||||
|
||||
/// The Android host: a Material grouped list with its native separators.
|
||||
/// The Android host: the Material list with the shared row's dividers.
|
||||
Future<void> _pumpRows(
|
||||
WidgetTester tester,
|
||||
List<JsonMap> sessions, {
|
||||
@@ -107,11 +108,16 @@ void main() {
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
// Native Material separators sit between rows, not around the group.
|
||||
expect(find.byType(Divider), findsOneWidget);
|
||||
// One inset divider between the rows, none after the last; it starts
|
||||
// under the text, not at the edge.
|
||||
expect(find.byKey(appListRowDividerKey), findsOneWidget);
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(appListRowDividerKey)).dx,
|
||||
closeTo(title.left, 1),
|
||||
);
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(const Key('chat-row-s2'))).dy,
|
||||
greaterThan(
|
||||
greaterThanOrEqualTo(
|
||||
tester.getBottomLeft(find.byKey(const Key('chat-row-s1'))).dy,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
import 'package:pipelines_app/shell/detail_page.dart';
|
||||
|
||||
@@ -24,17 +25,32 @@ void main() {
|
||||
// Filter and sort are app-bar actions; no toolbar row without a filter.
|
||||
expect(find.byKey(const Key('pipeline-toolbar')), findsNothing);
|
||||
// Each pipeline has a deterministic tinted initial rather than one generic
|
||||
// flow icon, while the title follows native ListTile spacing.
|
||||
// flow icon, while the title follows the shared row's spacing.
|
||||
expect(find.byKey(const Key('pipeline-avatar-1')), findsOneWidget);
|
||||
expect(
|
||||
tester.getTopLeft(find.text('Alpha review')).dx,
|
||||
greaterThan(listLeft),
|
||||
);
|
||||
|
||||
// Inset dividers between rows, none after the last.
|
||||
expect(
|
||||
find.descendant(of: list, matching: find.byType(Divider)),
|
||||
find.descendant(of: list, matching: find.byKey(appListRowDividerKey)),
|
||||
findsNWidgets(fixture.summaries.length - 1),
|
||||
);
|
||||
// The divider starts under the title, not at the list edge.
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(appListRowDividerKey).first).dx,
|
||||
closeTo(tester.getTopLeft(find.text('Alpha review')).dx, 1),
|
||||
);
|
||||
// The initial is legible: a 40px circle with a large glyph.
|
||||
final avatar = find.byKey(const Key('pipeline-avatar-1'));
|
||||
expect(tester.getSize(avatar), const Size.square(40));
|
||||
expect(
|
||||
tester
|
||||
.getSize(find.descendant(of: avatar, matching: find.text('A')))
|
||||
.height,
|
||||
greaterThanOrEqualTo(14),
|
||||
);
|
||||
|
||||
// The title's trailing time and the one muted facts line replace the old
|
||||
// version/id, run metadata, and graph stack.
|
||||
@@ -196,7 +212,7 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino keeps native tiles with the same row identity', (
|
||||
testWidgets('Cupertino keeps the shared row with the same row identity', (
|
||||
tester,
|
||||
) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
@@ -211,7 +227,12 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(CupertinoListTile), findsWidgets);
|
||||
expect(
|
||||
tester
|
||||
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
|
||||
.cupertino,
|
||||
isTrue,
|
||||
);
|
||||
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
|
||||
expect(find.textContaining('v2 · #'), findsNothing);
|
||||
expect(find.byKey(const Key('pipeline-avatar-1')), findsOneWidget);
|
||||
|
||||
@@ -61,13 +61,18 @@ void main() {
|
||||
expect(find.text('Schedules (1)'), findsOneWidget);
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Every 24h · mon, wed · Europe/London'),
|
||||
find.text('v3 · Every 24h · mon, wed · Europe/London'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(scheduleAddKey), findsOneWidget);
|
||||
// Edit, Pause and Delete are the row's overflow menu.
|
||||
await tester.tap(find.byKey(scheduleRowMenuKey(8)));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowDeleteKey(8)), findsOneWidget);
|
||||
await tester.tapAt(const Offset(4, 4));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.callsOf('list_schedules').single.fields, {'pipeline_id': 1});
|
||||
|
||||
await tester.tap(find.text('Source'));
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import '../../native_back.dart';
|
||||
import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
|
||||
@@ -122,7 +123,13 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
|
||||
expect(find.byType(CupertinoListTile), findsWidgets);
|
||||
// The shared list row, in its Cupertino form.
|
||||
expect(
|
||||
tester
|
||||
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
|
||||
.cupertino,
|
||||
isTrue,
|
||||
);
|
||||
expect(find.byType(CupertinoActionSheet), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
@@ -129,7 +130,7 @@ void main() {
|
||||
await tester.tap(find.byTooltip('Refresh'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final row = tester.widget<ListTile>(
|
||||
final row = tester.widget<AppListRow>(
|
||||
find.byKey(const Key('pipeline-row-1')),
|
||||
);
|
||||
expect(row.selected, isTrue);
|
||||
|
||||
@@ -30,16 +30,15 @@ void main() {
|
||||
|
||||
expect(find.text('2 schedules'), findsOneWidget);
|
||||
expect(find.textContaining('not pipeline definitions'), findsOneWidget);
|
||||
// Two lines per row: the name with its next run, then the timer
|
||||
// and pinned pipeline version. The editor holds the rest.
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
expect(find.text('Find battery chemistry sources'), findsOneWidget);
|
||||
expect(find.text('Pipeline 4 · v2'), findsOneWidget);
|
||||
expect(find.text('Workspace: /srv/research'), findsOneWidget);
|
||||
expect(find.text('Timer: Every 24h · mon, wed'), findsOneWidget);
|
||||
expect(find.text('Timezone: Europe/London'), findsOneWidget);
|
||||
expect(find.text('22 Oct 09:00'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Next due: 2026-10-22 09:00 (your local time)'),
|
||||
find.text('Every 24h · mon, wed · Pipeline 4 · v2'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Find battery chemistry sources'), findsNothing);
|
||||
|
||||
await tester.scrollUntilVisible(
|
||||
find.text('Nightly report'),
|
||||
@@ -50,11 +49,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
expect(find.text('Nightly report'), findsOneWidget);
|
||||
expect(find.text('Pipeline 7 · v5'), findsOneWidget);
|
||||
expect(find.text('Workspace: /srv/reports'), findsOneWidget);
|
||||
expect(find.text('Timer: 10:00, 18:30'), findsOneWidget);
|
||||
expect(find.text('Timezone: Server timezone'), findsOneWidget);
|
||||
expect(find.text('Next due: Paused'), findsOneWidget);
|
||||
expect(find.text('10:00, 18:30 · Pipeline 7 · v5'), findsOneWidget);
|
||||
expect(find.text('Paused'), findsOneWidget);
|
||||
|
||||
if (cupertino) {
|
||||
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||
|
||||
@@ -18,6 +18,20 @@ Future<void> _tapSave(WidgetTester tester) async {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// Edit, Pause/Enable and Delete live in the row's overflow menu.
|
||||
Future<void> _openMenu(WidgetTester tester, int id) async {
|
||||
await tester.ensureVisible(find.byKey(scheduleRowMenuKey(id)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(scheduleRowMenuKey(id)));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> _pick(WidgetTester tester, Key item, int id) async {
|
||||
await _openMenu(tester, id);
|
||||
await tester.tap(find.byKey(item));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('lists this pipeline schedules with server values and states', (
|
||||
tester,
|
||||
@@ -46,21 +60,24 @@ void main() {
|
||||
|
||||
expect(find.text('Schedules (2)'), findsOneWidget);
|
||||
expect(find.text('Research batteries'), findsOneWidget);
|
||||
// Two lines: the name with its next run, then version and timer words.
|
||||
expect(
|
||||
find.text('Every 24h · mon, wed · Europe/London'),
|
||||
find.text('v2 · Every 24h · mon, wed · Europe/London'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Paused'), findsWidgets);
|
||||
expect(find.text('Nightly report'), findsOneWidget);
|
||||
expect(
|
||||
find.text('10:00, 18:30 · Server timezone'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Enabled'), findsOneWidget);
|
||||
expect(find.text('Paused'), findsWidgets);
|
||||
expect(find.text('Paused'), findsWidgets);
|
||||
expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget);
|
||||
expect(find.text('v5 · 10:00, 18:30 · Server timezone'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel(RegExp('Enabled')), findsOneWidget);
|
||||
expect(find.bySemanticsLabel(RegExp('Paused')), findsOneWidget);
|
||||
expect(find.text('Paused'), findsOneWidget);
|
||||
// The prompt and the inline text buttons are gone from the row.
|
||||
expect(find.text('Edit'), findsNothing);
|
||||
expect(find.byKey(scheduleRowMenuKey(8)), findsOneWidget);
|
||||
await _openMenu(tester, 9);
|
||||
expect(find.byKey(scheduleRowEditKey(9)), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowToggleKey(9)), findsOneWidget);
|
||||
expect(find.text('Enable'), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowDeleteKey(9)), findsOneWidget);
|
||||
expect(gateway.calls.map((call) => call.type), ['list_schedules']);
|
||||
expect(gateway.calls.single.fields, {'pipeline_id': 4});
|
||||
});
|
||||
@@ -187,7 +204,7 @@ void main() {
|
||||
});
|
||||
await pumpScheduleSection(tester, gateway: gateway);
|
||||
|
||||
await tester.tap(find.byKey(scheduleRowEditKey(8)));
|
||||
await _pick(tester, scheduleRowEditKey(8), 8);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester
|
||||
@@ -238,14 +255,14 @@ void main() {
|
||||
});
|
||||
await pumpScheduleSection(tester, gateway: gateway);
|
||||
|
||||
await tester.tap(find.byKey(scheduleRowToggleKey(8)));
|
||||
await _pick(tester, scheduleRowToggleKey(8), 8);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final call = gateway.callsOf('save_schedule').single;
|
||||
expect(call.fields.containsKey('request_key'), isFalse);
|
||||
expect(call.fields['schedule'], {...original, 'enabled': false});
|
||||
expect(find.text('Paused'), findsWidgets);
|
||||
expect(find.text('Paused'), findsWidgets);
|
||||
expect(find.text('Paused'), findsOneWidget);
|
||||
await _openMenu(tester, 8);
|
||||
expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget);
|
||||
expect(find.text('Enable'), findsOneWidget);
|
||||
expect(gateway.calls.map((call) => call.type), [
|
||||
@@ -264,11 +281,12 @@ void main() {
|
||||
});
|
||||
await pumpScheduleSection(tester, gateway: gateway);
|
||||
|
||||
await tester.tap(find.byKey(scheduleRowToggleKey(8)));
|
||||
await _pick(tester, scheduleRowToggleKey(8), 8);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(scheduleRowErrorKey(8)), findsOneWidget);
|
||||
expect(find.text('conflict: revision 3 is stale'), findsOneWidget);
|
||||
await _openMenu(tester, 8);
|
||||
expect(find.text('Pause'), findsOneWidget);
|
||||
expect(gateway.callsOf('list_schedules'), hasLength(1));
|
||||
});
|
||||
@@ -291,7 +309,7 @@ void main() {
|
||||
});
|
||||
await pumpScheduleSection(tester, gateway: gateway);
|
||||
|
||||
await tester.tap(find.byKey(scheduleRowDeleteKey(8)));
|
||||
await _pick(tester, scheduleRowDeleteKey(8), 8);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Delete Research batteries?'), findsOneWidget);
|
||||
expect(
|
||||
@@ -304,7 +322,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.callsOf('delete_schedule'), isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(scheduleRowDeleteKey(8)));
|
||||
await _pick(tester, scheduleRowDeleteKey(8), 8);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(scheduleDeleteConfirmKey));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -333,7 +351,7 @@ void main() {
|
||||
});
|
||||
await pumpScheduleSection(tester, gateway: gateway);
|
||||
|
||||
await tester.tap(find.byKey(scheduleRowDeleteKey(8)));
|
||||
await _pick(tester, scheduleRowDeleteKey(8), 8);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(scheduleDeleteConfirmKey));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -392,10 +410,10 @@ void main() {
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.byKey(scheduleAddKey), findsOneWidget);
|
||||
await tester.ensureVisible(find.byKey(scheduleRowDeleteKey(8)));
|
||||
await tester.pumpAndSettle();
|
||||
await _openMenu(tester, 8);
|
||||
expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowDeleteKey(8)), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:pipelines_app/features/search/search_screen.dart';
|
||||
import 'package:pipelines_app/features/search/ui/search_bar_controls.dart';
|
||||
import 'package:pipelines_app/features/search/ui/search_bounds_note.dart';
|
||||
import 'package:pipelines_app/features/search/ui/search_layout.dart';
|
||||
import 'package:pipelines_app/features/search/ui/search_result_view.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
import 'search_screen_test.dart'
|
||||
@@ -95,7 +95,7 @@ void main() {
|
||||
expect(find.textContaining('Results truncated'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host: rows show a bold title, a kind tag and one line', (
|
||||
testWidgets('$host: rows are the shared row: title, kind-led line', (
|
||||
tester,
|
||||
) async {
|
||||
_size(tester, 390);
|
||||
@@ -110,8 +110,10 @@ void main() {
|
||||
|
||||
final row = find.byKey(const ValueKey('search.result.run:11:4:output'));
|
||||
expect(row, findsOneWidget);
|
||||
expect(tester.widget<AppListRow>(row).cupertino, cupertino);
|
||||
// The kind leads the one muted line, before the snippet.
|
||||
expect(
|
||||
find.descendant(of: row, matching: find.byType(SearchKindTag)),
|
||||
find.descendant(of: row, matching: find.textContaining('Field · ')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
import 'dart:ui' show Tristate;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_avatar.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_overflow_menu.dart';
|
||||
|
||||
const _longTitle = 'A row title long enough that it must ellipsise somewhere';
|
||||
const _longLine = 'a muted line of facts that is far too long for one line';
|
||||
|
||||
Widget _host(bool cupertino, Widget child, {Brightness? brightness}) {
|
||||
final body = ListView(children: [child]);
|
||||
return cupertino
|
||||
? CupertinoApp(
|
||||
theme: CupertinoThemeData(brightness: brightness),
|
||||
home: CupertinoPageScaffold(child: body),
|
||||
)
|
||||
: MaterialApp(
|
||||
theme: ThemeData(brightness: brightness ?? Brightness.light),
|
||||
home: Scaffold(body: body),
|
||||
);
|
||||
}
|
||||
|
||||
void _size(WidgetTester tester, double width, {double textScale = 1}) {
|
||||
tester.view.physicalSize = Size(width, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = textScale;
|
||||
addTearDown(tester.view.reset);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
}
|
||||
|
||||
AppListRow _row({
|
||||
String title = 'Fixture run',
|
||||
String? time = '9d ago',
|
||||
bool selected = false,
|
||||
bool emphasized = false,
|
||||
bool divider = true,
|
||||
VoidCallback? onTap,
|
||||
void Function(String)? onPicked,
|
||||
}) => AppListRow(
|
||||
key: const Key('row'),
|
||||
selected: selected,
|
||||
emphasized: emphasized,
|
||||
divider: divider,
|
||||
onTap: onTap ?? () {},
|
||||
leading: const AppListAvatar(
|
||||
key: Key('avatar'),
|
||||
child: Icon(Icons.play_arrow),
|
||||
),
|
||||
title: Text(title),
|
||||
time: time,
|
||||
subtitle: const Text('pipeline · 2 stages'),
|
||||
compactSubtitle: const Text('Running'),
|
||||
subtitleLeading: const AppListStatusDot(
|
||||
key: Key('dot'),
|
||||
color: Color(0xFF00AA00),
|
||||
semanticLabel: 'Running',
|
||||
),
|
||||
menu: AppOverflowMenu<String>(
|
||||
key: const Key('menu'),
|
||||
sheetTitle: title,
|
||||
actions: const [
|
||||
AppMenuAction(key: Key('menu-rename'), value: 'rename', label: 'Rename'),
|
||||
AppMenuAction(
|
||||
key: Key('menu-delete'),
|
||||
value: 'delete',
|
||||
label: 'Delete',
|
||||
destructive: true,
|
||||
),
|
||||
],
|
||||
onSelected: (_, value) => onPicked?.call(value),
|
||||
),
|
||||
);
|
||||
|
||||
TextStyle _paint(WidgetTester tester, String text) =>
|
||||
tester.renderObject<RenderParagraph>(find.textContaining(text)).text.style!;
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host: avatar, title with time, one line, menu, divider', (
|
||||
tester,
|
||||
) async {
|
||||
_size(tester, 560);
|
||||
var taps = 0;
|
||||
String? picked;
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
cupertino,
|
||||
_row(onTap: () => taps++, onPicked: (value) => picked = value),
|
||||
),
|
||||
);
|
||||
|
||||
final avatar = tester.getRect(find.byKey(const Key('avatar')));
|
||||
final title = tester.getRect(find.text('Fixture run'));
|
||||
final time = tester.getRect(find.text('9d ago'));
|
||||
final line = tester.getRect(find.text('pipeline · 2 stages'));
|
||||
final menu = tester.getRect(find.byKey(const Key('menu')));
|
||||
expect(avatar.size, const Size.square(kAppListAvatarSize));
|
||||
expect(avatar.right, lessThanOrEqualTo(title.left));
|
||||
expect(time.left, greaterThan(title.right - 1));
|
||||
expect(time.center.dy, closeTo(title.center.dy, 3));
|
||||
expect(line.top, greaterThanOrEqualTo(title.bottom - 1));
|
||||
expect(menu.left, greaterThanOrEqualTo(time.right));
|
||||
expect(find.byKey(const Key('dot')), findsOneWidget);
|
||||
// The title is bold, the line muted and smaller.
|
||||
expect(_paint(tester, 'Fixture run').fontWeight, FontWeight.w600);
|
||||
expect(
|
||||
_paint(tester, 'pipeline').fontSize!,
|
||||
lessThan(_paint(tester, 'Fixture run').fontSize!),
|
||||
);
|
||||
// The inset divider starts under the text column.
|
||||
final divider = tester.getRect(find.byKey(appListRowDividerKey));
|
||||
expect(divider.left, closeTo(title.left, 1));
|
||||
|
||||
await tester.tap(find.text('Fixture run'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(taps, 1);
|
||||
|
||||
// One overflow icon per host; the menu items keep their keys.
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('menu')),
|
||||
matching: find.byIcon(
|
||||
cupertino ? CupertinoIcons.ellipsis : Icons.more_vert,
|
||||
),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('menu')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(taps, 1, reason: 'the menu is its own control');
|
||||
if (cupertino) {
|
||||
expect(find.byType(CupertinoActionSheet), findsOneWidget);
|
||||
expect(find.text('Cancel'), findsOneWidget);
|
||||
} else {
|
||||
expect(find.byType(PopupMenuItem<String>), findsNWidgets(2));
|
||||
}
|
||||
await tester.tap(find.byKey(const Key('menu-delete')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(picked, 'delete');
|
||||
});
|
||||
|
||||
testWidgets('$host: selected and emphasised rows', (tester) async {
|
||||
_size(tester, 560);
|
||||
await tester.pumpWidget(
|
||||
_host(cupertino, _row(selected: true, emphasized: true)),
|
||||
);
|
||||
final row = find.byKey(const Key('row'));
|
||||
expect(
|
||||
tester.getSemantics(row).flagsCollection.isSelected,
|
||||
Tristate.isTrue,
|
||||
);
|
||||
final surface = find.descendant(
|
||||
of: row,
|
||||
matching: find.byKey(appListRowSurfaceKey),
|
||||
);
|
||||
final context = tester.element(row);
|
||||
expect(
|
||||
cupertino
|
||||
? tester.widget<ColoredBox>(surface).color
|
||||
: tester.widget<Material>(surface).color,
|
||||
AppListRow.selectedColor(context, cupertino: cupertino),
|
||||
);
|
||||
final accent = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
expect(_paint(tester, 'Fixture run').fontWeight, FontWeight.w700);
|
||||
expect(_paint(tester, '9d ago').color, accent);
|
||||
|
||||
await tester.pumpWidget(_host(cupertino, _row()));
|
||||
expect(
|
||||
cupertino
|
||||
? tester.widget<ColoredBox>(surface).color
|
||||
: tester.widget<Material>(surface).color,
|
||||
const Color(0x00000000),
|
||||
);
|
||||
expect(_paint(tester, '9d ago').color, isNot(accent));
|
||||
});
|
||||
|
||||
testWidgets('$host: a narrow pane drops the avatar, time and menu', (
|
||||
tester,
|
||||
) async {
|
||||
_size(tester, 240);
|
||||
await tester.pumpWidget(_host(cupertino, _row()));
|
||||
expect(find.byKey(const Key('avatar')), findsNothing);
|
||||
expect(find.text('9d ago'), findsNothing);
|
||||
expect(find.byKey(const Key('menu')), findsNothing);
|
||||
expect(find.text('Running'), findsOneWidget);
|
||||
expect(find.text('pipeline · 2 stages'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('$host: keepMenuWhenCompact keeps the menu', (tester) async {
|
||||
_size(tester, 240);
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
cupertino,
|
||||
AppListRow(
|
||||
keepMenuWhenCompact: true,
|
||||
title: const Text('Chat'),
|
||||
menu: AppOverflowMenu<int>(
|
||||
key: const Key('menu'),
|
||||
actions: const [AppMenuAction(value: 1, label: 'Star')],
|
||||
onSelected: (_, _) {},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.byKey(const Key('menu')), findsOneWidget);
|
||||
});
|
||||
|
||||
for (final brightness in Brightness.values) {
|
||||
testWidgets('$host ${brightness.name}: 320px at 2x text ellipsises '
|
||||
'without overflow', (tester) async {
|
||||
_size(tester, 320, textScale: 2);
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
cupertino,
|
||||
brightness: brightness,
|
||||
AppListRow(
|
||||
key: const Key('row'),
|
||||
onTap: () {},
|
||||
leading: const AppListAvatar(
|
||||
key: Key('avatar'),
|
||||
child: Text('P'),
|
||||
),
|
||||
title: const Text(_longTitle),
|
||||
time: '12 days ago',
|
||||
subtitle: const Text(_longLine),
|
||||
menu: AppOverflowMenu<int>(
|
||||
key: const Key('menu'),
|
||||
actions: const [AppMenuAction(value: 1, label: 'Star')],
|
||||
onSelected: (_, _) {},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
final title = tester.renderObject<RenderParagraph>(
|
||||
find.text(_longTitle),
|
||||
);
|
||||
expect(title.maxLines, 1);
|
||||
expect(title.didExceedMaxLines, isTrue);
|
||||
final line = tester.renderObject<RenderParagraph>(find.text(_longLine));
|
||||
expect(line.maxLines, 1);
|
||||
expect(line.didExceedMaxLines, isTrue);
|
||||
final row = tester.getRect(find.byKey(const Key('row')));
|
||||
expect(
|
||||
tester.getRect(find.text('12 days ago')).right,
|
||||
lessThanOrEqualTo(row.right),
|
||||
);
|
||||
// The avatar keeps its size; its glyph scales down inside it.
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('avatar'))),
|
||||
const Size.square(kAppListAvatarSize),
|
||||
);
|
||||
expect(find.byKey(const Key('menu')), findsOneWidget);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
testWidgets('the initial avatar reads the first letter, upper case', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Center(
|
||||
child: AppListAvatar.initial(' beta flow', color: Colors.teal),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.text('B'), findsOneWidget);
|
||||
expect(_paint(tester, 'B').fontSize, 18);
|
||||
expect(_paint(tester, 'B').fontWeight, FontWeight.w700);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user