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.
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/search/domain/search_controller.dart';
|
||||
import 'package:pipelines_app/features/search/domain/search_query.dart';
|
||||
import 'search_test_support.dart';
|
||||
|
||||
void main() {
|
||||
test('a server error is shown, and retry issues a fresh request', () async {
|
||||
final gateway = QueuedGateway();
|
||||
final controller = controllerFor(gateway);
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
controller.updateQuery('plan');
|
||||
await pumpEventQueue();
|
||||
gateway.fail(0, StateError('server is down'));
|
||||
await pumpEventQueue();
|
||||
|
||||
expect(controller.bodyKind, SearchBodyKind.error);
|
||||
expect(controller.error, contains('server is down'));
|
||||
|
||||
final retry = controller.retry();
|
||||
await pumpEventQueue();
|
||||
expect(gateway.calls, hasLength(2));
|
||||
expect(gateway.lastSearch, {'query': 'plan', 'kind': '', 'limit': 0});
|
||||
|
||||
gateway.succeed(
|
||||
1,
|
||||
envelope([
|
||||
{
|
||||
'kind': 'pipeline',
|
||||
'target': 'pipeline:7',
|
||||
'pipeline': {'id': 7},
|
||||
},
|
||||
]),
|
||||
);
|
||||
await retry;
|
||||
expect(controller.error, isNull);
|
||||
expect(controller.results, hasLength(1));
|
||||
expect(controller.bodyKind, SearchBodyKind.results);
|
||||
});
|
||||
|
||||
test('a stale failure never replaces the newest query state', () async {
|
||||
final gateway = QueuedGateway();
|
||||
final controller = controllerFor(gateway);
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
controller.updateQuery('first');
|
||||
await pumpEventQueue();
|
||||
controller.updateQuery('second');
|
||||
await pumpEventQueue();
|
||||
|
||||
gateway.fail(0, StateError('stale failure'));
|
||||
await pumpEventQueue();
|
||||
|
||||
expect(controller.error, isNull);
|
||||
expect(controller.loading, isTrue);
|
||||
expect(controller.bodyKind, SearchBodyKind.searching);
|
||||
|
||||
gateway.succeed(
|
||||
1,
|
||||
envelope([
|
||||
{
|
||||
'kind': 'pipeline',
|
||||
'target': 'pipeline:9',
|
||||
'pipeline': {'id': 9},
|
||||
},
|
||||
]),
|
||||
);
|
||||
await pumpEventQueue();
|
||||
expect(controller.error, isNull);
|
||||
expect(controller.results.single['target'], 'pipeline:9');
|
||||
expect(controller.bodyKind, SearchBodyKind.results);
|
||||
});
|
||||
|
||||
test(
|
||||
'a missing search_results payload reports the unsupported copy',
|
||||
() async {
|
||||
final gateway = QueuedGateway();
|
||||
final controller = controllerFor(gateway);
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
controller.updateQuery('plan');
|
||||
await pumpEventQueue();
|
||||
gateway.succeed(0, {'type': 'pong'});
|
||||
await pumpEventQueue();
|
||||
|
||||
expect(controller.bodyKind, SearchBodyKind.error);
|
||||
expect(controller.error, unsupportedSearchCopy);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user