Files
pipelines/app/test/features/search/search_test_support.dart
T
alan 51140cd3b7 feat(app): add native omni-search screen over the search gateway
Pure request/parse/row logic in lib/features/search/domain, a
gateway-backed repository, and Material plus Cupertino bodies.
The header and rows share one scroll view, and the server's
truncation, scan and cap facts stay visible even when a bounded
scan returns no matches.

Tests cover the exact search envelope, token parsing, stale replies,
retry, truncation bounds and platform layouts. A Web-only fixture
and CDP probe support rendered verification; the screen is not yet
registered in the shell.
2026-10-21 16:41:30 +01:00

51 lines
1.4 KiB
Dart

import 'dart:async';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/search/data/search_repository.dart';
import 'package:pipelines_app/features/search/domain/search_controller.dart';
class QueuedGateway implements ApiGateway {
final calls = <JsonMap>[];
final pending = <Completer<JsonMap>>[];
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
calls.add(Map.of(fields));
final completer = Completer<JsonMap>();
pending.add(completer);
return completer.future;
}
@override
Stream<JsonMap> get frames => const Stream.empty();
void succeed(int index, JsonMap reply) => pending[index].complete(reply);
void fail(int index, Object error) => pending[index].completeError(error);
JsonMap get lastSearch =>
Map<String, dynamic>.from((calls.last['search'] as Map));
}
JsonMap envelope(
List<JsonMap> results, {
bool truncated = false,
int scannedSteps = 0,
int scannedBytes = 0,
int cap = 50,
int scanBoundBytes = 1 << 20,
}) => {
'search_results': {
'results': results,
'truncated': truncated,
'scanned_steps': scannedSteps,
'scanned_bytes': scannedBytes,
'cap': cap,
'scan_bound_bytes': scanBoundBytes,
},
};
OmniSearchController controllerFor(ApiGateway gateway) => OmniSearchController(
repository: SearchRepository(gateway),
debounce: Duration.zero,
);