-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(medusa): Implement premises of the creation flow of an order edit (
#2187) **What** - Implements the admin create end point - Service implementation of the create method and the retrieveActive as well as the totals computation - Improve compute line items - client - medusa-js api - medusa-react mutations hooks **Tests** - Unit tests of the create end points - Unit tests of the service create method - Integration tests for admin that also take into account totals computations - client - medusa-js tests - medusa-react hooks tests FIXES CORE-491
- Loading branch information
Showing
20 changed files
with
742 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 19 additions & 1 deletion
20
packages/medusa-react/src/hooks/admin/order-edits/mutations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/medusa/src/api/routes/admin/order-edits/__tests__/create-order-edit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { IdMap } from "medusa-test-utils" | ||
import { request } from "../../../../../helpers/test-request" | ||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit" | ||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing" | ||
|
||
describe("POST /admin/order-edits", () => { | ||
describe("successfully create an order edit", () => { | ||
const orderId = IdMap.getId("order-edit-order-id-test") | ||
const internalNote = "test internal note" | ||
let subject | ||
|
||
beforeAll(async () => { | ||
subject = await request("POST", "/admin/order-edits", { | ||
payload: { | ||
order_id: orderId, | ||
internal_note: internalNote, | ||
}, | ||
adminSession: { | ||
jwt: { | ||
userId: IdMap.getId("admin_user"), | ||
}, | ||
}, | ||
flags: [OrderEditingFeatureFlag], | ||
}) | ||
}) | ||
|
||
afterAll(async () => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it("returns 200", () => { | ||
expect(subject.status).toEqual(200) | ||
}) | ||
|
||
it("calls order edit service create", () => { | ||
expect(orderEditServiceMock.create).toHaveBeenCalledTimes(1) | ||
expect(orderEditServiceMock.create).toHaveBeenCalledWith( | ||
{ | ||
order_id: orderId, | ||
internal_note: internalNote, | ||
}, | ||
{ | ||
loggedInUserId: IdMap.getId("admin_user"), | ||
} | ||
) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.