From f7bd588a0290c3f782655f503d118bd23d2ec8cb Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Tue, 9 May 2023 12:29:44 +0530 Subject: [PATCH] chore(test): add status change tests --- .../inventory/tests/testSerialNumbers.spec.ts | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/models/inventory/tests/testSerialNumbers.spec.ts b/models/inventory/tests/testSerialNumbers.spec.ts index 4b8d5f85..f3ec8635 100644 --- a/models/inventory/tests/testSerialNumbers.spec.ts +++ b/models/inventory/tests/testSerialNumbers.spec.ts @@ -421,6 +421,55 @@ test('Material Issue, status change of Serial Number', async (t) => { 0, 'location one has quantity 0 of serialNumbers after issue' ); + + await doc.cancel(); + for (const sn of serialNumbers) { + const status = await fyo.getValue(ModelNameEnum.SerialNumber, sn, 'status'); + t.equal( + status, + 'Active', + `Serial Number ${sn} updated to Active post cancel` + ); + } +}); + +test('Material Receipt cancellation, Serial Number status update', async (t) => { + const serialNumber = `004\n005\n006`; + const serialNumbers = getSerialNumbers(serialNumber); + const doc = await getStockMovement( + MovementTypeEnum.MaterialReceipt, + new Date('2022-11-04T09:59:04.528'), + [ + { + item: itemMap.Pen.name, + to: locationMap.LocationOne, + quantity: 3, + rate: 100, + serialNumber, + }, + ], + fyo + ); + + await (await doc.sync()).submit(); + for (const sn of serialNumbers) { + const status = await fyo.getValue(ModelNameEnum.SerialNumber, sn, 'status'); + t.equal( + status, + 'Active', + `Serial Number ${sn} updated to Active after submit` + ); + } + + await doc.cancel(); + for (const sn of serialNumbers) { + const status = await fyo.getValue(ModelNameEnum.SerialNumber, sn, 'status'); + t.equal( + status, + 'Inactive', + `Serial Number ${sn} updated to InActive after cancel` + ); + } }); closeTestFyo(fyo, __filename);