Skip to content

Commit 7b50ed1

Browse files
authored
Merge branch 'develop' into fix/with-deleted-detection
2 parents 27b1619 + 9d61bb7 commit 7b50ed1

224 files changed

Lines changed: 25317 additions & 4354 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/blue-bags-grin.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"integration-tests-http": patch
3+
"@medusajs/types": patch
4+
"@medusajs/medusa": patch
5+
---
6+
7+
Enable filtering admin products API by variant EAN, UPC, and barcode

.changeset/bright-guests-speak.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@medusajs/payment": patch
3+
"@medusajs/utils": patch
4+
---
5+
6+
fix(payment): round currency decimal precision

.changeset/sixty-years-invite.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@medusajs/workflow-engine-inmemory": patch
3+
"@medusajs/workflow-engine-redis": patch
4+
"@medusajs/orchestration": patch
5+
"@medusajs/utils": patch
6+
---
7+
8+
fix(workflow-engine-*): Cleanup expired executions

integration-tests/http/__tests__/order/admin/order.spec.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,69 @@ medusaIntegrationTestRunner({
6666
expect(response.data.orders).toHaveLength(0)
6767
expect(response.data.orders).toEqual([])
6868
})
69+
70+
it("should search orders by shipping address", async () => {
71+
let response = await api.get(`/admin/orders?fields=+shipping_address.address_1,+shipping_address.address_2`, adminHeaders)
72+
73+
expect(response.data.orders).toHaveLength(1)
74+
expect(response.data.orders).toEqual([
75+
expect.objectContaining({
76+
id: order.id,
77+
}),
78+
])
79+
80+
response = await api.get(`/admin/orders?fields=+shipping_address.address_1,+shipping_address.address_2&q=${order.shipping_address.address_1}`, adminHeaders)
81+
82+
expect(response.data.orders).toHaveLength(1)
83+
expect(response.data.orders).toEqual([
84+
expect.objectContaining({
85+
id: order.id,
86+
}),
87+
])
88+
89+
response = await api.get(`/admin/orders?q=${order.shipping_address.address_2}`, adminHeaders)
90+
91+
expect(response.data.orders).toHaveLength(1)
92+
expect(response.data.orders).toEqual([
93+
expect.objectContaining({
94+
id: order.id,
95+
}),
96+
])
97+
98+
response = await api.get(`/admin/orders?q=does-not-exist`, adminHeaders)
99+
100+
expect(response.data.orders).toHaveLength(0)
101+
expect(response.data.orders).toEqual([])
102+
})
103+
104+
it("should search orders by billing address", async () => {
105+
let response = await api.get(`/admin/orders?fields=+billing_address.address_1,+billing_address.address_2`, adminHeaders)
106+
107+
expect(response.data.orders).toHaveLength(1)
108+
expect(response.data.orders).toEqual([
109+
expect.objectContaining({
110+
id: order.id,
111+
}),
112+
])
113+
114+
response = await api.get(`/admin/orders?fields=+billing_address.address_1,+billing_address.address_2&q=${order.billing_address.address_1}`, adminHeaders)
115+
116+
expect(response.data.orders).toHaveLength(1)
117+
expect(response.data.orders).toEqual([
118+
expect.objectContaining({
119+
id: order.id,
120+
}),
121+
])
122+
123+
response = await api.get(`/admin/orders?q=${order.billing_address.address_2}`, adminHeaders)
124+
125+
expect(response.data.orders).toHaveLength(1)
126+
expect(response.data.orders).toEqual([
127+
expect.objectContaining({
128+
id: order.id,
129+
}),
130+
])
131+
})
69132
})
70133

71134
describe("POST /orders/:id", () => {

integration-tests/http/__tests__/product/admin/product.spec.ts

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,231 @@ medusaIntegrationTestRunner({
952952
}),
953953
])
954954
})
955+
956+
it("returns a list of products filtered by variants[ean]", async () => {
957+
const productWithEan = await api.post(
958+
"/admin/products",
959+
getProductFixture({
960+
title: "Product with EAN",
961+
shipping_profile_id: shippingProfile.id,
962+
variants: [
963+
{
964+
title: "Test variant",
965+
ean: "1234567890123",
966+
prices: [{ currency_code: "usd", amount: 100 }],
967+
options: {
968+
size: "large",
969+
color: "green",
970+
},
971+
},
972+
],
973+
}),
974+
adminHeaders
975+
)
976+
977+
await api.post(
978+
"/admin/products",
979+
getProductFixture({
980+
title: "Product with different EAN",
981+
shipping_profile_id: shippingProfile.id,
982+
variants: [
983+
{
984+
title: "Test variant 2",
985+
ean: "9876543210987",
986+
prices: [{ currency_code: "usd", amount: 150 }],
987+
options: {
988+
size: "large",
989+
color: "green",
990+
},
991+
},
992+
],
993+
}),
994+
adminHeaders
995+
)
996+
997+
const response = await api
998+
.get("/admin/products?variants[ean]=1234567890123", adminHeaders)
999+
.catch((err) => {
1000+
console.log(err)
1001+
})
1002+
1003+
expect(response.status).toEqual(200)
1004+
expect(response.data.products).toHaveLength(1)
1005+
expect(response.data.products).toEqual(
1006+
expect.arrayContaining([
1007+
expect.objectContaining({
1008+
id: productWithEan.data.product.id,
1009+
title: "Product with EAN",
1010+
variants: expect.arrayContaining([
1011+
expect.objectContaining({
1012+
ean: "1234567890123",
1013+
}),
1014+
]),
1015+
}),
1016+
])
1017+
)
1018+
})
1019+
1020+
it("returns a list of products filtered by variants[upc]", async () => {
1021+
const productWithUpc = await api.post(
1022+
"/admin/products",
1023+
getProductFixture({
1024+
title: "Product with UPC",
1025+
shipping_profile_id: shippingProfile.id,
1026+
variants: [
1027+
{
1028+
title: "Test variant",
1029+
upc: "123456789012",
1030+
prices: [{ currency_code: "usd", amount: 200 }],
1031+
options: {
1032+
size: "large",
1033+
color: "green",
1034+
},
1035+
},
1036+
],
1037+
}),
1038+
adminHeaders
1039+
)
1040+
1041+
await api.post(
1042+
"/admin/products",
1043+
getProductFixture({
1044+
title: "Product with different UPC",
1045+
shipping_profile_id: shippingProfile.id,
1046+
variants: [
1047+
{
1048+
title: "Test variant 2",
1049+
upc: "098765432109",
1050+
prices: [{ currency_code: "usd", amount: 250 }],
1051+
options: {
1052+
size: "large",
1053+
color: "green",
1054+
},
1055+
},
1056+
],
1057+
}),
1058+
adminHeaders
1059+
)
1060+
1061+
const response = await api
1062+
.get("/admin/products?variants[upc]=123456789012", adminHeaders)
1063+
.catch((err) => {
1064+
console.log(err)
1065+
})
1066+
1067+
expect(response.status).toEqual(200)
1068+
expect(response.data.products).toHaveLength(1)
1069+
expect(response.data.products).toEqual(
1070+
expect.arrayContaining([
1071+
expect.objectContaining({
1072+
id: productWithUpc.data.product.id,
1073+
title: "Product with UPC",
1074+
variants: expect.arrayContaining([
1075+
expect.objectContaining({
1076+
upc: "123456789012",
1077+
}),
1078+
]),
1079+
}),
1080+
])
1081+
)
1082+
})
1083+
1084+
it("returns a list of products filtered by variants[barcode]", async () => {
1085+
const productWithBarcode = await api.post(
1086+
"/admin/products",
1087+
getProductFixture({
1088+
title: "Product with Barcode",
1089+
shipping_profile_id: shippingProfile.id,
1090+
variants: [
1091+
{
1092+
title: "Test variant",
1093+
barcode: "1234567890",
1094+
prices: [{ currency_code: "usd", amount: 300 }],
1095+
options: {
1096+
size: "large",
1097+
color: "green",
1098+
},
1099+
},
1100+
],
1101+
}),
1102+
adminHeaders
1103+
)
1104+
1105+
await api.post(
1106+
"/admin/products",
1107+
getProductFixture({
1108+
title: "Product with different Barcode",
1109+
shipping_profile_id: shippingProfile.id,
1110+
variants: [
1111+
{
1112+
title: "Test variant 2",
1113+
barcode: "0987654321",
1114+
prices: [{ currency_code: "usd", amount: 350 }],
1115+
options: {
1116+
size: "large",
1117+
color: "green",
1118+
},
1119+
},
1120+
],
1121+
}),
1122+
adminHeaders
1123+
)
1124+
1125+
const response = await api
1126+
.get("/admin/products?variants[barcode]=1234567890", adminHeaders)
1127+
.catch((err) => {
1128+
console.log(err)
1129+
})
1130+
1131+
expect(response.status).toEqual(200)
1132+
expect(response.data.products).toHaveLength(1)
1133+
expect(response.data.products).toEqual(
1134+
expect.arrayContaining([
1135+
expect.objectContaining({
1136+
id: productWithBarcode.data.product.id,
1137+
title: "Product with Barcode",
1138+
variants: expect.arrayContaining([
1139+
expect.objectContaining({
1140+
barcode: "1234567890",
1141+
}),
1142+
]),
1143+
}),
1144+
])
1145+
)
1146+
})
1147+
1148+
it("returns empty list when filtering by non-existent variants[ean]", async () => {
1149+
const response = await api
1150+
.get("/admin/products?variants[ean]=5555555555555", adminHeaders)
1151+
.catch((err) => {
1152+
console.log(err)
1153+
})
1154+
1155+
expect(response.status).toEqual(200)
1156+
expect(response.data.products).toHaveLength(0)
1157+
})
1158+
1159+
it("returns empty list when filtering by non-existent variants[upc]", async () => {
1160+
const response = await api
1161+
.get("/admin/products?variants[upc]=555555555555", adminHeaders)
1162+
.catch((err) => {
1163+
console.log(err)
1164+
})
1165+
1166+
expect(response.status).toEqual(200)
1167+
expect(response.data.products).toHaveLength(0)
1168+
})
1169+
1170+
it("returns empty list when filtering by non-existent variants[barcode]", async () => {
1171+
const response = await api
1172+
.get("/admin/products?variants[barcode]=5555555555", adminHeaders)
1173+
.catch((err) => {
1174+
console.log(err)
1175+
})
1176+
1177+
expect(response.status).toEqual(200)
1178+
expect(response.data.products).toHaveLength(0)
1179+
})
9551180
})
9561181

9571182
describe("GET /admin/products/:id", () => {

integration-tests/http/__tests__/product/store/product.spec.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -788,31 +788,33 @@ medusaIntegrationTestRunner({
788788

789789
// TODO: This doesn't work currently, but worked in v1
790790
it.skip("returns a list of ordered products by variants title DESC", async () => {
791+
})
792+
793+
it("returns a list of ordered products by variant title ASC", async () => {
791794
const response = await api.get(
792-
"/store/products?order=-variants.title",
795+
"/store/products?order=variants.title",
793796
storeHeaders
794797
)
795798

796799
expect(response.status).toEqual(200)
797-
expect(response.data.products).toEqual([
798-
expect.objectContaining({ id: product3.id }),
799-
expect.objectContaining({ id: product2.id }),
800-
expect.objectContaining({ id: product.id }),
800+
expect(response.data.products.map((p) => p.id)).toEqual([
801+
product.id,
802+
product2.id,
803+
product3.id,
801804
])
802805
})
803806

804-
// TODO: This doesn't work currently, but worked in v1
805-
it.skip("returns a list of ordered products by variants title ASC", async () => {
807+
it("returns a list of ordered products by variant title DESC", async () => {
806808
const response = await api.get(
807-
"/store/products?order=variants.title",
809+
"/store/products?order=-variants.title",
808810
storeHeaders
809811
)
810812

811813
expect(response.status).toEqual(200)
812-
expect(response.data.products).toEqual([
813-
expect.objectContaining({ id: product3.id }),
814-
expect.objectContaining({ id: product2.id }),
815-
expect.objectContaining({ id: product.id }),
814+
expect(response.data.products.map((p) => p.id)).toEqual([
815+
product3.id,
816+
product2.id,
817+
product.id,
816818
])
817819
})
818820

packages/admin/dashboard/src/lib/format-currency.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const formatCurrency = (amount: number, currency: string) => {
2-
return new Intl.NumberFormat("en-US", {
2+
return new Intl.NumberFormat(undefined, {
33
style: "currency",
44
currency,
55
signDisplay: "auto",

0 commit comments

Comments
 (0)