Skip to content

Commit 9aa59b7

Browse files
committed
[red] Require board identity in connected card
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent bc3f87f commit 9aa59b7

2 files changed

Lines changed: 57 additions & 2 deletions

File tree

‎app/test/support/connect_harness.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ DeviceInfo connectedBoardInfo({
4444
String mpyVersion = '1.28.0',
4545
int freeMem = 48000,
4646
String fsRoot = '/',
47+
String deviceId = '5646',
48+
String agentVersion = '0.6.0',
4749
}) => DeviceInfo(
4850
chip: chip,
4951
mpyVersion: mpyVersion,
5052
freeMem: freeMem,
5153
fsRoot: fsRoot,
54+
deviceId: deviceId,
55+
agentVersion: agentVersion,
5256
);
5357

5458
/// The neutral fakes bound into one runtime [ConnectionManager], so a test can

‎app/test/widget/connect_screen_test.dart‎

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
// Renders (Signal design system, frozen contract ADR-0009 §3):
1111
// readiness banner (adapter-off/unauthorized/unsupported + localized rationale)
1212
// → scan CTA → live ScanHit list (name + RSSI) → connecting indicator →
13-
// connected Board-info card (chip / MicroPython / free-mem = the PROOF) →
14-
// disconnect; an error state; and a live diagnostics panel for HIL debugging.
13+
// connected Board-info card (board ID / PyBLE firmware / chip / MicroPython /
14+
// free-mem = the PROOF) → disconnect; an error state; and a live diagnostics
15+
// panel for HIL debugging.
1516
//
1617
// NEVER pumpAndSettle: a scanning/connecting progress indicator animates forever
1718
// and would time out; pump explicit frames after each scripted transition.
@@ -180,6 +181,23 @@ void main() {
180181

181182
final AppLocalizations l10n = _l10n(tester);
182183
expect(find.text(l10n.connectDeviceInfoTitle), findsOneWidget);
184+
expect(find.text(l10n.connectDeviceBoardId), findsOneWidget);
185+
expect(
186+
find.text('5646'),
187+
findsOneWidget,
188+
reason: 'the PBLE/1 board ID is rendered verbatim',
189+
);
190+
expect(
191+
find.text(_hitA.id),
192+
findsNothing,
193+
reason: 'the platform scan identifier is never exposed as Board ID',
194+
);
195+
expect(find.text(l10n.connectDeviceAgentVersion), findsOneWidget);
196+
expect(
197+
find.text('0.6.0'),
198+
findsOneWidget,
199+
reason: 'the PyBLE agent firmware version is rendered verbatim',
200+
);
183201
expect(
184202
find.text('esp32-s3'),
185203
findsOneWidget,
@@ -190,6 +208,39 @@ void main() {
190208
expect(find.byKey(_disconnectKey), findsOneWidget);
191209
});
192210

211+
testWidgets('missing identity metadata is reported without gating use', (
212+
WidgetTester tester,
213+
) async {
214+
final FakeConnection board = FakeConnection(
215+
initial: ConnState.connecting,
216+
deviceInfo: connectedBoardInfo(deviceId: '', agentVersion: ''),
217+
);
218+
final ConnectRig rig = ConnectRig(board: board);
219+
addTearDown(rig.dispose);
220+
await pumpConnect(tester, rig);
221+
222+
await tester.tap(find.byKey(_scanKey));
223+
await tester.pump();
224+
rig.scanner.emit(<ScanHit>[_hitA]);
225+
await tester.pump();
226+
await tester.tap(find.byKey(_hitKey(_hitA.id)));
227+
await tester.pump();
228+
229+
board.emit(ConnState.ready);
230+
await tester.pump();
231+
await tester.pump(const Duration(milliseconds: 20));
232+
233+
final AppLocalizations l10n = _l10n(tester);
234+
expect(find.text(l10n.connectDeviceBoardId), findsOneWidget);
235+
expect(find.text(l10n.connectDeviceAgentVersion), findsOneWidget);
236+
expect(find.text(l10n.connectDeviceNotReported), findsNWidgets(2));
237+
expect(
238+
find.byKey(_disconnectKey),
239+
findsOneWidget,
240+
reason: 'missing additive metadata must not gate the connection',
241+
);
242+
});
243+
193244
testWidgets('disconnect returns to the scan state', (
194245
WidgetTester tester,
195246
) async {

0 commit comments

Comments
 (0)