Files
meshcore-open/test/widgets/translated_message_content_test.dart
zjs81 25f197c979 Fix review findings, add default flood scope, and address recent issues
Review fixes:
- Keep stored message history beyond the 200-message window; stop
  messages leaking between radios; reset link/session state on disconnect
- Accept firmware's 176-byte RX frames over USB/TCP
- Hold APP_START during contact sync; contact-sync watchdog; replay DMs
  from not-yet-known senders; tombstone late command replies; finish
  channel sync on ERR_NOT_FOUND; fail region-scoped sends cleanly
- DM retry watchdog when RESP_CODE_SENT never arrives; late repeater CLI
  replies; ACK hash collisions; UTF-8-safe name truncation
- Image pipeline: delete-during-decode, lifecycle cancels, decoder memory
  release, entry cap, dead worker recovery, atomic model writes
- Storage: deterministic reaction hash across web/native, Smaz
  double-decode, per-entry parsing, per-radio path history and regions,
  review-mode data isolation
- UI: safe channel slot selection, byte-length name limits, double-send
  guard, mounted checks, localized hardcoded strings
- Skip persisted-store reload on repeat SELF_INFO

Features:
- Radio default flood scope (firmware ver 11+) and explicit unscoped
  sends (ver 12+)
- Scan for nearby nodes (#570)
- Optional distinct first-hop repeater counting for channel resend (#589)
- Optional region next to hop count (#580)

Issues:
- Message text follows system font size (#569)
- Repeater/room password field accepts 20 chars (#576)
- TCP auto-reconnect and keepalive (#571)
- Order feeds by local receive time; flag future timestamps (#584)
- Coding rate help text (#568), French "Favoris" (#575)
- iOS/macOS app badge now clears

Translations for all new strings in every locale.
2026-10-11 01:25:31 -07:00

56 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/widgets/translated_message_content.dart';
double _renderedScaleFactor(WidgetTester tester) {
final linkify = find.byType(Linkify);
if (linkify.evaluate().isNotEmpty) {
return tester.widget<Linkify>(linkify.first).textScaleFactor;
}
return tester
.widget<SelectableLinkify>(find.byType(SelectableLinkify).first)
.textScaleFactor;
}
Future<void> _pump(WidgetTester tester, TextScaler scaler) {
return tester.pumpWidget(
MaterialApp(
home: MediaQuery(
data: MediaQueryData(textScaler: scaler),
child: const Scaffold(
body: TranslatedMessageContent(
displayText: 'hello https://example.com',
originalText: 'bonjour',
style: TextStyle(fontSize: 16),
),
),
),
),
);
}
void main() {
testWidgets('message body follows the system text scale', (tester) async {
await _pump(tester, TextScaler.noScaling);
expect(_renderedScaleFactor(tester), 1.0);
await _pump(tester, const TextScaler.linear(2));
expect(_renderedScaleFactor(tester), 2.0);
});
testWidgets('original and translated text both scale', (tester) async {
await _pump(tester, const TextScaler.linear(1.5));
final factors = [
...tester
.widgetList<Linkify>(find.byType(Linkify))
.map((w) => w.textScaleFactor),
...tester
.widgetList<SelectableLinkify>(find.byType(SelectableLinkify))
.map((w) => w.textScaleFactor),
];
expect(factors, hasLength(2));
expect(factors, everyElement(1.5));
});
}