1 import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
2 import {
3 createAdminUser,
4 adminHeaders,
5 } from "../../../../helpers/create-admin-user"
6
7 jest.setTimeout(30000)
8
9 medusaIntegrationTestRunner({
10 env: {},
11 testSuite: ({ dbConnection, getContainer, api, dbUtils }) => {
12 beforeAll(async () => {
13 const container = getContainer()
14 await createAdminUser(dbConnection, adminHeaders, container)
15
16 await dbUtils.snapshot()
17 })
18
19 // TODO: Currently we don't have these endpoints, enable tests once they are added.
20 describe("/admin/payment-collections", () => {
21 it("lists payment collections", async () => {})
22 })
23 // describe("/admin/payment-collections/:id", () => {
24 // it("gets payment collection", async () => {
25 // const response = await api.get(
26 // `/admin/payment-collections/${paymentCollection.id}`,
27 // adminHeaders
28 // )
29
30 // expect(response.data.payment_collection).toEqual(
31 // expect.objectContaining({
32 // id: paymentCollection.id,
33 // type: "order_edit",
34 // status: "not_paid",
35 // description: "paycol description",
36 // amount: 10000,
37 // })
38 // )
39
40 // expect(response.status).toEqual(200)
41 // })
42
43 // it("updates a payment collection", async () => {
44 // const response = await api.post(
45 // `/admin/payment-collections/${paymentCollection.id}`,
46 // {
47 // description: "new description",
48 // metadata: {
49 // a: 1,
50 // b: [1, 2, "3"],
51 // },
52 // },
53 // adminHeaders
54 // )
55
56 // expect(response.status).toEqual(200)
57 // expect(response.data.payment_collection).toEqual(
58 // expect.objectContaining({
59 // id: paymentCollection.id,
60 // type: "order_edit",
61 // amount: 10000,
62 // description: "new description",
63 // metadata: {
64 // a: 1,
65 // b: [1, 2, "3"],
66 // },
67 // authorized_amount: null,
68 // })
69 // )
70 // })
71
72 // it("marks a payment collection as authorized", async () => {
73 // const response = await api.post(
74 // `/admin/payment-collections/${paymentCollection.id}/authorize`,
75 // undefined,
76 // adminHeaders
77 // )
78
79 // expect(response.data.payment_collection).toEqual(
80 // expect.objectContaining({
81 // id: paymentCollection.id,
82 // type: "order_edit",
83 // status: "authorized",
84 // description: "paycol description",
85 // amount: 10000,
86 // authorized_amount: 10000,
87 // })
88 // )
89
90 // expect(response.status).toEqual(200)
91 // })
92
93 // it("delete a payment collection", async () => {
94 // const response = await api.delete(
95 // `/admin/payment-collections/${paymentCollection.id}`,
96 // adminHeaders
97 // )
98
99 // expect(response.data).toEqual({
100 // id: paymentCollection.id,
101 // deleted: true,
102 // object: "payment_collection",
103 // })
104
105 // expect(response.status).toEqual(200)
106 // })
107
108 // it("throws error when deleting an authorized payment collection", async () => {
109 // await api.post(
110 // `/admin/payment-collections/${paymentCollection.id}/authorize`,
111 // undefined,
112 // adminHeaders
113 // )
114
115 // try {
116 // await api.delete(
117 // `/admin/payment-collections/${paymentCollection.id}`,
118 // adminHeaders
119 // )
120
121 // expect(1).toBe(2) // should be ignored
122 // } catch (res) {
123 // expect(res.response.data.message).toBe(
124 // "Cannot delete payment collection with status authorized"
125 // )
126 // }
127 // })
128 // })
129 },
130 })