Files
pipelines/app/test/application/templates_behind_bar_test.dart
T
alan 2889d59119 App: replace a silent socket instead of hanging; blink the terminal cursor on a timer; keep one markdown cache entry per streamed reply
A socket that outlived a sleep or network change looked open, so every
queued request waited its own 30 s timeout behind the last until the page
was reopened. The client now replaces a socket whose request times out
unheard (or after two timeouts in a row), and probes it with a ping after
a quiet spell or on returning to the foreground.

The terminal's blinking cursor ran a Ticker (a frame every vsync); a 530 ms
timer now flips it. Streamed deltas no longer flood the markdown cache and
evict finished answers.

Adds tool/perf/idle_session_bench.mjs (idle frames, long-session heap,
snapshot census) and notes/perf-hangs-idle.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 20:47:22 +00:00

66 lines
2.6 KiB
Dart

import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/templates_destination.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/templates/screen.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
import 'pipelines_replies.dart';
import 'templates_wiring_test.dart' show pumpApp, readTemplates;
/// The app-level Templates page: one bar (Back + Refresh), the gallery and an
/// open template reach the top edge, start below the bar at rest and scroll
/// behind it. The shared list rows sit on the page background.
void main() {
testWidgets('the gallery and detail scroll behind the bar', (tester) async {
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(
replaceSilentSocket: false,
channelFactory: (_) => channel,
);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
);
addTearDown(provider.dispose);
await pumpApp(tester, channel: channel, client: client, provider: provider);
await replyPipelines(tester, channel, PipelineFixture());
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/templates')),
);
await readTemplates(tester, channel);
await tester.pumpAndSettle();
final bar = find.ancestor(
of: find.byKey(templatesPageBackKey),
matching: find.byType(SegmentedBar),
);
final barBottom = tester.getRect(bar).bottom;
// One bar: Back and Refresh are its pieces.
expect(
find.descendant(of: bar, matching: find.byKey(templatesRefreshKey)),
findsOneWidget,
);
final gallery = find.byKey(templatesGalleryKey);
expect(tester.getTopLeft(gallery).dy, 0);
final row = find.byKey(templateRowKey('release'));
expect(tester.getTopLeft(row).dy, greaterThanOrEqualTo(barBottom - 8));
// Scrolling moves the row up behind the bar.
final before = tester.getTopLeft(row).dy;
await tester.drag(gallery, const Offset(0, -40));
await tester.pump();
expect(tester.getTopLeft(row).dy, lessThanOrEqualTo(before));
await tester.tap(row);
await tester.pumpAndSettle();
final detail = find.byKey(templateDetailKey);
expect(tester.getTopLeft(detail).dy, 0);
expect(
tester.getTopLeft(find.byKey(templateCreateActionKey)).dy,
greaterThanOrEqualTo(barBottom - 8),
);
});
}