mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 17:19:56 +01:00
phase 2
This commit is contained in:
parent
e897f41a32
commit
061c2b4f8d
14 changed files with 1293 additions and 18 deletions
151
test-automation/web-ui/tests/api/production/batches.spec.ts
Normal file
151
test-automation/web-ui/tests/api/production/batches.spec.ts
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-BAT – Produktionschargen
|
||||
* Quelle: GitHub Issues #33–#36
|
||||
*/
|
||||
test.describe('TC-BAT: Produktionschargen', () => {
|
||||
async function createActiveRecipe(request: Parameters<typeof test>[1]['request'], token: string): Promise<string> {
|
||||
const catRes = await request.post('/api/categories', {
|
||||
data: { name: `BAT-Kat-${Date.now()}` },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: categoryId } = await catRes.json();
|
||||
const artRes = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `BAT-Art-${Date.now()}`,
|
||||
articleNumber: `BAT-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'KG',
|
||||
priceModel: 'FIXED',
|
||||
price: 1.5,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: articleId } = await artRes.json();
|
||||
|
||||
const recipeRes = await request.post('/api/recipes', {
|
||||
data: {
|
||||
name: `BAT-Rezept-${Date.now()}`,
|
||||
version: 1,
|
||||
type: 'FINISHED_PRODUCT',
|
||||
outputQuantity: '10',
|
||||
outputUom: 'KG',
|
||||
articleId,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: recipeId } = await recipeRes.json();
|
||||
|
||||
await request.post(`/api/recipes/${recipeId}/activate`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
return recipeId;
|
||||
}
|
||||
|
||||
test('TC-BAT-01: Charge planen – PLANNED Status', async ({ request, adminToken }) => {
|
||||
const recipeId = await createActiveRecipe(request, adminToken);
|
||||
const res = await request.post('/api/production/batches', {
|
||||
data: {
|
||||
recipeId,
|
||||
plannedQuantity: '20',
|
||||
plannedQuantityUnit: 'KG',
|
||||
productionDate: '2026-04-01',
|
||||
bestBeforeDate: '2026-04-08',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
const body = await res.json();
|
||||
expect(body.status).toBe('PLANNED');
|
||||
expect(body.batchNumber).toBeTruthy();
|
||||
});
|
||||
|
||||
test('TC-BAT-02: Charge starten', async ({ request, adminToken }) => {
|
||||
const recipeId = await createActiveRecipe(request, adminToken);
|
||||
const planRes = await request.post('/api/production/batches', {
|
||||
data: {
|
||||
recipeId,
|
||||
plannedQuantity: '5',
|
||||
plannedQuantityUnit: 'KG',
|
||||
productionDate: '2026-04-02',
|
||||
bestBeforeDate: '2026-04-09',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(planRes.status()).toBe(201);
|
||||
const { id } = await planRes.json();
|
||||
|
||||
const startRes = await request.post(`/api/production/batches/${id}/start`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(startRes.status()).toBe(200);
|
||||
const body = await startRes.json();
|
||||
expect(body.status).toBe('IN_PRODUCTION');
|
||||
});
|
||||
|
||||
test('TC-BAT-03: Charge abschließen', async ({ request, adminToken }) => {
|
||||
const recipeId = await createActiveRecipe(request, adminToken);
|
||||
const planRes = await request.post('/api/production/batches', {
|
||||
data: {
|
||||
recipeId,
|
||||
plannedQuantity: '8',
|
||||
plannedQuantityUnit: 'KG',
|
||||
productionDate: '2026-04-03',
|
||||
bestBeforeDate: '2026-04-10',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(planRes.status()).toBe(201);
|
||||
const { id } = await planRes.json();
|
||||
|
||||
await request.post(`/api/production/batches/${id}/start`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
|
||||
const completeRes = await request.post(`/api/production/batches/${id}/complete`, {
|
||||
data: { actualQuantity: '7.5', actualQuantityUnit: 'KG', waste: '0.5', wasteUnit: 'KG' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(completeRes.status()).toBe(200);
|
||||
const body = await completeRes.json();
|
||||
expect(body.status).toBe('COMPLETED');
|
||||
});
|
||||
|
||||
test('TC-BAT-04: Charge ohne Rezept wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/production/batches', {
|
||||
data: {
|
||||
plannedQuantity: '10',
|
||||
plannedQuantityUnit: 'KG',
|
||||
productionDate: '2026-04-01',
|
||||
bestBeforeDate: '2026-04-08',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-BAT-05: Charge nach Nummer suchen', async ({ request, adminToken }) => {
|
||||
const recipeId = await createActiveRecipe(request, adminToken);
|
||||
const planRes = await request.post('/api/production/batches', {
|
||||
data: {
|
||||
recipeId,
|
||||
plannedQuantity: '3',
|
||||
plannedQuantityUnit: 'KG',
|
||||
productionDate: '2026-04-04',
|
||||
bestBeforeDate: '2026-04-11',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(planRes.status()).toBe(201);
|
||||
const { batchNumber } = await planRes.json();
|
||||
|
||||
const findRes = await request.get(`/api/production/batches/by-number/${batchNumber}`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(findRes.status()).toBe(200);
|
||||
const body = await findRes.json();
|
||||
expect(body.batchNumber).toBe(batchNumber);
|
||||
});
|
||||
});
|
||||
132
test-automation/web-ui/tests/api/production/orders.spec.ts
Normal file
132
test-automation/web-ui/tests/api/production/orders.spec.ts
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-ORD – Produktionsaufträge
|
||||
* Quelle: GitHub Issues #38–#42
|
||||
*/
|
||||
test.describe('TC-ORD: Produktionsaufträge', () => {
|
||||
async function createActiveRecipe(request: Parameters<typeof test>[1]['request'], token: string): Promise<string> {
|
||||
const catRes = await request.post('/api/categories', {
|
||||
data: { name: `ORD-Kat-${Date.now()}` },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: categoryId } = await catRes.json();
|
||||
const artRes = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `ORD-Art-${Date.now()}`,
|
||||
articleNumber: `ORD-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'KG',
|
||||
priceModel: 'FIXED',
|
||||
price: 1.0,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: articleId } = await artRes.json();
|
||||
|
||||
const recipeRes = await request.post('/api/recipes', {
|
||||
data: {
|
||||
name: `ORD-Rezept-${Date.now()}`,
|
||||
version: 1,
|
||||
type: 'FINISHED_PRODUCT',
|
||||
outputQuantity: '10',
|
||||
outputUom: 'KG',
|
||||
articleId,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: recipeId } = await recipeRes.json();
|
||||
|
||||
await request.post(`/api/recipes/${recipeId}/activate`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
return recipeId;
|
||||
}
|
||||
|
||||
test('TC-ORD-01: Produktionsauftrag erstellen – PLANNED Status', async ({ request, adminToken }) => {
|
||||
const recipeId = await createActiveRecipe(request, adminToken);
|
||||
const res = await request.post('/api/production/production-orders', {
|
||||
data: {
|
||||
recipeId,
|
||||
plannedQuantity: '50',
|
||||
plannedQuantityUnit: 'KG',
|
||||
plannedDate: '2026-05-01',
|
||||
priority: 'NORMAL',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
const body = await res.json();
|
||||
expect(body.status).toBe('PLANNED');
|
||||
});
|
||||
|
||||
test('TC-ORD-02: Auftrag ohne Rezept wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/production/production-orders', {
|
||||
data: {
|
||||
plannedQuantity: '10',
|
||||
plannedQuantityUnit: 'KG',
|
||||
plannedDate: '2026-05-01',
|
||||
priority: 'NORMAL',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-ORD-03: Auftrag freigeben', async ({ request, adminToken }) => {
|
||||
const recipeId = await createActiveRecipe(request, adminToken);
|
||||
const createRes = await request.post('/api/production/production-orders', {
|
||||
data: {
|
||||
recipeId,
|
||||
plannedQuantity: '30',
|
||||
plannedQuantityUnit: 'KG',
|
||||
plannedDate: '2026-05-02',
|
||||
priority: 'HIGH',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id } = await createRes.json();
|
||||
|
||||
const releaseRes = await request.post(`/api/production/production-orders/${id}/release`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(releaseRes.status()).toBe(200);
|
||||
const body = await releaseRes.json();
|
||||
expect(body.status).toBe('RELEASED');
|
||||
});
|
||||
|
||||
test('TC-ORD-04: Auftrag stornieren', async ({ request, adminToken }) => {
|
||||
const recipeId = await createActiveRecipe(request, adminToken);
|
||||
const createRes = await request.post('/api/production/production-orders', {
|
||||
data: {
|
||||
recipeId,
|
||||
plannedQuantity: '15',
|
||||
plannedQuantityUnit: 'KG',
|
||||
plannedDate: '2026-05-03',
|
||||
priority: 'LOW',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id } = await createRes.json();
|
||||
|
||||
const cancelRes = await request.post(`/api/production/production-orders/${id}/cancel`, {
|
||||
data: { reason: 'Test-Stornierung' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(cancelRes.status()).toBe(200);
|
||||
const body = await cancelRes.json();
|
||||
expect(body.status).toBe('CANCELLED');
|
||||
});
|
||||
|
||||
test('TC-ORD-05: Aufträge nach Status filtern', async ({ request, adminToken }) => {
|
||||
const res = await request.get('/api/production/production-orders?status=PLANNED', {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
const body = await res.json();
|
||||
expect(Array.isArray(body)).toBe(true);
|
||||
});
|
||||
});
|
||||
141
test-automation/web-ui/tests/api/production/recipes.spec.ts
Normal file
141
test-automation/web-ui/tests/api/production/recipes.spec.ts
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-REC – Rezepte
|
||||
* Quelle: GitHub Issues #26–#32
|
||||
*/
|
||||
test.describe('TC-REC: Rezepte', () => {
|
||||
async function createArticle(request: Parameters<typeof test>[1]['request'], token: string): Promise<string> {
|
||||
const catRes = await request.post('/api/categories', {
|
||||
data: { name: `Kat-${Date.now()}` },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: categoryId } = await catRes.json();
|
||||
const artRes = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `Art-${Date.now()}`,
|
||||
articleNumber: `ART-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'KG',
|
||||
priceModel: 'FIXED',
|
||||
price: 2.0,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id } = await artRes.json();
|
||||
return id;
|
||||
}
|
||||
|
||||
test('TC-REC-01: Rezept erstellen – DRAFT Status', async ({ request, adminToken }) => {
|
||||
const articleId = await createArticle(request, adminToken);
|
||||
const res = await request.post('/api/recipes', {
|
||||
data: {
|
||||
name: `Brot-${Date.now()}`,
|
||||
version: 1,
|
||||
type: 'FINISHED_PRODUCT',
|
||||
outputQuantity: '10',
|
||||
outputUom: 'KG',
|
||||
articleId,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
const body = await res.json();
|
||||
expect(body.status).toBe('DRAFT');
|
||||
});
|
||||
|
||||
test('TC-REC-02: Rezept ohne Name wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const articleId = await createArticle(request, adminToken);
|
||||
const res = await request.post('/api/recipes', {
|
||||
data: { version: 1, type: 'FINISHED_PRODUCT', outputQuantity: '10', outputUom: 'KG', articleId },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-REC-03: Zutat zu Rezept hinzufügen', async ({ request, adminToken }) => {
|
||||
const articleId = await createArticle(request, adminToken);
|
||||
const recipeRes = await request.post('/api/recipes', {
|
||||
data: {
|
||||
name: `Rezept-Zutaten-${Date.now()}`,
|
||||
version: 1,
|
||||
type: 'FINISHED_PRODUCT',
|
||||
outputQuantity: '5',
|
||||
outputUom: 'KG',
|
||||
articleId,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(recipeRes.status()).toBe(201);
|
||||
const { id: recipeId } = await recipeRes.json();
|
||||
|
||||
const ingredientArticleId = await createArticle(request, adminToken);
|
||||
const ingRes = await request.post(`/api/recipes/${recipeId}/ingredients`, {
|
||||
data: { position: 1, articleId: ingredientArticleId, quantity: '2', uom: 'KG', substitutable: false },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(ingRes.status()).toBe(201);
|
||||
});
|
||||
|
||||
test('TC-REC-04: Rezept aktivieren', async ({ request, adminToken }) => {
|
||||
const articleId = await createArticle(request, adminToken);
|
||||
const recipeRes = await request.post('/api/recipes', {
|
||||
data: {
|
||||
name: `Aktivieren-${Date.now()}`,
|
||||
version: 1,
|
||||
type: 'INTERMEDIATE',
|
||||
outputQuantity: '3',
|
||||
outputUom: 'KG',
|
||||
articleId,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(recipeRes.status()).toBe(201);
|
||||
const { id: recipeId } = await recipeRes.json();
|
||||
|
||||
const activateRes = await request.post(`/api/recipes/${recipeId}/activate`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(activateRes.status()).toBe(200);
|
||||
const body = await activateRes.json();
|
||||
expect(body.status).toBe('ACTIVE');
|
||||
});
|
||||
|
||||
test('TC-REC-05: Rezept archivieren', async ({ request, adminToken }) => {
|
||||
const articleId = await createArticle(request, adminToken);
|
||||
const recipeRes = await request.post('/api/recipes', {
|
||||
data: {
|
||||
name: `Archiv-${Date.now()}`,
|
||||
version: 1,
|
||||
type: 'RAW_MATERIAL',
|
||||
outputQuantity: '1',
|
||||
outputUom: 'KG',
|
||||
articleId,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(recipeRes.status()).toBe(201);
|
||||
const { id: recipeId } = await recipeRes.json();
|
||||
|
||||
await request.post(`/api/recipes/${recipeId}/activate`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
|
||||
const archiveRes = await request.post(`/api/recipes/${recipeId}/archive`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(archiveRes.status()).toBe(200);
|
||||
const body = await archiveRes.json();
|
||||
expect(body.status).toBe('ARCHIVED');
|
||||
});
|
||||
|
||||
test('TC-REC-06: Rezepte nach Status filtern', async ({ request, adminToken }) => {
|
||||
const res = await request.get('/api/recipes?status=DRAFT', {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
const body = await res.json();
|
||||
const list = Array.isArray(body) ? body : body.content ?? [];
|
||||
expect(Array.isArray(list)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
@ -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