add some new features
This commit is contained in:
@@ -143,6 +143,12 @@ void main() {
|
||||
Future<void> add(String id) async {
|
||||
await tester.tap(find.byType(DropdownButtonFormField<String>));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text(
|
||||
'Restgewicht: ${DisplayFormats.number(controller.restgewichtGramm(id)!)} g',
|
||||
),
|
||||
findsWidgets,
|
||||
);
|
||||
await tester.tap(find.text(controller.filamentLabel(id)).last);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
@@ -201,7 +207,6 @@ void main() {
|
||||
(tester) async {
|
||||
await show(tester);
|
||||
fill();
|
||||
controller.gesamtpreisController.text = '12,50';
|
||||
photos.result = png;
|
||||
await controller.pickPhoto();
|
||||
await controller.saveBauteil();
|
||||
@@ -209,19 +214,19 @@ void main() {
|
||||
expect(remaining('b'), 960);
|
||||
final originalId = controller.bauteile.single.bauteilId;
|
||||
final originalDate = controller.bauteile.single.erstelltAm;
|
||||
expect(controller.bauteile.single.gesamtpreis, 12.5);
|
||||
expect(controller.bauteile.single.gesamtpreis, 3);
|
||||
expect(
|
||||
storage
|
||||
.getModelList(BauteilController.storageKey)
|
||||
.single['gesamtpreis'],
|
||||
12.5,
|
||||
3,
|
||||
);
|
||||
expect(controller.gesamtpreisController.text, isEmpty);
|
||||
|
||||
await edit(tester, controller.bauteile.single);
|
||||
expect(controller.foto.value, png);
|
||||
expect(controller.gesamtpreisController.text, '12,5');
|
||||
controller.gesamtpreisController.text = '18,90';
|
||||
expect(controller.gesamtpreisController.text, '3,00');
|
||||
controller.aufschlagController.text = '20';
|
||||
expect(controller.verfuegbarGramm('a'), 1000);
|
||||
controller.verbrauchController('a').text = '20';
|
||||
controller.verbrauchController('b').text = '80';
|
||||
@@ -242,7 +247,7 @@ void main() {
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
controller.bauteile.every((item) => item.gesamtpreis == 18.9),
|
||||
controller.bauteile.every((item) => item.gesamtpreis == 2.4),
|
||||
isTrue,
|
||||
);
|
||||
expect(remaining('a'), 960);
|
||||
@@ -255,7 +260,7 @@ void main() {
|
||||
expect(remaining('a'), 980);
|
||||
final reloaded = Get.put(BauteilController(), tag: 'reload');
|
||||
expect(reloaded.bauteile.single.fotoBytes, png);
|
||||
expect(reloaded.bauteile.single.gesamtpreis, 18.9);
|
||||
expect(reloaded.bauteile.single.gesamtpreis, 2.4);
|
||||
expect(reloaded.bauteile.single.filamente.last.verbrauchGramm, 80);
|
||||
// Purchases retain the original weight; the persisted ledger is deducted.
|
||||
expect(
|
||||
@@ -285,27 +290,27 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Total price rejects invalid amounts, accepts zero and can be cleared',
|
||||
'Markup rejects invalid amounts, accepts zero and price is always calculated',
|
||||
(tester) async {
|
||||
await show(tester);
|
||||
fill();
|
||||
for (final value in ['-1', 'NaN', 'Infinity', 'abc']) {
|
||||
controller.gesamtpreisController.text = value;
|
||||
controller.aufschlagController.text = value;
|
||||
await controller.saveBauteil();
|
||||
expect(storage.getModelList(BauteilController.storageKey), isEmpty);
|
||||
}
|
||||
controller.gesamtpreisController.text = '0';
|
||||
controller.aufschlagController.text = '0';
|
||||
await controller.saveBauteil();
|
||||
expect(controller.bauteile.single.gesamtpreis, 0);
|
||||
expect(controller.bauteile.single.gesamtpreis, 2);
|
||||
await edit(tester, controller.bauteile.single);
|
||||
controller.gesamtpreisController.clear();
|
||||
controller.aufschlagController.text = '25';
|
||||
await controller.saveBauteil();
|
||||
expect(controller.bauteile.single.gesamtpreis, isNull);
|
||||
expect(controller.bauteile.single.gesamtpreis, 2.5);
|
||||
expect(
|
||||
storage
|
||||
.getModelList(BauteilController.storageKey)
|
||||
.single['gesamtpreis'],
|
||||
isNull,
|
||||
2.5,
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -322,6 +327,7 @@ void main() {
|
||||
expect(remaining('a'), 40);
|
||||
await edit(tester, first);
|
||||
expect(controller.verfuegbarGramm('a'), 940);
|
||||
expect(controller.restgewichtGramm('a'), 40);
|
||||
controller.gewichtController.text = '940';
|
||||
controller.verbrauchController('a').text = '950';
|
||||
await controller.saveBauteil();
|
||||
@@ -402,7 +408,6 @@ void main() {
|
||||
(tester) async {
|
||||
await show(tester, narrow: true);
|
||||
fill();
|
||||
controller.gesamtpreisController.text = '12,50';
|
||||
photos.result = png;
|
||||
await controller.pickPhoto();
|
||||
await controller.saveBauteil();
|
||||
@@ -414,7 +419,7 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Gesamtpreis ${DisplayFormats.currency(12.5)}'),
|
||||
find.text('Gesamtpreis ${DisplayFormats.currency(3)}'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user