fe24f228fe
Review r2 findings P2-4, P2-5, P3-13: a shared relative-time helper for
every list row's time, formatDuration switches to days past 24h ('9d
16h'), the stage page uses one visit numbering, drops a repeated stage
heading and fixes '1 files', and search run hits read 'Run 1'.
Implemented by pipeline run #205/#207 (Terra); its UIReview blocked on a
fixture without timestamps, verified by the manager.
91 lines
2.9 KiB
Dart
91 lines
2.9 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 and bounded durations', () {
|
|
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(840000), '9d 17h');
|
|
expect(formatDuration(-4), '0s');
|
|
expect(stageCountText(1), '1 stage');
|
|
expect(stageCountText(2), '2 stages');
|
|
});
|
|
|
|
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,
|
|
'',
|
|
);
|
|
},
|
|
);
|
|
});
|
|
}
|