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:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user