mirror of
https://github.com/inventree/inventree-app.git
synced 2026-11-21 21:25:48 +00:00
Audit log (#899)
* Check if the backend supports auditlog info * Change from stockhistory to auditlog - Removes support for legacy stockhistory tracking - Now uses AuditLog * Update release notes
This commit is contained in:
1 parent
3a228dfc1f
commit
edd7fafb6d
24 files changed
+488
-214
No files matched your search
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Unit tests for the InvenTreeAuditLogEntry model
|
||||
*/
|
||||
|
||||
import "package:flutter_test/flutter_test.dart";
|
||||
import "package:inventree/inventree/audit_log.dart";
|
||||
|
||||
void main() {
|
||||
group("Audit Log:", () {
|
||||
test("Label", () async {
|
||||
var entry = InvenTreeAuditLogEntry.fromJson({
|
||||
"action": 1,
|
||||
"action_label": "Update",
|
||||
"event_label": null,
|
||||
});
|
||||
|
||||
expect(entry.label, equals("Update"));
|
||||
|
||||
entry = InvenTreeAuditLogEntry.fromJson({
|
||||
"action": 1,
|
||||
"action_label": "Update",
|
||||
"event_label": "Stock counted",
|
||||
});
|
||||
|
||||
expect(entry.label, equals("Stock counted"));
|
||||
});
|
||||
|
||||
test("Change Summary", () async {
|
||||
var entry = InvenTreeAuditLogEntry.fromJson({
|
||||
"changes_detail": [
|
||||
{"field": "quantity", "label": "Quantity", "old": "5", "new": "10"},
|
||||
{
|
||||
"field": "status",
|
||||
"label": "Status",
|
||||
"old": 10,
|
||||
"new": 50,
|
||||
"old_display": "OK",
|
||||
"new_display": "Attention",
|
||||
},
|
||||
{"field": "name", "label": "Name", "old": null, "new": "Widget"},
|
||||
{"field": "notes", "label": "Notes", "old": "None", "new": "abc"},
|
||||
{
|
||||
"field": "tags",
|
||||
"label": "Tags",
|
||||
"type": "m2m",
|
||||
"operation": "add",
|
||||
"objects": ["red", "blue"],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(
|
||||
entry.changeSummary,
|
||||
equals([
|
||||
"Quantity: 5 → 10",
|
||||
"Status: OK → Attention",
|
||||
"Name: Widget",
|
||||
"Notes: abc",
|
||||
"Tags: add red, blue",
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
test("No Changes", () async {
|
||||
var entry = InvenTreeAuditLogEntry.fromJson({});
|
||||
|
||||
expect(entry.changes, isEmpty);
|
||||
expect(entry.changeSummary, isEmpty);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user