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
|
|
@ -0,0 +1,73 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-INV – Inventurzählungen
|
||||
* Quelle: GitHub Issues #4–#20
|
||||
*/
|
||||
test.describe('TC-INV: Inventurzählungen', () => {
|
||||
async function createStorageLocation(request: Parameters<typeof test>[1]['request'], token: string): Promise<string> {
|
||||
const res = await request.post('/api/inventory/storage-locations', {
|
||||
data: { name: `INV-Lager-${Date.now()}`, storageType: 'DRY_STORAGE' },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const body = await res.json();
|
||||
return body.id;
|
||||
}
|
||||
|
||||
test('TC-INV-01: Inventurzählung anlegen', async ({ request, adminToken }) => {
|
||||
const storageLocationId = await createStorageLocation(request, adminToken);
|
||||
|
||||
const res = await request.post('/api/inventory/inventory-counts', {
|
||||
data: { storageLocationId, countDate: '2026-04-30' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
const body = await res.json();
|
||||
expect(body.status).toBe('PLANNED');
|
||||
});
|
||||
|
||||
test('TC-INV-02: Inventurzählung ohne Lagerort wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/inventory/inventory-counts', {
|
||||
data: { countDate: '2026-04-30' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-INV-03: Inventurzählung starten', async ({ request, adminToken }) => {
|
||||
const storageLocationId = await createStorageLocation(request, adminToken);
|
||||
|
||||
const createRes = await request.post('/api/inventory/inventory-counts', {
|
||||
data: { storageLocationId, countDate: '2026-05-01' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id } = await createRes.json();
|
||||
|
||||
const startRes = await request.patch(`/api/inventory/inventory-counts/${id}/start`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(startRes.status()).toBe(200);
|
||||
const body = await startRes.json();
|
||||
expect(body.status).toBe('IN_PROGRESS');
|
||||
});
|
||||
|
||||
test('TC-INV-04: Inventurzählung stornieren', async ({ request, adminToken }) => {
|
||||
const storageLocationId = await createStorageLocation(request, adminToken);
|
||||
|
||||
const createRes = await request.post('/api/inventory/inventory-counts', {
|
||||
data: { storageLocationId, countDate: '2026-05-02' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id } = await createRes.json();
|
||||
|
||||
const cancelRes = await request.post(`/api/inventory/inventory-counts/${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');
|
||||
});
|
||||
});
|
||||
99
test-automation/web-ui/tests/api/inventory/movements.spec.ts
Normal file
99
test-automation/web-ui/tests/api/inventory/movements.spec.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
119
test-automation/web-ui/tests/api/inventory/reservations.spec.ts
Normal file
119
test-automation/web-ui/tests/api/inventory/reservations.spec.ts
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-RES – Lagerreservierungen
|
||||
* Quelle: GitHub Issues #4–#20
|
||||
*/
|
||||
test.describe('TC-RES: Lagerreservierungen', () => {
|
||||
async function setupStock(
|
||||
request: Parameters<typeof test>[1]['request'],
|
||||
token: string,
|
||||
): Promise<{ stockId: string }> {
|
||||
const catRes = await request.post('/api/categories', {
|
||||
data: { name: `RES-Kat-${Date.now()}` },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: categoryId } = await catRes.json();
|
||||
|
||||
const artRes = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `RES-Art-${Date.now()}`,
|
||||
articleNumber: `RES-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'KG',
|
||||
priceModel: 'FIXED',
|
||||
price: 2.0,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: articleId } = await artRes.json();
|
||||
|
||||
const locRes = await request.post('/api/inventory/storage-locations', {
|
||||
data: { name: `RES-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();
|
||||
|
||||
await request.post(`/api/inventory/stocks/${stockId}/batches`, {
|
||||
data: {
|
||||
batchId: `RES-B-${Date.now()}`,
|
||||
batchType: 'PURCHASED',
|
||||
quantityAmount: '100',
|
||||
quantityUnit: 'KG',
|
||||
expiryDate: '2027-06-30',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
return { stockId };
|
||||
}
|
||||
|
||||
test('TC-RES-01: Reservierung anlegen', async ({ request, adminToken }) => {
|
||||
const { stockId } = await setupStock(request, adminToken);
|
||||
|
||||
const res = await request.post(`/api/inventory/stocks/${stockId}/reservations`, {
|
||||
data: {
|
||||
referenceType: 'PRODUCTION_ORDER',
|
||||
referenceId: `PO-${Date.now()}`,
|
||||
quantityAmount: '10',
|
||||
quantityUnit: 'KG',
|
||||
priority: 'NORMAL',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
const body = await res.json();
|
||||
expect(body.id).toBeTruthy();
|
||||
});
|
||||
|
||||
test('TC-RES-02: Reservierung freigeben', async ({ request, adminToken }) => {
|
||||
const { stockId } = await setupStock(request, adminToken);
|
||||
|
||||
const createRes = await request.post(`/api/inventory/stocks/${stockId}/reservations`, {
|
||||
data: {
|
||||
referenceType: 'PRODUCTION_ORDER',
|
||||
referenceId: `PO-REL-${Date.now()}`,
|
||||
quantityAmount: '5',
|
||||
quantityUnit: 'KG',
|
||||
priority: 'NORMAL',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id: reservationId } = await createRes.json();
|
||||
|
||||
const releaseRes = await request.delete(`/api/inventory/stocks/${stockId}/reservations/${reservationId}`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(releaseRes.status()).toBe(204);
|
||||
});
|
||||
|
||||
test('TC-RES-03: Reservierung bestätigen', async ({ request, adminToken }) => {
|
||||
const { stockId } = await setupStock(request, adminToken);
|
||||
|
||||
const createRes = await request.post(`/api/inventory/stocks/${stockId}/reservations`, {
|
||||
data: {
|
||||
referenceType: 'PRODUCTION_ORDER',
|
||||
referenceId: `PO-CONF-${Date.now()}`,
|
||||
quantityAmount: '8',
|
||||
quantityUnit: 'KG',
|
||||
priority: 'HIGH',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id: reservationId } = await createRes.json();
|
||||
|
||||
const confirmRes = await request.post(`/api/inventory/stocks/${stockId}/reservations/${reservationId}/confirm`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(confirmRes.status()).toBe(204);
|
||||
});
|
||||
});
|
||||
116
test-automation/web-ui/tests/api/inventory/stock.spec.ts
Normal file
116
test-automation/web-ui/tests/api/inventory/stock.spec.ts
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-STOCK – Lagerbestand
|
||||
* Quelle: GitHub Issues #4–#20
|
||||
*/
|
||||
test.describe('TC-STOCK: Lagerbestand', () => {
|
||||
async function createStorageLocation(request: Parameters<typeof test>[1]['request'], token: string): Promise<string> {
|
||||
const res = await request.post('/api/inventory/storage-locations', {
|
||||
data: { name: `Lager-${Date.now()}`, storageType: 'DRY_STORAGE' },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const body = await res.json();
|
||||
return body.id;
|
||||
}
|
||||
|
||||
async function createArticle(request: Parameters<typeof test>[1]['request'], token: string): Promise<string> {
|
||||
const catRes = await request.post('/api/categories', {
|
||||
data: { name: `ST-Kat-${Date.now()}` },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: categoryId } = await catRes.json();
|
||||
const artRes = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `ST-Art-${Date.now()}`,
|
||||
articleNumber: `ST-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'KG',
|
||||
priceModel: 'FIXED',
|
||||
price: 1.0,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id } = await artRes.json();
|
||||
return id;
|
||||
}
|
||||
|
||||
test('TC-STOCK-01: Lagerort erstellen', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/inventory/storage-locations', {
|
||||
data: { name: `Kühlraum-${Date.now()}`, storageType: 'COLD_ROOM', minTemperature: '2', maxTemperature: '8' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
const body = await res.json();
|
||||
expect(body.storageType).toBe('COLD_ROOM');
|
||||
});
|
||||
|
||||
test('TC-STOCK-02: Lagerort ohne Name wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/inventory/storage-locations', {
|
||||
data: { storageType: 'FREEZER' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-STOCK-03: Bestand anlegen', async ({ request, adminToken }) => {
|
||||
const storageLocationId = await createStorageLocation(request, adminToken);
|
||||
const articleId = await createArticle(request, adminToken);
|
||||
|
||||
const res = await request.post('/api/inventory/stocks', {
|
||||
data: { articleId, storageLocationId, minimumLevelAmount: '5', minimumLevelUnit: 'KG' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
});
|
||||
|
||||
test('TC-STOCK-04: Bestand ohne Artikel wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const storageLocationId = await createStorageLocation(request, adminToken);
|
||||
const res = await request.post('/api/inventory/stocks', {
|
||||
data: { storageLocationId },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-STOCK-05: Batch zum Bestand hinzufügen', async ({ request, adminToken }) => {
|
||||
const storageLocationId = await createStorageLocation(request, adminToken);
|
||||
const articleId = await createArticle(request, adminToken);
|
||||
|
||||
const stockRes = await request.post('/api/inventory/stocks', {
|
||||
data: { articleId, storageLocationId },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(stockRes.status()).toBe(201);
|
||||
const { id: stockId } = await stockRes.json();
|
||||
|
||||
const batchRes = await request.post(`/api/inventory/stocks/${stockId}/batches`, {
|
||||
data: {
|
||||
batchId: `BATCH-${Date.now()}`,
|
||||
batchType: 'PURCHASED',
|
||||
quantityAmount: '10',
|
||||
quantityUnit: 'KG',
|
||||
expiryDate: '2026-12-31',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(batchRes.status()).toBe(201);
|
||||
});
|
||||
|
||||
test('TC-STOCK-06: Bestände unterhalb Mindestmenge abfragen', async ({ request, adminToken }) => {
|
||||
const res = await request.get('/api/inventory/stocks/below-minimum', {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
expect(Array.isArray(await res.json())).toBe(true);
|
||||
});
|
||||
|
||||
test('TC-STOCK-07: Bestände nach Lagerort filtern', async ({ request, adminToken }) => {
|
||||
const storageLocationId = await createStorageLocation(request, adminToken);
|
||||
const res = await request.get(`/api/inventory/stocks?storageLocationId=${storageLocationId}`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
expect(Array.isArray(await res.json())).toBe(true);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue