mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 10:09:35 +01:00
73 lines
2.9 KiB
TypeScript
73 lines
2.9 KiB
TypeScript
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');
|
||
});
|
||
});
|