feat(app): label pipeline rows from recorded version and stages
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pipeline_models.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pipeline_query.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
import 'test_helpers.dart';
|
||||
|
||||
/// The list row's recorded metadata only: version, stage count (including the
|
||||
/// recorded flow's fallback), updated time and name. Nothing may be filled in
|
||||
/// for a field the reply did not record.
|
||||
void main() {
|
||||
group('pipeline row metadata', () {
|
||||
test('version, stage count and name come from the reply', () {
|
||||
final pipeline = PipelineSummary.fromJson(
|
||||
pipelineSummary(id: 7, name: 'Seven', version: 3, stages: 2),
|
||||
);
|
||||
|
||||
expect(pipelineVersionLabel(pipeline), 'v3');
|
||||
expect(pipelineStageSummary(pipeline), '2 stages');
|
||||
expect(pipelineSubtitle(pipeline), 'id 7 · v3 · 2 stages');
|
||||
expect(pipeline.displayName, 'Seven');
|
||||
});
|
||||
|
||||
test('one recorded stage keeps the web singular label', () {
|
||||
final pipeline = PipelineSummary.fromJson(
|
||||
pipelineSummary(id: 1, name: 'Solo', version: 1, stages: 1),
|
||||
);
|
||||
|
||||
expect(pipelineStageSummary(pipeline), '1 stage');
|
||||
});
|
||||
|
||||
test('a recorded flow supplies the count when stages is absent', () {
|
||||
final json = pipelineSummary(id: 8, name: 'Flow')..remove('stages');
|
||||
json['shape'] = reviewGraph();
|
||||
|
||||
final pipeline = PipelineSummary.fromJson(json);
|
||||
|
||||
expect(pipeline.stages, 0);
|
||||
expect(pipeline.rowStageCount, 2);
|
||||
expect(pipelineStageSummary(pipeline), '2 stages');
|
||||
expect(pipelineSubtitle(pipeline), 'id 8 · v1 · 2 stages');
|
||||
});
|
||||
|
||||
test('a recorded stage count wins over the recorded flow', () {
|
||||
final json = pipelineSummary(id: 9, name: 'Pinned', stages: 1)
|
||||
..['shape'] = reviewGraph();
|
||||
|
||||
final pipeline = PipelineSummary.fromJson(json);
|
||||
|
||||
expect(pipelineStageSummary(pipeline), '1 stage');
|
||||
});
|
||||
|
||||
test('neither recorded reads the web zero-stage fallback', () {
|
||||
final json = pipelineSummary(id: 10, name: 'Bare')..remove('stages');
|
||||
final malformed = pipelineSummary(id: 11, name: 'Odd')
|
||||
..remove('stages')
|
||||
..['shape'] = {'stages': 'not a list'};
|
||||
|
||||
expect(pipelineStageSummary(PipelineSummary.fromJson(json)), '0 stages');
|
||||
expect(
|
||||
pipelineStageSummary(PipelineSummary.fromJson(malformed)),
|
||||
'0 stages',
|
||||
);
|
||||
});
|
||||
|
||||
test('the updated line is exact and omitted when unrecorded', () {
|
||||
final recorded = PipelineSummary.fromJson(
|
||||
pipelineSummary(id: 11, name: 'Timed'),
|
||||
);
|
||||
final absent = PipelineSummary.fromJson(
|
||||
pipelineSummary(id: 12, name: 'Untimed', updatedAt: ''),
|
||||
);
|
||||
final unparseable = PipelineSummary.fromJson(
|
||||
pipelineSummary(id: 13, name: 'Bad time', updatedAt: 'not a time'),
|
||||
);
|
||||
|
||||
expect(pipelineUpdatedLine(recorded), 'updated 17 Oct 21:26');
|
||||
expect(pipelineUpdatedLine(absent), isNull);
|
||||
expect(pipelineUpdatedLine(unparseable), isNull);
|
||||
});
|
||||
|
||||
test('a blank name reads the web fallback, never an empty title', () {
|
||||
final pipeline = PipelineSummary.fromJson(
|
||||
pipelineSummary(id: 14, name: '', version: 2, stages: 3),
|
||||
);
|
||||
|
||||
expect(pipeline.displayName, 'pipeline 14');
|
||||
});
|
||||
|
||||
testWidgets('the row shows recorded metadata and hides absent values', (
|
||||
tester,
|
||||
) async {
|
||||
final fixture = PipelineFixture();
|
||||
final shapeOnly = pipelineSummary(id: 8, name: '', version: 1)
|
||||
..remove('stages')
|
||||
..['shape'] = reviewGraph()
|
||||
..['updated_at'] = '';
|
||||
final zeroStages = pipelineSummary(
|
||||
id: 9,
|
||||
name: 'Zero',
|
||||
version: 4,
|
||||
stages: 0,
|
||||
updatedAt: 'not a time',
|
||||
)..['shape'] = reviewGraph();
|
||||
final gateway = gatewayFor(
|
||||
fixture,
|
||||
summaries: [
|
||||
pipelineSummary(id: 7, name: 'Seven', version: 3, stages: 2),
|
||||
shapeOnly,
|
||||
zeroStages,
|
||||
],
|
||||
);
|
||||
|
||||
await pumpWide(tester, gateway);
|
||||
|
||||
expect(find.text('Seven'), findsOneWidget);
|
||||
expect(find.text('id 7 · v3 · 2 stages'), findsOneWidget);
|
||||
expect(find.text('updated 17 Oct 21:26'), findsOneWidget);
|
||||
|
||||
expect(find.text('pipeline 8'), findsOneWidget);
|
||||
expect(find.text('id 8 · v1 · 2 stages'), findsOneWidget);
|
||||
|
||||
expect(find.text('id 9 · v4 · 0 stages'), findsOneWidget);
|
||||
expect(find.textContaining('updated '), findsOneWidget);
|
||||
expect(find.text('no runs recorded'), findsNWidgets(3));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user