mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 13:49:36 +01:00
phase 2
This commit is contained in:
parent
e897f41a32
commit
061c2b4f8d
14 changed files with 1293 additions and 18 deletions
|
|
@ -0,0 +1,88 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-TRACE – Chargen-Rückverfolgung
|
||||
* Quelle: GitHub Issues #43–#44
|
||||
*/
|
||||
test.describe('TC-TRACE: Chargen-Rückverfolgung', () => {
|
||||
async function createPlannedBatch(request: Parameters<typeof test>[1]['request'], token: string): Promise<{ batchId: string; batchNumber: string }> {
|
||||
const catRes = await request.post('/api/categories', {
|
||||
data: { name: `TRC-Kat-${Date.now()}` },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: categoryId } = await catRes.json();
|
||||
|
||||
const artRes = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `TRC-Art-${Date.now()}`,
|
||||
articleNumber: `TRC-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'KG',
|
||||
priceModel: 'FIXED',
|
||||
price: 2.0,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: articleId } = await artRes.json();
|
||||
|
||||
const recipeRes = await request.post('/api/recipes', {
|
||||
data: {
|
||||
name: `TRC-Rezept-${Date.now()}`,
|
||||
version: 1,
|
||||
type: 'FINISHED_PRODUCT',
|
||||
outputQuantity: '5',
|
||||
outputUom: 'KG',
|
||||
articleId,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: recipeId } = await recipeRes.json();
|
||||
|
||||
await request.post(`/api/recipes/${recipeId}/activate`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
const batchRes = await request.post('/api/production/batches', {
|
||||
data: {
|
||||
recipeId,
|
||||
plannedQuantity: '5',
|
||||
plannedQuantityUnit: 'KG',
|
||||
productionDate: '2026-06-01',
|
||||
bestBeforeDate: '2026-06-08',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
expect(batchRes.status()).toBe(201);
|
||||
const batch = await batchRes.json();
|
||||
return { batchId: batch.id, batchNumber: batch.batchNumber };
|
||||
}
|
||||
|
||||
test('TC-TRACE-01: Vorwärts-Verfolgung einer Charge', async ({ request, adminToken }) => {
|
||||
const { batchId } = await createPlannedBatch(request, adminToken);
|
||||
|
||||
const res = await request.get(`/api/production/batches/${batchId}/trace-forward`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
const body = await res.json();
|
||||
expect(body).toHaveProperty('batchId');
|
||||
});
|
||||
|
||||
test('TC-TRACE-02: Rückwärts-Verfolgung einer Charge', async ({ request, adminToken }) => {
|
||||
const { batchId } = await createPlannedBatch(request, adminToken);
|
||||
|
||||
const res = await request.get(`/api/production/batches/${batchId}/trace-backward`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
const body = await res.json();
|
||||
expect(body).toHaveProperty('batchId');
|
||||
});
|
||||
|
||||
test('TC-TRACE-03: Rückverfolgung einer nicht vorhandenen Charge gibt 404', async ({ request, adminToken }) => {
|
||||
const res = await request.get('/api/production/batches/non-existent-id/trace-forward', {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect([404, 400]).toContain(res.status());
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue