Captures page: the recording checklist with one start/end button
/ crosscheck (push) Successful in 1s
CI / Analyze & Test (push) Successful in 10s
CI / Debug APK (push) Successful in 24s

Steps come from a bundled copy of contracts checklists/ (assets/contracts/,
refreshed by tool/sync-contracts.sh), not from Dart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDwfd6Ki8UfG4hK6W5YpJz
This commit is contained in:
2026-10-13 11:12:44 +09:00
parent 4a32a801f0
commit bf8a99fb23
7 changed files with 793 additions and 4 deletions
+79
View File
@@ -0,0 +1,79 @@
import 'dart:convert';
import 'dart:io';
import 'package:display/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);
}
});
}