import 'package:flutter_test/flutter_test.dart'; import 'package:sequence_diagram/model/models.dart'; import 'package:sequence_diagram/state/app_controller.dart'; void main() { group('station management', () { test('setStations reassigns actions of a removed station', () { final AppController c = AppController(project: Project.demo()); expect(c.project.stations.length, 2); final String removed = c.project.stations[1].id; expect(c.project.actions.any((Action a) => a.stationId == removed), isTrue); c.setStations([c.project.stations.first]); expect(c.project.stations.length, 1); expect(c.project.actions.every((Action a) => a.stationId == c.project.stations.first.id), isTrue); expect(c.canUndo, isTrue); }); test('setStations ignores an empty list (keep at least one station)', () { final AppController c = AppController(project: Project.demo()); final int before = c.project.stations.length; c.setStations([]); expect(c.project.stations.length, before); }); test('setStations can add and rename stations', () { final AppController c = AppController(project: Project.demo()); final List next = [ ...c.project.stations, const Station(id: 'ST3', name: '工位 3', order: 2, color: 0xFF4ADE80), ]; c.setStations(next); expect(c.project.stations.length, 3); expect(c.project.stationById('ST3')?.name, '工位 3'); }); }); }