price per item is printed
This commit is contained in:
@@ -88,6 +88,7 @@ void main() {
|
||||
druckdauerMinuten: 60,
|
||||
gewichtGramm: 40,
|
||||
abfallGramm: 10,
|
||||
gesamtpreis: 12.5,
|
||||
filamente: [
|
||||
const BauteilFilamentModel(
|
||||
filamentId: 'f1',
|
||||
@@ -129,6 +130,7 @@ void main() {
|
||||
await controller.importData();
|
||||
expect(storage.tables, fixture());
|
||||
expect(home.materialien, ['PA12', 'PLA']);
|
||||
expect(home.filamentIdsMitProfil, contains('f1'));
|
||||
expect(home.restgewicht(home.filamente.single), 950);
|
||||
expect(controller.hasError.value, isFalse);
|
||||
},
|
||||
@@ -174,6 +176,23 @@ void main() {
|
||||
expect(storage.tables, fixture());
|
||||
});
|
||||
|
||||
test('Backup imports accept legacy parts without price and reject negative prices', () {
|
||||
final legacy = fixture();
|
||||
legacy[StorageKeys.bauteile]!.single.remove('gesamtpreis');
|
||||
final decoded = BackupModel.decode(BackupModel(legacy).encode());
|
||||
expect(
|
||||
BauteilModel.fromJson(decoded.data[StorageKeys.bauteile]!.single)
|
||||
.gesamtpreis,
|
||||
isNull,
|
||||
);
|
||||
final invalid = fixture();
|
||||
invalid[StorageKeys.bauteile]!.single['gesamtpreis'] = -1;
|
||||
expect(
|
||||
() => BackupModel.decode(BackupModel(invalid).encode()),
|
||||
throwsFormatException,
|
||||
);
|
||||
});
|
||||
|
||||
test('A failed import restores previously written tables', () async {
|
||||
storage.tables.addAll(fixture());
|
||||
files.source = BackupModel({for (final key in BackupModel.keys) key: []})
|
||||
|
||||
Reference in New Issue
Block a user