47 lines
1.5 KiB
Dart
47 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/pipelines/screen.dart';
|
|
|
|
import 'fixtures.dart';
|
|
|
|
FakeGateway gatewayFor(
|
|
PipelineFixture fixture, {
|
|
bool listFails = false,
|
|
bool runsFail = false,
|
|
bool detailFails = false,
|
|
List<Map<String, dynamic>>? summaries,
|
|
}) => FakeGateway(
|
|
(type, fields) => switch (type) {
|
|
'list_pipelines' =>
|
|
listFails
|
|
? errorReply('server offline')
|
|
: pipelineListReply(summaries ?? fixture.summaries),
|
|
'list_runs' =>
|
|
runsFail ? errorReply('runs down') : runListReply(fixture.runs),
|
|
'get_pipeline' =>
|
|
detailFails
|
|
? errorReply('pipeline ${fields['pipeline_id']} was not found')
|
|
: pipelineDetailReply(
|
|
fixture.detailFor(
|
|
fields['pipeline_id'] as int,
|
|
fields['version'] as int,
|
|
)!,
|
|
),
|
|
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
|
|
_ => errorReply('unexpected $type'),
|
|
},
|
|
);
|
|
|
|
Future<void> pumpWide(WidgetTester tester, FakeGateway gateway) async {
|
|
tester.view.physicalSize = const Size(1100, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
await tester.pumpWidget(MaterialApp(home: PipelinesScreen(gateway: gateway)));
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
Finder selectableText(String text) => find.byWidgetPredicate(
|
|
(widget) => widget is SelectableText && widget.data == text,
|
|
);
|