Files
app-flutter/test/checklist_test.dart
T
mikkeli 4cf7a786d6
/ crosscheck (push) Successful in 1s
CI / Analyze & Test (push) Successful in 13s
CI / Debug APK (push) Successful in 27s
App structure: a swipe-in menu shell; pages/, link/, actions/; Settings
The shell (shell.dart): a drawer from the left edge or each page's menu button.
Dash, Signals, Captures; Tools (Camera, Link test, Orin power options), the
rarely used ones, after pirate-station-aide; Settings (gateway address, dark/bright,
build-time theme and landing). Landing view at build time: YUKART_HOME=dash|signals,
signals for now. Dash, Signals and Captures stay alive while hidden; Captures has its
own navigator, so a run survives switching views. Back goes inside Captures, then to
the landing view, then out. The mock banner sits over every page.

main.dart is startup only; the old home screen is pages/signals.dart; dialogs and
sheets moved to actions/; the protocol client, USB binding and Reading to link/.
lib/README.md catalogues it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDwfd6Ki8UfG4hK6W5YpJz
2026-10-14 14:08:56 +09:00

80 lines
2.3 KiB
Dart

import 'dart:convert';
import 'dart:io';
import 'package:display/pages/checklist.dart';
import 'package:flutter_test/flutter_test.dart';
Checklist sample() => Checklist.fromJson({
'id': 'demo',
'version': 2,
'title': 'Demo',
'sections': [
{
'title': 'A',
'steps': [
{
'id': '1',
'title': 'Brake',
'actions': [
{'label': 'brake', 'repeat': 2},
{'label': 'flash', 'point': true},
],
},
{
'id': '2',
'title': 'Gears',
'actions': [
{'label': 'gear 1'},
],
},
],
},
],
});
void main() {
test('one button: announce once, start/end spans, repeats numbered, points single', () {
final r = ChecklistRun(sample());
expect(r.nextLabel, 'Start brake #1');
expect(r.press(), ['checklist demo v2', '1 brake #1 start']);
expect(r.nextLabel, 'End brake #1');
expect(r.press(), ['1 brake #1 end']);
expect(r.press(), ['1 brake #2 start']);
expect(r.press(), ['1 brake #2 end']);
expect(r.nextLabel, 'Mark flash');
expect(r.press(), ['1 flash']);
expect(r.nextLabel, 'Next step');
expect(r.press(), isEmpty);
expect(r.current.id, '2');
expect(r.press(), ['2 gear 1 start']);
expect(r.press(), ['2 gear 1 end']);
expect(r.finished, isTrue);
expect(r.nextLabel, 'All done');
});
test('leaving an open span aborts it', () {
final r = ChecklistRun(sample());
r.press();
expect(r.redo(), ['1 brake #1 abort', '1 redo']);
expect(r.inSpan, isFalse);
expect(r.nextLabel, 'Start brake #1');
r.press();
expect(r.select(1), ['1 brake #1 abort']);
expect(r.current.id, '2');
expect(r.skip(), ['2 skip']);
expect(r.finished, isTrue);
});
test('the bundled checklists parse, with unique step ids', () {
final dir = Directory('assets/contracts/checklists');
final files = dir.listSync().whereType<File>().where((f) => f.path.endsWith('.json')).toList();
expect(files, isNotEmpty);
for (final f in files) {
final c = Checklist.fromJson(jsonDecode(f.readAsStringSync()) as Map<String, dynamic>);
final ids = c.steps.map((s) => s.id).toList();
expect(ids.toSet().length, ids.length, reason: f.path);
expect(c.steps.every((s) => s.actions.isNotEmpty), isTrue, reason: f.path);
}
});
}