epic(#938): Blocked pane says "no radio" instead of "no blocked users"
Epic C of Feature #853, carrying #507. Much smaller than the plan assumed, because `BlockedView` already existed and was already wired into Settings. What it did not have was the distinction #507 asked for, or any tests. **The gap.** With no radio connected the pane rendered "No blocked users", which is indistinguishable from a connected radio with an empty list. Since #471 made blocks per radio, that wording invited exactly the wrong conclusion: that the blocks had been lost. Now a disconnected pane says "No radio connected" and explains why ("Blocks belong to the radio that holds them"), because the reason is what stops it reading as data loss. English-only string additions per the repo convention; `untranslated.json` tracks the other 17 locales. **Tests: 5, and the first one has teeth.** I proved it by disabling the new branch and watching it fail: Expected: exactly one matching candidate Actual: Found 0 widgets with text "No radio connected" Then reverted. A test nobody has watched fail is not evidence, and this session has already produced three harnesses that reported success while measuring nothing. Covered, all through the widget rather than the service: - no radio says so, and gives the reason - a connected radio with nothing blocked says THAT - a block made on radio A is absent on radio B - switching back restores A's list, because isolation is not deletion - an unblock survives a switch and back, which is #507's clear-sticks case and the re-clear that #471 was about #507 also lists "migration drops the global keys". That already exists: `BlockService.loadForDevice` calls `_store.dropLegacyGlobal()` on every device load. Noted rather than re-implemented. Suite 1,419 pass, analyze clean, format clean. Still outstanding for this Epic: the T1000e hardware check #507 asks for, which is an owner step and the only part I cannot do. Citadel: meshcore-open-uu9, meshcore-open-9ft Refs #938, #507, #471, #853 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>pull/948/head
parent
c4e28b653d
commit
4d9f1546e2
@ -0,0 +1,149 @@
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/connector/meshcore_connector.dart';
|
||||
import 'package:meshcore_open/l10n/app_localizations.dart';
|
||||
import 'package:meshcore_open/screens/settings/blocked_view.dart';
|
||||
import 'package:meshcore_open/services/block_service.dart';
|
||||
import 'package:meshcore_open/storage/drift/blob_store.dart';
|
||||
import 'package:meshcore_open/storage/drift/offband_database.dart';
|
||||
import 'package:meshcore_open/storage/prefs_manager.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// #938 (#507): the Blocked pane is per radio, and says so.
|
||||
///
|
||||
/// The gap this closes: with no radio connected the pane rendered "No blocked
|
||||
/// users", which is indistinguishable from a connected radio with an empty
|
||||
/// list. Since #471 made blocks per radio, that wording invited the reader to
|
||||
/// conclude their blocks had been lost.
|
||||
void main() {
|
||||
late OffbandDatabase db;
|
||||
|
||||
setUp(() async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
PrefsManager.reset();
|
||||
await PrefsManager.initialize();
|
||||
db = OffbandDatabase(NativeDatabase.memory());
|
||||
BlobStore.overrideForTest(BlobStore(db));
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await db.close();
|
||||
BlobStore.clearTestOverride();
|
||||
});
|
||||
|
||||
Widget harness(BlockService block) => MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<BlockService>.value(value: block),
|
||||
ChangeNotifierProvider<MeshCoreConnector>(
|
||||
create: (_) => MeshCoreConnector(),
|
||||
),
|
||||
],
|
||||
child: const MaterialApp(
|
||||
localizationsDelegates: [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
],
|
||||
home: Scaffold(body: BlockedView()),
|
||||
),
|
||||
);
|
||||
|
||||
group('the two empty states read differently', () {
|
||||
testWidgets('no radio connected says so, and explains why', (t) async {
|
||||
final block = BlockService();
|
||||
await block.loadForDevice(null);
|
||||
|
||||
await t.pumpWidget(harness(block));
|
||||
await t.pumpAndSettle();
|
||||
|
||||
expect(find.text('No radio connected'), findsOneWidget);
|
||||
expect(
|
||||
find.textContaining('Blocks belong to the radio that holds them'),
|
||||
findsOneWidget,
|
||||
reason: 'the reason matters: without it the pane looks like data loss',
|
||||
);
|
||||
expect(
|
||||
find.text('No blocked users'),
|
||||
findsNothing,
|
||||
reason: 'this was the bug: both states said the same thing',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('a connected radio with nothing blocked says THAT', (t) async {
|
||||
final block = BlockService();
|
||||
await block.loadForDevice('aa' * 16);
|
||||
|
||||
await t.pumpWidget(harness(block));
|
||||
await t.pumpAndSettle();
|
||||
|
||||
expect(find.text('No blocked users'), findsOneWidget);
|
||||
expect(find.text('No radio connected'), findsNothing);
|
||||
});
|
||||
});
|
||||
|
||||
group('per-radio isolation through the pane', () {
|
||||
testWidgets('a block made on radio A is absent on radio B', (t) async {
|
||||
final block = BlockService();
|
||||
await block.loadForDevice('aa' * 16);
|
||||
await block.block('deadbeef');
|
||||
|
||||
await t.pumpWidget(harness(block));
|
||||
await t.pumpAndSettle();
|
||||
expect(find.textContaining('deadbeef'), findsOneWidget);
|
||||
|
||||
// Switch radios, as the connector does on SELF_INFO.
|
||||
await block.loadForDevice('bb' * 16);
|
||||
await t.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
find.textContaining('deadbeef'),
|
||||
findsNothing,
|
||||
reason: 'radio A\'s block must not appear while radio B is connected',
|
||||
);
|
||||
expect(find.text('No blocked users'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('switching back restores radio A\'s list', (t) async {
|
||||
final block = BlockService();
|
||||
await block.loadForDevice('aa' * 16);
|
||||
await block.block('deadbeef');
|
||||
await block.loadForDevice('bb' * 16);
|
||||
await block.loadForDevice('aa' * 16);
|
||||
|
||||
await t.pumpWidget(harness(block));
|
||||
await t.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
find.textContaining('deadbeef'),
|
||||
findsOneWidget,
|
||||
reason: 'isolation is not deletion: A keeps its own list',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('unblock sticks', () {
|
||||
testWidgets('an unblock survives a radio switch and back', (t) async {
|
||||
final block = BlockService();
|
||||
await block.loadForDevice('aa' * 16);
|
||||
await block.block('deadbeef');
|
||||
await block.unblock('deadbeef');
|
||||
|
||||
await block.loadForDevice('bb' * 16);
|
||||
await block.loadForDevice('aa' * 16);
|
||||
|
||||
await t.pumpWidget(harness(block));
|
||||
await t.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
find.textContaining('deadbeef'),
|
||||
findsNothing,
|
||||
reason:
|
||||
'the clear-sticks case from #507: the re-clear that kept '
|
||||
'recurring was #471, and it must not come back',
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Reference in new issue