1
0
Fork 0
mirror of https://github.com/s-frick/effigenix.git synced 2026-03-28 17:04:49 +01:00
This commit is contained in:
Janosch 2026-03-27 11:26:06 +01:00
parent e897f41a32
commit 061c2b4f8d
14 changed files with 1293 additions and 18 deletions

View file

@ -0,0 +1,99 @@
import { test, expect } from '../../../fixtures/auth.fixture.js';
/**
* TC-MOV Warenbewegungen
* Quelle: GitHub Issues #4#20
*/
test.describe('TC-MOV: Warenbewegungen', () => {
async function setupStockWithBatch(
request: Parameters<typeof test>[1]['request'],
token: string,
): Promise<{ stockId: string; stockBatchId: string; articleId: string; batchId: string }> {
const catRes = await request.post('/api/categories', {
data: { name: `MOV-Kat-${Date.now()}` },
headers: { Authorization: `Bearer ${token}` },
});
const { id: categoryId } = await catRes.json();
const artRes = await request.post('/api/articles', {
data: {
name: `MOV-Art-${Date.now()}`,
articleNumber: `MOV-${Date.now()}`,
categoryId,
unit: 'KG',
priceModel: 'FIXED',
price: 1.0,
},
headers: { Authorization: `Bearer ${token}` },
});
const { id: articleId } = await artRes.json();
const locRes = await request.post('/api/inventory/storage-locations', {
data: { name: `MOV-Lager-${Date.now()}`, storageType: 'DRY_STORAGE' },
headers: { Authorization: `Bearer ${token}` },
});
const { id: storageLocationId } = await locRes.json();
const stockRes = await request.post('/api/inventory/stocks', {
data: { articleId, storageLocationId },
headers: { Authorization: `Bearer ${token}` },
});
expect(stockRes.status()).toBe(201);
const { id: stockId } = await stockRes.json();
const batchId = `B-${Date.now()}`;
const batchRes = await request.post(`/api/inventory/stocks/${stockId}/batches`, {
data: {
batchId,
batchType: 'PURCHASED',
quantityAmount: '20',
quantityUnit: 'KG',
expiryDate: '2026-12-31',
},
headers: { Authorization: `Bearer ${token}` },
});
expect(batchRes.status()).toBe(201);
const { id: stockBatchId } = await batchRes.json();
return { stockId, stockBatchId, articleId, batchId };
}
test('TC-MOV-01: Warenbewegung erfassen Wareneingang', async ({ request, adminToken }) => {
const { stockId, stockBatchId, articleId, batchId } = await setupStockWithBatch(request, adminToken);
const res = await request.post('/api/inventory/stock-movements', {
data: {
stockId,
articleId,
stockBatchId,
batchId,
batchType: 'PURCHASED',
movementType: 'GOODS_RECEIPT',
quantityAmount: '5',
quantityUnit: 'KG',
},
headers: { Authorization: `Bearer ${adminToken}` },
});
expect(res.status()).toBe(201);
const body = await res.json();
expect(body.movementType).toBe('GOODS_RECEIPT');
});
test('TC-MOV-02: Warenbewegung ohne Pflichtfelder wird abgelehnt', async ({ request, adminToken }) => {
const res = await request.post('/api/inventory/stock-movements', {
data: { movementType: 'GOODS_RECEIPT' },
headers: { Authorization: `Bearer ${adminToken}` },
});
expect(res.status()).toBe(400);
});
test('TC-MOV-03: Warenbewegungen nach Stock auflisten', async ({ request, adminToken }) => {
const { stockId } = await setupStockWithBatch(request, adminToken);
const res = await request.get(`/api/inventory/stock-movements?stockId=${stockId}`, {
headers: { Authorization: `Bearer ${adminToken}` },
});
expect(res.status()).toBe(200);
expect(Array.isArray(await res.json())).toBe(true);
});
});