mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 15:29:34 +01:00
phase 2
This commit is contained in:
parent
e897f41a32
commit
061c2b4f8d
14 changed files with 1293 additions and 18 deletions
116
test-automation/web-ui/tests/api/masterdata/articles.spec.ts
Normal file
116
test-automation/web-ui/tests/api/masterdata/articles.spec.ts
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-ART – Artikel
|
||||
* Quelle: GitHub Issue #64
|
||||
*/
|
||||
test.describe('TC-ART: Artikel', () => {
|
||||
async function createCategory(request: Parameters<typeof test>[1]['request'], token: string): Promise<string> {
|
||||
const res = await request.post('/api/categories', {
|
||||
data: { name: `ART-Kat-${Date.now()}` },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const body = await res.json();
|
||||
return body.id;
|
||||
}
|
||||
|
||||
test('TC-ART-01: Artikel erstellen – Pflichtfelder', async ({ request, adminToken }) => {
|
||||
const categoryId = await createCategory(request, adminToken);
|
||||
const res = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `Weizenbrot-${Date.now()}`,
|
||||
articleNumber: `ART-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'PIECE_FIXED',
|
||||
priceModel: 'FIXED',
|
||||
price: 2.99,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
const body = await res.json();
|
||||
expect(body.status).toBe('ACTIVE');
|
||||
});
|
||||
|
||||
test('TC-ART-02: Artikel erscheint in Liste nach Erstellung', async ({ request, adminToken }) => {
|
||||
const categoryId = await createCategory(request, adminToken);
|
||||
const name = `ListArt-${Date.now()}`;
|
||||
const articleNumber = `ART-LIST-${Date.now()}`;
|
||||
await request.post('/api/articles', {
|
||||
data: { name, articleNumber, categoryId, unit: 'KG', priceModel: 'FIXED', price: 5.0 },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
const res = await request.get('/api/articles', {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
const body = await res.json();
|
||||
const list = Array.isArray(body) ? body : body.content ?? [];
|
||||
expect(list.some((a: { name: string }) => a.name === name)).toBe(true);
|
||||
});
|
||||
|
||||
test('TC-ART-03: Artikel ohne Name wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const categoryId = await createCategory(request, adminToken);
|
||||
const res = await request.post('/api/articles', {
|
||||
data: { articleNumber: `ART-${Date.now()}`, categoryId, unit: 'KG', priceModel: 'FIXED', price: 1.0 },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-ART-04: Artikel ohne Artikelnummer wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const categoryId = await createCategory(request, adminToken);
|
||||
const res = await request.post('/api/articles', {
|
||||
data: { name: `NoNumber-${Date.now()}`, categoryId, unit: 'KG', priceModel: 'FIXED', price: 1.0 },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-ART-05: Artikel deaktivieren', async ({ request, adminToken }) => {
|
||||
const categoryId = await createCategory(request, adminToken);
|
||||
const createRes = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `Deact-${Date.now()}`,
|
||||
articleNumber: `ART-DEACT-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'PIECE_FIXED',
|
||||
priceModel: 'FIXED',
|
||||
price: 1.5,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id } = await createRes.json();
|
||||
|
||||
const deactRes = await request.post(`/api/articles/${id}/deactivate`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(deactRes.status()).toBe(200);
|
||||
const body = await deactRes.json();
|
||||
expect(body.status).toBe('INACTIVE');
|
||||
});
|
||||
|
||||
test('TC-ART-06: Verkaufseinheit hinzufügen', async ({ request, adminToken }) => {
|
||||
const categoryId = await createCategory(request, adminToken);
|
||||
const createRes = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `SalesUnit-${Date.now()}`,
|
||||
articleNumber: `ART-SU-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'KG',
|
||||
priceModel: 'FIXED',
|
||||
price: 3.0,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id } = await createRes.json();
|
||||
|
||||
const suRes = await request.post(`/api/articles/${id}/sales-units`, {
|
||||
data: { unit: 'HUNDRED_GRAM', priceModel: 'FIXED', price: 0.3 },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(suRes.status()).toBe(201);
|
||||
});
|
||||
});
|
||||
|
|
@ -6,7 +6,7 @@ import { test, expect } from '../../../fixtures/auth.fixture.js';
|
|||
*/
|
||||
test.describe('TC-CAT: Produktkategorien', () => {
|
||||
test('TC-CAT-01: Kategorie erstellen – Happy Path', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/product-categories', {
|
||||
const res = await request.post('/api/categories', {
|
||||
data: { name: 'Obst & Gemüse', description: 'Frische Produkte' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
|
|
@ -17,7 +17,7 @@ test.describe('TC-CAT: Produktkategorien', () => {
|
|||
});
|
||||
|
||||
test('TC-CAT-02: Kategorie erstellen – ohne Beschreibung', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/product-categories', {
|
||||
const res = await request.post('/api/categories', {
|
||||
data: { name: `Milchprodukte-${Date.now()}` },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
|
|
@ -26,11 +26,11 @@ test.describe('TC-CAT: Produktkategorien', () => {
|
|||
|
||||
test('TC-CAT-04: Doppelter Name wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const name = `Duplikat-${Date.now()}`;
|
||||
await request.post('/api/product-categories', {
|
||||
await request.post('/api/categories', {
|
||||
data: { name },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
const res = await request.post('/api/product-categories', {
|
||||
const res = await request.post('/api/categories', {
|
||||
data: { name },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
|
|
@ -38,7 +38,7 @@ test.describe('TC-CAT: Produktkategorien', () => {
|
|||
});
|
||||
|
||||
test('TC-CAT-06: Leerer Name wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/product-categories', {
|
||||
const res = await request.post('/api/categories', {
|
||||
data: { name: '' },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-B2B – Rahmenverträge (Frame Contracts)
|
||||
* Quelle: GitHub Issue #66
|
||||
*/
|
||||
test.describe('TC-B2B: Rahmenverträge', () => {
|
||||
const baseAddress = {
|
||||
street: 'Handelsweg',
|
||||
houseNumber: '10',
|
||||
postalCode: '20095',
|
||||
city: 'Hamburg',
|
||||
country: 'DE',
|
||||
phone: '+49 40 99999',
|
||||
};
|
||||
|
||||
async function createB2bCustomer(request: Parameters<typeof test>[1]['request'], token: string): Promise<string> {
|
||||
const res = await request.post('/api/customers', {
|
||||
data: { name: `B2B-${Date.now()}`, type: 'B2B', ...baseAddress, paymentDueDays: 30 },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const body = await res.json();
|
||||
return body.id;
|
||||
}
|
||||
|
||||
async function createArticleWithCategory(request: Parameters<typeof test>[1]['request'], token: string): Promise<string> {
|
||||
const catRes = await request.post('/api/categories', {
|
||||
data: { name: `B2B-Kat-${Date.now()}` },
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id: categoryId } = await catRes.json();
|
||||
const artRes = await request.post('/api/articles', {
|
||||
data: {
|
||||
name: `B2B-Art-${Date.now()}`,
|
||||
articleNumber: `B2B-${Date.now()}`,
|
||||
categoryId,
|
||||
unit: 'KG',
|
||||
priceModel: 'FIXED',
|
||||
price: 4.5,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
const { id } = await artRes.json();
|
||||
return id;
|
||||
}
|
||||
|
||||
test('TC-B2B-01: Rahmenvertrag setzen', async ({ request, adminToken }) => {
|
||||
const customerId = await createB2bCustomer(request, adminToken);
|
||||
const articleId = await createArticleWithCategory(request, adminToken);
|
||||
|
||||
const res = await request.put(`/api/customers/${customerId}/frame-contract`, {
|
||||
data: {
|
||||
validFrom: '2026-01-01',
|
||||
validUntil: '2026-12-31',
|
||||
rhythm: 'WEEKLY',
|
||||
lineItems: [{ articleId, agreedPrice: 4.0, agreedQuantity: 10.0, unit: 'KG' }],
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
const body = await res.json();
|
||||
expect(body.frameContract).toBeTruthy();
|
||||
});
|
||||
|
||||
test('TC-B2B-02: Rahmenvertrag ohne Positionen wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const customerId = await createB2bCustomer(request, adminToken);
|
||||
|
||||
const res = await request.put(`/api/customers/${customerId}/frame-contract`, {
|
||||
data: { rhythm: 'WEEKLY', lineItems: [] },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-B2B-03: Rahmenvertrag entfernen', async ({ request, adminToken }) => {
|
||||
const customerId = await createB2bCustomer(request, adminToken);
|
||||
const articleId = await createArticleWithCategory(request, adminToken);
|
||||
|
||||
await request.put(`/api/customers/${customerId}/frame-contract`, {
|
||||
data: {
|
||||
rhythm: 'MONTHLY',
|
||||
lineItems: [{ articleId, agreedPrice: 3.0 }],
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
|
||||
const res = await request.delete(`/api/customers/${customerId}/frame-contract`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(204);
|
||||
});
|
||||
});
|
||||
119
test-automation/web-ui/tests/api/masterdata/customers.spec.ts
Normal file
119
test-automation/web-ui/tests/api/masterdata/customers.spec.ts
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
import { test, expect } from '../../../fixtures/auth.fixture.js';
|
||||
|
||||
/**
|
||||
* TC-CUS – Kunden
|
||||
* Quelle: GitHub Issue #65
|
||||
*/
|
||||
test.describe('TC-CUS: Kunden', () => {
|
||||
const baseAddress = {
|
||||
street: 'Musterstraße',
|
||||
houseNumber: '1',
|
||||
postalCode: '10115',
|
||||
city: 'Berlin',
|
||||
country: 'DE',
|
||||
phone: '+49 30 12345',
|
||||
};
|
||||
|
||||
test('TC-CUS-01: Kunde erstellen – Pflichtfelder (B2C)', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/customers', {
|
||||
data: { name: `Müller ${Date.now()}`, type: 'B2C', ...baseAddress },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
const body = await res.json();
|
||||
expect(body.status).toBe('ACTIVE');
|
||||
expect(body.type).toBe('B2C');
|
||||
});
|
||||
|
||||
test('TC-CUS-02: B2B-Kunde erstellen', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/customers', {
|
||||
data: {
|
||||
name: `B2B GmbH ${Date.now()}`,
|
||||
type: 'B2B',
|
||||
...baseAddress,
|
||||
contactPerson: 'Max Mustermann',
|
||||
paymentDueDays: 30,
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(201);
|
||||
const body = await res.json();
|
||||
expect(body.type).toBe('B2B');
|
||||
});
|
||||
|
||||
test('TC-CUS-03: Kunde erscheint in Liste nach Erstellung', async ({ request, adminToken }) => {
|
||||
const name = `ListKunde-${Date.now()}`;
|
||||
await request.post('/api/customers', {
|
||||
data: { name, type: 'B2C', ...baseAddress },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
const res = await request.get('/api/customers', {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(200);
|
||||
const body = await res.json();
|
||||
const list = Array.isArray(body) ? body : body.content ?? [];
|
||||
expect(list.some((c: { name: string }) => c.name === name)).toBe(true);
|
||||
});
|
||||
|
||||
test('TC-CUS-04: Kunde ohne Name wird abgelehnt', async ({ request, adminToken }) => {
|
||||
const res = await request.post('/api/customers', {
|
||||
data: { type: 'B2C', ...baseAddress },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(res.status()).toBe(400);
|
||||
});
|
||||
|
||||
test('TC-CUS-05: Lieferadresse hinzufügen', async ({ request, adminToken }) => {
|
||||
const createRes = await request.post('/api/customers', {
|
||||
data: { name: `DelivAddr-${Date.now()}`, type: 'B2C', ...baseAddress },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id } = await createRes.json();
|
||||
|
||||
const addrRes = await request.post(`/api/customers/${id}/delivery-addresses`, {
|
||||
data: {
|
||||
label: 'Lager',
|
||||
street: 'Lagerstraße',
|
||||
houseNumber: '5',
|
||||
postalCode: '10117',
|
||||
city: 'Berlin',
|
||||
country: 'DE',
|
||||
},
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(addrRes.status()).toBe(201);
|
||||
});
|
||||
|
||||
test('TC-CUS-06: Kunde deaktivieren', async ({ request, adminToken }) => {
|
||||
const createRes = await request.post('/api/customers', {
|
||||
data: { name: `Deact-${Date.now()}`, type: 'B2C', ...baseAddress },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id } = await createRes.json();
|
||||
|
||||
const deactRes = await request.post(`/api/customers/${id}/deactivate`, {
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(deactRes.status()).toBe(200);
|
||||
const body = await deactRes.json();
|
||||
expect(body.status).toBe('INACTIVE');
|
||||
});
|
||||
|
||||
test('TC-CUS-07: Präferenzen setzen', async ({ request, adminToken }) => {
|
||||
const createRes = await request.post('/api/customers', {
|
||||
data: { name: `Prefs-${Date.now()}`, type: 'B2C', ...baseAddress },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(createRes.status()).toBe(201);
|
||||
const { id } = await createRes.json();
|
||||
|
||||
const prefsRes = await request.put(`/api/customers/${id}/preferences`, {
|
||||
data: { preferences: ['BIO', 'REGIONAL'] },
|
||||
headers: { Authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
expect(prefsRes.status()).toBe(200);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue