mirror of
https://github.com/inventree/inventree-app.git
synced 2026-11-29 16:55:04 +00:00
Build fixes (#927)
* bug fix for completing build order * update release notes * fix build line count * Display correct response for build auto-allocate
This commit is contained in:
1 parent
a4bbde6447
commit
9ee01016c8
5 files changed
+202
-95
No files matched your search
+50
-12
@@ -83,16 +83,10 @@ void main() {
|
||||
var build = InvenTreeBuildOrder.fromJson({
|
||||
"quantity": 10,
|
||||
"completed": 4,
|
||||
"item_count": 3,
|
||||
"allocated_line_count": 3,
|
||||
"output_count": 2,
|
||||
});
|
||||
|
||||
expect(build.progressPercent, equals(40));
|
||||
expect(build.remaining, equals(6));
|
||||
expect(build.lineItemCount, equals(3));
|
||||
expect(build.areAllLinesAllocated, isTrue);
|
||||
expect(build.outputCount, equals(2));
|
||||
|
||||
// Progress is clamped
|
||||
build = InvenTreeBuildOrder.fromJson({"quantity": 10, "completed": 15});
|
||||
@@ -100,22 +94,64 @@ void main() {
|
||||
|
||||
build = InvenTreeBuildOrder.fromJson({"quantity": 0, "completed": 1});
|
||||
expect(build.progressPercent, equals(0));
|
||||
});
|
||||
|
||||
// No line items
|
||||
expect(InvenTreeBuildOrder.fromJson({}).areAllLinesAllocated, isFalse);
|
||||
test("Auto-allocate outcome", () async {
|
||||
BuildTaskOutcome outcome(int code, [Map<String, dynamic>? data]) =>
|
||||
InvenTreeBuildOrder.autoAllocateOutcome(
|
||||
APIResponse(statusCode: code, data: data ?? {}),
|
||||
);
|
||||
|
||||
// Older servers (API < 465) complete synchronously with 201
|
||||
expect(outcome(201), equals(BuildTaskOutcome.complete));
|
||||
|
||||
// Task offloaded to the background worker
|
||||
expect(
|
||||
outcome(200, {
|
||||
"task_id": "abc",
|
||||
"pending": true,
|
||||
"complete": false,
|
||||
"success": false,
|
||||
}),
|
||||
equals(BuildTaskOutcome.queued),
|
||||
);
|
||||
|
||||
// Task run synchronously
|
||||
expect(
|
||||
outcome(200, {"task_id": "", "complete": true, "success": true}),
|
||||
equals(BuildTaskOutcome.complete),
|
||||
);
|
||||
expect(
|
||||
outcome(200, {"task_id": "", "complete": true, "success": false}),
|
||||
equals(BuildTaskOutcome.failed),
|
||||
);
|
||||
|
||||
// Task could not be run, or request rejected
|
||||
expect(outcome(404, {"complete": false}), BuildTaskOutcome.failed);
|
||||
expect(outcome(400), equals(BuildTaskOutcome.failed));
|
||||
});
|
||||
|
||||
test("Details", () async {
|
||||
var build = InvenTreeBuildOrder.fromJson({
|
||||
"parent": 3,
|
||||
"part_detail": {"name": "Assembly"},
|
||||
"destination_detail": {"name": "Store"},
|
||||
"take_from": 5,
|
||||
"destination": 7,
|
||||
});
|
||||
|
||||
expect(build.isParentBuild, isTrue);
|
||||
expect(build.parentBuildId, equals(3));
|
||||
expect(build.partDetail?.name, equals("Assembly"));
|
||||
expect(build.destinationName, equals("Store"));
|
||||
expect(build.sourceLocationId, equals(5));
|
||||
expect(build.destinationId, equals(7));
|
||||
|
||||
// Unset locations are null (not 0 or -1)
|
||||
build = InvenTreeBuildOrder.fromJson({
|
||||
"take_from": null,
|
||||
"destination": null,
|
||||
});
|
||||
expect(build.sourceLocationId, isNull);
|
||||
expect(build.destinationId, isNull);
|
||||
|
||||
build = InvenTreeBuildOrder.fromJson({});
|
||||
expect(build.isParentBuild, isFalse);
|
||||
@@ -139,12 +175,14 @@ void main() {
|
||||
expect(production.canHold, isTrue);
|
||||
expect(production.canCompleteOrder, isTrue);
|
||||
|
||||
// Cannot complete without any outputs
|
||||
// Completion is offered without output counts (the server validates)
|
||||
expect(
|
||||
InvenTreeBuildOrder.fromJson({"status": 20}).canCompleteOrder,
|
||||
isFalse,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
expect(production.finishUrl, endsWith("/finish/"));
|
||||
|
||||
final onHold = build(25);
|
||||
expect(onHold.isOnHold, isTrue);
|
||||
expect(onHold.canIssue, isTrue);
|
||||
|
||||
Reference in new issue
Block a user