mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 17:04:49 +01:00
phase 2
This commit is contained in:
parent
e897f41a32
commit
061c2b4f8d
14 changed files with 1293 additions and 18 deletions
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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue