fix(app): guard foreground refresh during interaction
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
@@ -153,6 +153,74 @@ void main() {
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('foreground resume preserves an open dialog and skips refresh', (
|
||||
tester,
|
||||
) async {
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
await pumpApp(tester, provider: provider, client: client);
|
||||
await waitForRequest(tester, channel, 'list_runs');
|
||||
final initialRuns = pipelineRequest(channel, 'list_runs')!;
|
||||
channel.incoming.add(jsonEncode({
|
||||
'id': initialRuns['id'],
|
||||
'type': 'runs',
|
||||
'runs': PipelineFixture().runs,
|
||||
}));
|
||||
await tester.pump();
|
||||
final before = countType(channel, 'list_runs');
|
||||
showDialog<void>(
|
||||
context: tester.element(find.byType(Scaffold).first),
|
||||
builder: (_) => const AlertDialog(content: Text('Still open')),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await resume(tester);
|
||||
|
||||
expect(countType(channel, 'list_runs'), before);
|
||||
expect(find.text('Still open'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('foreground resume skips refresh while a text field has focus', (
|
||||
tester,
|
||||
) async {
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
await pumpApp(tester, provider: provider, client: client);
|
||||
await waitForRequest(tester, channel, 'list_runs');
|
||||
final initialRuns = pipelineRequest(channel, 'list_runs')!;
|
||||
channel.incoming.add(jsonEncode({
|
||||
'id': initialRuns['id'],
|
||||
'type': 'runs',
|
||||
'runs': PipelineFixture().runs,
|
||||
}));
|
||||
await tester.pump();
|
||||
final before = countType(channel, 'list_runs');
|
||||
showDialog<void>(
|
||||
context: tester.element(find.byType(Scaffold).first),
|
||||
builder: (_) => const AlertDialog(content: TextField()),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.tap(find.byType(TextField).last);
|
||||
await tester.pump();
|
||||
|
||||
await resume(tester);
|
||||
|
||||
expect(countType(channel, 'list_runs'), before);
|
||||
expect(FocusManager.instance.primaryFocus?.hasFocus, isTrue);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('foreground resume does not refresh an open run detail', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user