mirror of
https://github.com/inventree/inventree-app.git
synced 2026-11-23 14:16:08 +00:00
bug fix for pricing didsplay (#929)
* bug fix for pricing didsplay Display override values correctly * update release notes
This commit is contained in:
1 parent
6614aa2ff5
commit
2ee823b65f
3 files changed
+125
-3
No files matched your search
@@ -3,6 +3,7 @@
|
||||
|
||||
- Fix incorrect allocation count in build detail widget
|
||||
- Fix "new version available" notice showing in "About" view when app is up to date
|
||||
- Bug fix for part pricing display
|
||||
- Fix handling of form response data for stock item creation
|
||||
- Improved allocation display for build orders
|
||||
- Multiple bug fixes for build order support
|
||||
|
||||
@@ -67,12 +67,12 @@ class _PartPricingWidgetState extends RefreshableState<PartPricingWidget> {
|
||||
),
|
||||
);
|
||||
|
||||
if (pricing.overallMin != null) {
|
||||
if (pricing.overrideMin != null) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().priceOverrideMin),
|
||||
trailing: Text(
|
||||
renderCurrency(pricing.overallMin, pricing.overrideMinCurrency),
|
||||
renderCurrency(pricing.overrideMin, pricing.overrideMinCurrency),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -83,7 +83,7 @@ class _PartPricingWidgetState extends RefreshableState<PartPricingWidget> {
|
||||
ListTile(
|
||||
title: Text(L10().priceOverrideMax),
|
||||
trailing: Text(
|
||||
renderCurrency(pricing.overallMax, pricing.overrideMaxCurrency),
|
||||
renderCurrency(pricing.overrideMax, pricing.overrideMaxCurrency),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Widget tests for the part pricing screen (regression tests for B5).
|
||||
*
|
||||
* The "override" rows previously displayed the overall price range,
|
||||
* and were shown whenever an overall price existed.
|
||||
*
|
||||
* No server is required.
|
||||
*/
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_test/flutter_test.dart";
|
||||
import "package:one_context/one_context.dart";
|
||||
|
||||
import "package:inventree/helpers.dart";
|
||||
import "package:inventree/inventree/part.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/widget/part/part_pricing.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
|
||||
import "../setup.dart";
|
||||
import "harness.dart";
|
||||
|
||||
// Display the pricing screen for [pricing] data, and wait for it to load
|
||||
Future<void> pumpPricing(
|
||||
WidgetTester tester,
|
||||
Map<String, dynamic> pricing,
|
||||
) async {
|
||||
final screen = PartPricingWidget(
|
||||
part: InvenTreePart.fromJson({"pk": 1, "name": "Widget"}),
|
||||
partPricing: InvenTreePartPricing.fromJson(pricing),
|
||||
);
|
||||
|
||||
await pumpScreen(tester, screen);
|
||||
|
||||
final state =
|
||||
tester.state(find.byWidget(screen)) as RefreshableState<StatefulWidget>;
|
||||
|
||||
await waitUntil(tester, () => state.loaded, reason: "pricing loaded");
|
||||
await idle(tester);
|
||||
|
||||
// Allow the image cache (part thumbnail) to complete its cleanup timer
|
||||
await tester.pump(const Duration(seconds: 11));
|
||||
}
|
||||
|
||||
// The value displayed in the row titled [title]
|
||||
Finder rowValue(String title, String value) => find.descendant(
|
||||
of: find.widgetWithText(ListTile, title),
|
||||
matching: find.text(value),
|
||||
);
|
||||
|
||||
void main() {
|
||||
setupTestEnv();
|
||||
mockSharedPreferences();
|
||||
|
||||
setUp(() {
|
||||
OneContext().key = GlobalKey<NavigatorState>();
|
||||
useNewTempDirectory();
|
||||
});
|
||||
|
||||
testWidgets("Override prices are displayed", (tester) async {
|
||||
await pumpPricing(tester, {
|
||||
"currency": "AUD",
|
||||
"overall_min": 1,
|
||||
"overall_max": 10,
|
||||
"override_min": 2.5,
|
||||
"override_min_currency": "AUD",
|
||||
"override_max": 7.5,
|
||||
"override_max_currency": "USD",
|
||||
});
|
||||
|
||||
expect(
|
||||
rowValue(L10().priceOverrideMin, renderCurrency(2.5, "AUD")),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
expect(
|
||||
rowValue(L10().priceOverrideMax, renderCurrency(7.5, "USD")),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
// The overall range is not shown as an override
|
||||
expect(
|
||||
rowValue(L10().priceOverrideMin, renderCurrency(1, "AUD")),
|
||||
findsNothing,
|
||||
);
|
||||
|
||||
expect(
|
||||
rowValue(L10().priceOverrideMax, renderCurrency(10, "USD")),
|
||||
findsNothing,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets("No override rows without overrides", (tester) async {
|
||||
await pumpPricing(tester, {
|
||||
"currency": "AUD",
|
||||
"overall_min": 1,
|
||||
"overall_max": 10,
|
||||
});
|
||||
|
||||
expect(find.text(L10().priceRange), findsOneWidget);
|
||||
expect(find.text(L10().priceOverrideMin), findsNothing);
|
||||
expect(find.text(L10().priceOverrideMax), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets("Single override", (tester) async {
|
||||
await pumpPricing(tester, {
|
||||
"currency": "AUD",
|
||||
"overall_min": 1,
|
||||
"overall_max": 10,
|
||||
"override_max": 7.5,
|
||||
});
|
||||
|
||||
expect(find.text(L10().priceOverrideMin), findsNothing);
|
||||
|
||||
// Currency falls back to the pricing currency
|
||||
expect(
|
||||
rowValue(L10().priceOverrideMax, renderCurrency(7.5, "AUD")),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user