a44f31b989
Read-only Pipelines screen for the Flutter client: - list_pipelines and list_runs with a last-run join, plus get_pipeline with an explicit version (0 = latest); no mutation requests. - Name, run-presence, last-run-status and schedule filters; six sort orders; clear filters; truthful loading, empty and error states. - Detail Summary, selectable Source and version history with selection and return to latest. - Sequenced list/detail requests so stale replies cannot replace a newer selection or open a cleared one; refresh keeps the selected pipeline and version. - Material controls on Android/desktop and Cupertino on iOS; a per-label segmented tab row at narrow widths and scaled text, with the native control kept wherever an equal share fits. - Fixture probe entry and Chrome scripts for the rendered evidence; widget tests cover filters, sorting, formatting, sequencing, layout and the tab row. Graph rendering remains P2: the Graph tab states that it is pending and exposes a host hook. PipelinesScreen is not yet registered in the shell. Evidence and limits: app/notes/P1.md.
141 lines
4.6 KiB
Dart
141 lines
4.6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/core/api_gateway.dart';
|
|
import 'package:pipelines_app/features/pipelines/screen.dart';
|
|
|
|
import 'fixtures.dart';
|
|
import 'test_helpers.dart';
|
|
|
|
void main() {
|
|
testWidgets('list renders web wording, filters, opens detail and source', (
|
|
tester,
|
|
) async {
|
|
final fixture = PipelineFixture();
|
|
final gateway = gatewayFor(fixture);
|
|
await pumpWide(tester, gateway);
|
|
|
|
expect(find.text('Pipelines'), findsOneWidget);
|
|
expect(find.text('Alpha review'), findsOneWidget);
|
|
expect(find.text('id 1 · v2 · 2 stages'), findsOneWidget);
|
|
expect(find.text('updated 17 Oct 21:26'), findsOneWidget);
|
|
expect(find.text('1 schedule'), findsOneWidget);
|
|
expect(find.textContaining('run 42'), findsOneWidget);
|
|
expect(find.text('no runs recorded'), findsOneWidget);
|
|
expect(find.text('Select a pipeline.'), findsOneWidget);
|
|
|
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byKey(const Key('pipeline-detail')), findsOneWidget);
|
|
expect(find.text('hash-alpha'), findsOneWidget);
|
|
expect(find.text('id 1 · v2 · 2 stages'), findsNWidgets(2));
|
|
expect(gateway.callsOf('get_pipeline').single.fields, {
|
|
'pipeline_id': 1,
|
|
'version': 2,
|
|
});
|
|
|
|
await tester.tap(find.text('Source'));
|
|
await tester.pump();
|
|
expect(
|
|
selectableText('name: Alpha review\nstages:\n review:\n type: model'),
|
|
findsOneWidget,
|
|
);
|
|
});
|
|
|
|
testWidgets('version rows select an exact version and return to latest', (
|
|
tester,
|
|
) async {
|
|
final fixture = PipelineFixture();
|
|
final gateway = gatewayFor(fixture);
|
|
await pumpWide(tester, gateway);
|
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('v1'), findsOneWidget);
|
|
expect(find.text('v2'), findsNWidgets(2));
|
|
await tester.tap(find.byKey(const Key('pipeline-version-1')));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(gateway.callsOf('get_pipeline').last.fields, {
|
|
'pipeline_id': 1,
|
|
'version': 1,
|
|
});
|
|
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
|
|
|
|
await tester.tap(find.text('Source'));
|
|
await tester.pump();
|
|
expect(
|
|
selectableText(
|
|
'name: Alpha review\nstages:\n review:\n type: model\n'
|
|
'# selected version 1',
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
|
|
await tester.tap(find.text('Summary'));
|
|
await tester.pump();
|
|
await tester.tap(find.byKey(const Key('pipeline-latest-version')));
|
|
await tester.pumpAndSettle();
|
|
expect(gateway.callsOf('get_pipeline').last.fields, {
|
|
'pipeline_id': 1,
|
|
'version': 0,
|
|
});
|
|
expect(find.text('Viewing v1 (latest v2).'), findsNothing);
|
|
});
|
|
|
|
testWidgets('refresh keeps the selected row and its detail', (tester) async {
|
|
final fixture = PipelineFixture();
|
|
final gateway = gatewayFor(fixture);
|
|
await pumpWide(tester, gateway);
|
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byTooltip('Refresh'));
|
|
await tester.pumpAndSettle();
|
|
|
|
final row = tester.widget<ListTile>(
|
|
find.byKey(const Key('pipeline-row-1')),
|
|
);
|
|
expect(row.selected, isTrue);
|
|
expect(find.byKey(const Key('pipeline-detail')), findsOneWidget);
|
|
expect(gateway.callsOf('get_pipeline').length, greaterThanOrEqualTo(2));
|
|
});
|
|
|
|
testWidgets('initial loading is shown until both list reads settle', (
|
|
tester,
|
|
) async {
|
|
final fixture = PipelineFixture();
|
|
final list = Completer<JsonMap>();
|
|
final runs = Completer<JsonMap>();
|
|
final gateway = FakeGateway(
|
|
(type, fields) => switch (type) {
|
|
'list_pipelines' => list.future,
|
|
'list_runs' => runs.future,
|
|
_ => errorReply('unexpected $type'),
|
|
},
|
|
);
|
|
await tester.pumpWidget(
|
|
MaterialApp(home: PipelinesScreen(gateway: gateway)),
|
|
);
|
|
await tester.pump();
|
|
expect(find.text('Loading pipelines…'), findsOneWidget);
|
|
|
|
list.complete(pipelineListReply(fixture.summaries));
|
|
runs.complete(runListReply(fixture.runs));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Alpha review'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('graph tab states it is pending without a hook', (tester) async {
|
|
final fixture = PipelineFixture();
|
|
await pumpWide(tester, gatewayFor(fixture));
|
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Graph'));
|
|
await tester.pump();
|
|
expect(find.text('Graph rendering is pending (P2).'), findsOneWidget);
|
|
});
|
|
}
|