Files
meshcore-open/test/helpers/chat_jump_test.dart
T
zjs81 5ea44d6ce9 Tester feedback: routing, bulk select, notifications, map crash
Routing
- Auto routing picks routes by Thompson sampling over faded delivery
  stats (24 h half-life, capped evidence), weighted by what the radio
  currently hears; retries prefer a different route; last attempt floods.
- Route failures are held until a message's fate is known, so an offline
  contact no longer wrecks its route history; failing routes are only
  deleted after a week without a delivery.
- Direct (zero-hop) path is a rotation candidate (#643) and a new Direct
  mode in the routing sheet; history routes are used for repeater logins.
- Remove the route-weight sliders the new chooser no longer uses.

Chats
- Bulk selection in channel chats (spam / not spam / delete / copy) and
  in the Filtered messages list.
- Tapping a search result jumps to the message.
- Swipe-to-reply ignores vertical scrolls.
- Active conversation follows route lifecycle, so covered chats count
  unread again.

Notifications
- Tapping a notification opens its conversation.
- Per-conversation coalescing and one alert per queued-message sync.
- Monochrome status-bar icon; background service stops when the app is
  swiped away; stale notifications cleared on radio or slot change.

Other
- Online map: opaque links and painted dots for dense areas to avoid an
  Impeller GPU crash; expandable hop list on path maps.
- Contact share: clipboard import of shared contacts, "Add again".
- Android: enableEdgeToEdge and scrolling-screenshot support.
- Translations for all new strings; fix mistranslated routing labels.
2026-11-08 23:19:15 -07:00

106 lines
3.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/helpers/chat_jump.dart';
/// A reversed chat-style list with uneven row heights, so the list's extent
/// estimate is wrong and the helper has to walk to the target.
Widget _list(ScrollController controller, int count) {
return MaterialApp(
home: Scaffold(
body: ListView.builder(
reverse: true,
controller: controller,
itemCount: count,
itemBuilder: (context, index) => SizedBox(
key: ValueKey('row$index'),
height: 40.0 + (index % 7) * 30,
child: Text('row $index'),
),
),
),
);
}
void main() {
for (final target in [0, 7, 250, 499]) {
testWidgets('brings row $target of 500 on screen', (tester) async {
final controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(_list(controller, 500));
late bool found;
final done = scrollListToIndex(
controller: controller,
targetIndex: target,
itemCount: 500,
isMounted: () => true,
).then((value) => found = value);
// Drive frames until the helper finishes.
for (var i = 0; i < 200; i++) {
await tester.pump(const Duration(milliseconds: 50));
}
await done;
expect(found, isTrue);
final row = find.byKey(ValueKey('row$target'));
expect(row, findsOneWidget);
final rect = tester.getRect(row);
final screen = tester.getRect(find.byType(ListView));
expect(screen.overlaps(rect), isTrue);
});
}
// Codex's case: older rows much taller than recent ones, so the first
// estimate lands hundreds of rows short.
testWidgets('reaches a row far past rows of a very different height', (
tester,
) async {
final controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: ListView.builder(
reverse: true,
controller: controller,
itemCount: 2000,
itemBuilder: (_, i) => SizedBox(
key: ValueKey('row$i'),
height: i < 1000 ? 60 : 300,
child: Text('row $i'),
),
),
),
),
);
bool? found;
final done = scrollListToIndex(
controller: controller,
targetIndex: 1500,
itemCount: 2000,
isMounted: () => true,
).then((v) => found = v);
for (var i = 0; i < 300; i++) {
await tester.pump(const Duration(milliseconds: 50));
}
await done;
expect(found, isTrue);
expect(find.byKey(const ValueKey('row1500')), findsOneWidget);
});
testWidgets('rejects an index outside the list', (tester) async {
final controller = ScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(_list(controller, 10));
expect(
await scrollListToIndex(
controller: controller,
targetIndex: 10,
itemCount: 10,
isMounted: () => true,
),
isFalse,
);
});
}