supplier_central_frontend/cypress/e2e/api.cy.ts
vickytechkey 789c6f6445
Some checks failed
Beta CI/CD Pipeline / build-and-test (push) Failing after 46s
Beta CI/CD Pipeline / deploy-beta (push) Has been skipped
updating the api base
2026-08-09 21:33:35 +05:30

62 lines
2.2 KiB
TypeScript

describe('Seller Central Django Backend API E2E Tests', () => {
const backendUrl = 'http://16.113.57.127:8080/api';
it('verifies product list', () => {
cy.request(`${backendUrl}/products/`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.be.an('array');
});
});
it('creates and deletes a product', () => {
const uniqueSku = `SKU-CY-${Date.now()}`;
cy.request('POST', `${backendUrl}/products/`, {
title: 'Cypress Test Silk Scarf',
category: 'Apparel',
price: '55.00',
stock: 20,
sku: uniqueSku
}).then((response) => {
expect(response.status).to.eq(201);
expect(response.body.sku).to.eq(uniqueSku);
const prodId = response.body.id;
// Delete the created product
cy.request('DELETE', `${backendUrl}/products/${prodId}/`).then((delRes) => {
expect(delRes.status).to.eq(204); // django rest framework delete returns 204 No Content
});
});
});
it('verifies order list and acceptance', () => {
cy.request(`${backendUrl}/orders/`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.be.an('array');
expect(response.body.length).to.be.greaterThan(0);
const pendingOrder = response.body.find((o: any) => o.status === 'Pending Acceptance');
if (pendingOrder) {
cy.request('POST', `${backendUrl}/orders/${pendingOrder.id}/accept/`).then((acceptRes) => {
expect(acceptRes.status).to.eq(200);
expect(acceptRes.body.status).to.eq('Ready to Ship');
});
}
});
});
it('verifies wallet summary and payout withdrawal', () => {
cy.request(`${backendUrl}/wallet/`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('outstanding');
expect(response.body).to.have.property('withdrawn');
const currentOutstanding = parseFloat(response.body.outstanding);
if (currentOutstanding > 10) {
cy.request('POST', `${backendUrl}/wallet/withdraw/`, { amount: '10.00' }).then((withdrawRes) => {
expect(withdrawRes.status).to.eq(200);
expect(parseFloat(withdrawRes.body.outstanding)).to.eq(currentOutstanding - 10);
});
}
});
});
});