Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add change shipment state action in order action #211

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/twelve-schools-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@labdigital/commercetools-mock": patch
---

Added missing test OrderChangeShipmentStateAction in order action
9 changes: 9 additions & 0 deletions src/repositories/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
OrderAddReturnInfoAction,
OrderChangeOrderStateAction,
OrderChangePaymentStateAction,
OrderChangeShipmentStateAction,
OrderSetBillingAddressAction,
OrderSetCustomFieldAction,
OrderSetCustomTypeAction,
Expand Down Expand Up @@ -117,6 +118,14 @@ export class OrderUpdateHandler
resource.paymentState = paymentState;
}

changeShipmentState(
context: RepositoryContext,
resource: Writable<Order>,
{ shipmentState }: OrderChangeShipmentStateAction,
) {
resource.shipmentState = shipmentState;
}

setBillingAddress(
context: RepositoryContext,
resource: Writable<Order>,
Expand Down
14 changes: 14 additions & 0 deletions src/services/order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,20 @@ describe("Order Update Actions", () => {
expect(response.body.paymentState).toBe("Failed");
});

test("changeShipmentState", async () => {
assert(order, "order not created");

const response = await supertest(ctMock.app)
.post(`/dummy/orders/${order.id}`)
.send({
version: 1,
actions: [{ action: "changeShipmentState", shipmentState: "Delayed" }],
});
expect(response.status).toBe(200);
expect(response.body.version).toBe(2);
expect(response.body.shipmentState).toBe("Delayed");
});

test("setDeliveryCustomField", async () => {
const order: Order = {
...getBaseResourceProperties(),
Expand Down