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>? 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': []}, _ => errorReply('unexpected $type'), }, ); Future 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, ); /// Picks a scope from the segments, or from the menu a pane too narrow for /// the segments shows instead. Future pickScope(WidgetTester tester, String label) async { final segment = find.descendant( of: find.byKey(const Key('pipeline-scope')), matching: find.text(label), ); if (segment.evaluate().isEmpty) { await tester.tap(find.byKey(const Key('pipeline-scope'))); await tester.pumpAndSettle(); await tester.tap(find.text(label).last); } else { await tester.tap(segment); } await tester.pumpAndSettle(); }