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.
96 lines
3.2 KiB
Dart
96 lines
3.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/pipelines/pipeline_format.dart';
|
|
import 'package:pipelines_app/features/pipelines/pipeline_models.dart';
|
|
import 'package:pipelines_app/features/pipelines/pipeline_query.dart';
|
|
|
|
import 'fixtures.dart';
|
|
|
|
void main() {
|
|
group('formatting', () {
|
|
test('renders local timestamps, durations and ages', () {
|
|
expect(formatLocalTimestamp('2026-10-17T21:26:00'), '17 Oct 21:26');
|
|
expect(formatLocalTimestamp(''), isNull);
|
|
expect(formatLocalTimestamp('not a time'), isNull);
|
|
expect(formatDuration(0), '0s');
|
|
expect(formatDuration(45), '45s');
|
|
expect(formatDuration(125), '2m 5s');
|
|
expect(formatDuration(3720), '1h 2m');
|
|
expect(formatDuration(-4), '0s');
|
|
expect(stageCountText(1), '1 stage');
|
|
expect(stageCountText(2), '2 stages');
|
|
final now = DateTime(2026, 10, 17, 21, 30);
|
|
expect(formatRanAgo('2026-10-17T21:29:40', now), 'just now');
|
|
expect(formatRanAgo('2026-10-17T21:25:00', now), '5m ago');
|
|
expect(formatRanAgo('2026-10-17T19:30:00', now), '2h ago');
|
|
expect(formatRanAgo('2026-10-14T21:30:00', now), '3d ago');
|
|
expect(formatRanAgo('2026-10-17T22:00:00', now), 'just now');
|
|
});
|
|
|
|
test('maps the server status vocabulary and unknown values', () {
|
|
expect(runStateOf('success'), 'succeeded');
|
|
expect(runStateOf('CANCELLED'), 'canceled');
|
|
expect(runStateOf('error'), 'failed');
|
|
expect(runStateOf('mystery'), 'unknown');
|
|
expect(runStateOf(null), 'unknown');
|
|
expect(runStateLabel('running'), 'Running');
|
|
});
|
|
});
|
|
|
|
group('pipeline detail', () {
|
|
test('parses the get_pipeline detail and resolves latest', () {
|
|
final detail = PipelineDetail.fromJson(
|
|
pipelineDetail(
|
|
id: 7,
|
|
name: 'Seven',
|
|
version: 0,
|
|
latestVersion: 3,
|
|
source: 'name: seven',
|
|
versions: [versionSummary(1), versionSummary(2), versionSummary(3)],
|
|
),
|
|
);
|
|
expect(detail.id, 7);
|
|
expect(detail.latestVersion, 3);
|
|
expect(detail.resolvedVersion, 3);
|
|
expect(detail.source, 'name: seven');
|
|
expect(detail.versions.map((version) => version.version), [1, 2, 3]);
|
|
expect(pipelineSubtitle(detail), 'id 7 · v0 · 1 stage');
|
|
expect(pipelineSummaryFields(detail).first.key, 'Content hash');
|
|
expect(
|
|
pipelineSummaryFields(
|
|
detail,
|
|
).firstWhere((field) => field.key == 'Latest version').value,
|
|
'v3',
|
|
);
|
|
});
|
|
|
|
test(
|
|
'schedule state distinguishes configured, absent and unknown peers',
|
|
() {
|
|
expect(
|
|
PipelineSummary.fromJson(
|
|
pipelineSummary(id: 1, name: 'a', scheduleCount: 2),
|
|
).scheduleState,
|
|
PipelineScheduleState.scheduled,
|
|
);
|
|
expect(
|
|
PipelineSummary.fromJson(
|
|
pipelineSummary(
|
|
id: 1,
|
|
name: 'a',
|
|
scheduleCount: null,
|
|
scheduled: null,
|
|
),
|
|
).scheduleState,
|
|
PipelineScheduleState.unclassified,
|
|
);
|
|
expect(
|
|
PipelineSummary.fromJson(
|
|
pipelineSummary(id: 1, name: 'a'),
|
|
).scheduleLabel,
|
|
'',
|
|
);
|
|
},
|
|
);
|
|
});
|
|
}
|