This commit is contained in:
Lucas Tettamanti
2026-01-18 20:07:40 -03:00
parent 23c3d44490
commit 9754347a36
11 changed files with 1516 additions and 6 deletions

View File

@@ -184,4 +184,39 @@ export const api = {
async syncFromWoo() {
return fetch("/products/sync-from-woo", { method: "POST" }).then(r => r.json());
},
// --- Testing ---
async listRecentOrders({ limit = 20 } = {}) {
const u = new URL("/test/orders", location.origin);
u.searchParams.set("limit", String(limit));
return fetch(u).then(r => r.json());
},
async getProductsWithStock() {
return fetch("/test/products-with-stock").then(r => r.json());
},
async createTestOrder({ basket, address, wa_chat_id }) {
return fetch("/test/order", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ basket, address, wa_chat_id }),
}).then(r => r.json());
},
async createPaymentLink({ woo_order_id, amount }) {
return fetch("/test/payment-link", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ woo_order_id, amount }),
}).then(r => r.json());
},
async simulateMpWebhook({ woo_order_id, amount }) {
return fetch("/test/simulate-webhook", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ woo_order_id, amount }),
}).then(r => r.json());
},
};