mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Add device identification guide dialog for unregistered devices
Adds a "How to identify this device" button next to Register Device that opens a dialog with personalized clues (vendor/type) and steps to track down the physical device on the network. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
3d7c4a1323
commit
f3d845ce37
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:frontend/devices/device_identification_guide.dart';
|
||||
import 'package:frontend/model/device.dart';
|
||||
|
||||
import '../helpers/fixtures.dart';
|
||||
import '../helpers/pump_app.dart';
|
||||
|
||||
void main() {
|
||||
Device device({String vendor = 'Acme Corp', String deviceType = 'laptop'}) =>
|
||||
Device.fromJson(deviceJson(vendor: vendor, deviceType: deviceType));
|
||||
|
||||
// Pumps a button that opens the dialog, then taps it so the dialog is shown.
|
||||
Future<void> openDialog(WidgetTester tester, Device d) async {
|
||||
await pumpScreen(
|
||||
tester,
|
||||
Builder(
|
||||
builder: (context) => ElevatedButton(
|
||||
onPressed: () => showDeviceIdentificationDialog(context, d),
|
||||
child: const Text('open'),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('open'));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets('shows every guidance step', (tester) async {
|
||||
await openDialog(tester, device());
|
||||
|
||||
expect(find.text('Identify this device'), findsOneWidget);
|
||||
expect(find.text('Check the manufacturer'), findsOneWidget);
|
||||
expect(find.text('Try the unplug test'), findsOneWidget);
|
||||
expect(find.text('Check your router'), findsOneWidget);
|
||||
expect(find.text('Scan its open ports (advanced)'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('weaves the vendor and type into the intro', (tester) async {
|
||||
await openDialog(
|
||||
tester,
|
||||
device(vendor: 'Acme Corp', deviceType: 'printer'),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.textContaining('Printer'),
|
||||
findsWidgets,
|
||||
reason: 'the inferred device type should appear in the intro',
|
||||
);
|
||||
expect(find.textContaining('Acme Corp'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('closes when Close is tapped', (tester) async {
|
||||
await openDialog(tester, device());
|
||||
|
||||
await tester.tap(find.text('Close'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Identify this device'), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user