fix - ASS-OLD

This commit is contained in:
2026-09-23 09:59:41 +07:00
parent a215b503c6
commit cdaa56febd
5 changed files with 78 additions and 30 deletions

View File

@@ -121,6 +121,16 @@ test('current and archived inventory are selected separately', async () => {
}
});
test('borrow and return history includes requests linked to archived assets', async () => {
const oldBorrow = { BorrowId: 21, AssetId: 17, RequestType: 'borrow', IsArchived: true };
const oldReturn = { BorrowId: 22, AssetId: 17, RequestType: 'return', IsArchived: true };
const fixture = createFixture(() => ({ recordset: [oldBorrow, oldReturn] }));
const response = await fixture.invoke('get', '/api/asset-borrows');
assert.deepEqual(Array.from(response.body.data, row => row.BorrowId), [21, 22]);
assert.match(fixture.queries[0].query, /FROM AssetBorrowRequests br\s+LEFT JOIN AssetInventory ai ON ai.AssetId = br.AssetId/);
assert.doesNotMatch(fixture.queries[0].query, /WHERE\s+(?:br\.|ai\.)?IsArchived\s*=\s*0/i);
});
test('new borrow requests cannot target an archived asset', async () => {
const fixture = createFixture(() => ({ recordset: [{
AssetId: 17, IsArchived: true, Quantity: 10, EndingBalance: 7,