Files
pipelines/app/test/features/pipelines/pipeline_scope_control_test.dart
T

66 lines
2.0 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_scope_control.dart';
void main() {
for (final cupertino in [false, true]) {
for (final width in [120.0, 500.0]) {
testWidgets(
'native scope remains usable at $width, Cupertino=$cupertino',
(tester) async {
var scheduled = false;
final control = StatefulBuilder(
builder: (context, setState) => Center(
child: SizedBox(
width: width,
child: PipelineScopeControl(
scheduled: scheduled,
onSelected: (value) => setState(() => scheduled = value),
),
),
),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: control))
: MaterialApp(home: Scaffold(body: control)),
);
await tester.pumpAndSettle();
if (width == 120) {
await tester.tap(find.byKey(const Key('pipeline-scope')));
await tester.pumpAndSettle();
await tester.tap(find.text('Scheduled').last);
} else {
await tester.tap(find.text('Scheduled'));
}
await tester.pumpAndSettle();
expect(scheduled, isTrue);
expect(tester.takeException(), isNull);
},
);
}
}
testWidgets('wide scope control hugs its labels', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SizedBox(
width: 500,
child: Align(
alignment: AlignmentDirectional.centerStart,
child: PipelineScopeControl(scheduled: false, onSelected: (_) {}),
),
),
),
),
);
expect(
tester.getSize(find.byKey(const Key('pipeline-scope'))).width,
lessThan(500),
);
});
}