feat(medusa): cart context (#201)

- Adds a context field to Cart
- context is automatically populated with ip + user agent
- context can be updated via POST /store/cart/:id or set when creating via POST /store/cart
This commit is contained in:
Sebastian Rindom
2021-03-12 11:48:51 +01:00
committed by GitHub
parent a031f1f338
commit dd7b306333
20 changed files with 3499 additions and 657 deletions

View File

@@ -72,6 +72,26 @@ describe("/store/carts", () => {
const getRes = await api.post(`/store/carts/${response.data.cart.id}`);
expect(getRes.status).toEqual(200);
});
it("creates a cart with context", async () => {
const api = useApi();
const response = await api.post("/store/carts", {
context: {
test_id: "test",
},
});
expect(response.status).toEqual(200);
const getRes = await api.post(`/store/carts/${response.data.cart.id}`);
expect(getRes.status).toEqual(200);
const cart = getRes.data.cart;
expect(cart.context).toEqual({
ip: "::ffff:127.0.0.1",
user_agent: "axios/0.21.1",
test_id: "test",
});
});
});
describe("POST /store/carts/:id", () => {