Skip to content

Commit

Permalink
Merge branch 'develop' into fix/CreateOrderFulfillmentWorkFlowInput
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-r-l-rodrigues authored Oct 11, 2024
2 parents 41b51b2 + c8b375a commit b3e791b
Show file tree
Hide file tree
Showing 547 changed files with 16,095 additions and 5,860 deletions.
1 change: 1 addition & 0 deletions .changeset/little-books-reply.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@medusajs/admin-vite-plugin": patch
"@medusajs/framework": patch
"@medusajs/index": patch
"@medusajs/locking": patch
---

chore: Preview release changeset
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ packages/*
!packages/cache-inmemory
!packages/create-medusa-app
!packages/product
!packages/locking
!packages/orchestration
!packages/workflows-sdk
!packages/core-flows
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ module.exports = {
"./packages/modules/workflow-engine-redis/tsconfig.spec.json",
"./packages/modules/link-modules/tsconfig.spec.json",
"./packages/modules/user/tsconfig.spec.json",
"./packages/modules/locking/tsconfig.spec.json",

"./packages/modules/providers/file-local/tsconfig.spec.json",
"./packages/modules/providers/file-s3/tsconfig.spec.json",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ www/**/.yarn/*
.idea
.turbo
build/**
dist/**
**/dist
**/stats
.favorites.json
Expand Down
2 changes: 1 addition & 1 deletion define_jest_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function defineJestConfig(config) {
},
target: "ES2021",
},
sourceMaps: true,
sourceMaps: "inline",
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,16 @@ medusaIntegrationTestRunner({
)

expect(response.status).toEqual(200)
expect(response.data).toEqual(
expect.objectContaining({
collection: expect.objectContaining({
id: expect.stringMatching(/^pcol_*/),
title: "New collection",
handle: "test-new-collection",
created_at: expect.any(String),
updated_at: expect.any(String),
}),
})
)
expect(response.data).toEqual({
collection: {
id: expect.stringMatching(/^pcol_*/),
title: "New collection",
handle: "test-new-collection",
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
},
})
})

it("lists collections", async () => {
Expand All @@ -96,22 +95,33 @@ medusaIntegrationTestRunner({
expect(response.data).toEqual(
expect.objectContaining({
count: 3,
limit: 10,
offset: 0,
collections: expect.arrayContaining([
expect.objectContaining({
id: baseCollection2.id,
{
id: baseCollection.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
expect.objectContaining({
handle: "test-collection",
metadata: null,
title: "test-collection",
},
{
id: baseCollection1.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
expect.objectContaining({
id: baseCollection.id,
handle: "test-collection1",
metadata: null,
title: "test-collection1",
},
{
id: baseCollection2.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
handle: "test-collection2",
metadata: null,
title: "test-collection2",
},
]),
})
)
Expand All @@ -127,11 +137,14 @@ medusaIntegrationTestRunner({
expect.objectContaining({
count: 1,
collections: expect.arrayContaining([
expect.objectContaining({
{
id: baseCollection.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
handle: "test-collection",
metadata: null,
title: "test-collection",
},
]),
})
)
Expand All @@ -154,13 +167,14 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200)
expect(response.data).toEqual(
expect.objectContaining({
collection: expect.objectContaining({
collection: {
id: expect.stringMatching(/^pcol_*/),
title: "test collection creation",
handle: "test-handle-creation",
created_at: expect.any(String),
updated_at: expect.any(String),
}),
metadata: null,
},
})
)
})
Expand Down
17 changes: 17 additions & 0 deletions integration-tests/http/__tests__/order/admin/order.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ medusaIntegrationTestRunner({
.order
})

it("should find the order querying it by number", async () => {
const userEmail = "tony@stark-industries.com"

const response = (
await api.get(`/admin/orders/?q=non-existing`, adminHeaders)
).data

expect(response.orders).toHaveLength(0)

const response2 = (
await api.get(`/admin/orders/?fields=+email&q=@stark`, adminHeaders)
).data

expect(response2.orders).toHaveLength(1)
expect(response2.orders[0].email).toEqual(userEmail)
})

it("should only create fulfillments grouped by shipping requirement", async () => {
const {
response: { data },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
createAdminUser,
} from "../../../../helpers/create-admin-user"

jest.setTimeout(30000)
jest.setTimeout(50000)

medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => {
Expand Down Expand Up @@ -310,6 +310,14 @@ medusaIntegrationTestRunner({
)
).data.product_category

await api.post(
"/admin/product-categories",
{
name: "Something different",
},
adminHeaders
)

const response = await api.get(
"/admin/product-categories?q=Category",
adminHeaders
Expand All @@ -333,20 +341,16 @@ medusaIntegrationTestRunner({
}),
])
)
})

const responseTwo = await api.get(
"/admin/product-categories?q=three",
it("should query all categories if q is empty", async () => {
const response = await api.get(
"/admin/product-categories?q=",
adminHeaders
)

expect(responseTwo.status).toEqual(200)
expect(responseTwo.data.product_categories).toHaveLength(1)
expect(responseTwo.data.product_categories).toEqual([
expect.objectContaining({
id: categoryThree.id,
name: "Category Three",
}),
])
expect(response.status).toEqual(200)
expect(response.data.product_categories).toHaveLength(7) // created in beforeEach
})

it("gets list of product category with immediate children and parents", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,20 @@ medusaIntegrationTestRunner({
expect(res.status).toEqual(200)
expect(res.data.product_types).toEqual(
expect.arrayContaining([
expect.objectContaining({
{
id: expect.stringMatching(/ptyp_.{24}/),
value: "test1",
}),
expect.objectContaining({
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
},
{
id: expect.stringMatching(/ptyp_.{24}/),
value: "test2",
}),
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
},
])
)
})
Expand All @@ -61,13 +69,35 @@ medusaIntegrationTestRunner({

// The value of the type should match the search param
expect(res.data.product_types).toEqual([
expect.objectContaining({
{
id: expect.stringMatching(/ptyp_.{24}/),
value: "test1",
}),
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
},
])
})

// BREAKING: Removed a test around filtering based on discount condition id, which is no longer supported
})

describe("/admin/product-types/:id", () => {
it("returns a product type", async () => {
const res = await api.get(
`/admin/product-types/${type1.id}`,
adminHeaders
)

expect(res.status).toEqual(200)
expect(res.data.product_type).toEqual({
id: expect.stringMatching(/ptyp_.{24}/),
value: "test1",
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
})
})
})
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,7 @@ medusaIntegrationTestRunner({

await deleteLineItemsWorkflow(appContainer).run({
input: {
cart_id: cart.id,
ids: items.map((i) => i.id),
},
throwOnError: false,
Expand Down Expand Up @@ -1211,6 +1212,7 @@ medusaIntegrationTestRunner({

const { errors } = await workflow.run({
input: {
cart_id: cart.id,
ids: items.map((i) => i.id),
},
throwOnError: false,
Expand Down
31 changes: 16 additions & 15 deletions integration-tests/modules/__tests__/cart/store/carts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
ProductStatus,
PromotionRuleOperator,
PromotionType,
RuleOperator
RuleOperator,
} from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import {
Expand Down Expand Up @@ -144,18 +144,18 @@ medusaIntegrationTestRunner({

await remoteLink.create([
{
Product: {
[Modules.PRODUCT]: {
variant_id: product.variants[0].id,
},
Pricing: {
[Modules.PRICING]: {
price_set_id: priceSet.id,
},
},
{
Product: {
[Modules.PRODUCT]: {
variant_id: product.variants[1].id,
},
Pricing: {
[Modules.PRICING]: {
price_set_id: priceSetTwo.id,
},
},
Expand Down Expand Up @@ -232,8 +232,8 @@ medusaIntegrationTestRunner({

await remoteLink.create([
{
Product: { variant_id: product.variants[0].id },
Pricing: { price_set_id: priceSet.id },
[Modules.PRODUCT]: { variant_id: product.variants[0].id },
[Modules.PRICING]: { price_set_id: priceSet.id },
},
])

Expand Down Expand Up @@ -1080,10 +1080,10 @@ medusaIntegrationTestRunner({

await remoteLink.create([
{
Product: {
[Modules.PRODUCT]: {
variant_id: productWithDefaultTax.variants[0].id,
},
Pricing: { price_set_id: priceSetDefaultTax.id },
[Modules.PRICING]: { price_set_id: priceSetDefaultTax.id },
},
])

Expand Down Expand Up @@ -1212,10 +1212,10 @@ medusaIntegrationTestRunner({

await remoteLink.create([
{
Product: {
[Modules.PRODUCT]: {
variant_id: productWithDefaultTax.variants[0].id,
},
Pricing: { price_set_id: priceSetDefaultTax.id },
[Modules.PRICING]: { price_set_id: priceSetDefaultTax.id },
},
])

Expand Down Expand Up @@ -2104,16 +2104,16 @@ medusaIntegrationTestRunner({

await remoteLink.create([
{
Product: {
[Modules.PRODUCT]: {
variant_id: productWithSpecialTax.variants[0].id,
},
Pricing: { price_set_id: priceSet.id },
[Modules.PRICING]: { price_set_id: priceSet.id },
},
{
Product: {
[Modules.PRODUCT]: {
variant_id: productWithDefaultTax.variants[0].id,
},
Pricing: { price_set_id: priceSetDefaultTax.id },
[Modules.PRICING]: { price_set_id: priceSetDefaultTax.id },
},
{
[Modules.CART]: { cart_id: cart.id },
Expand All @@ -2131,6 +2131,7 @@ medusaIntegrationTestRunner({
)

expect(response.status).toEqual(200)

expect(response.data.cart).toEqual(
expect.objectContaining({
id: cart.id,
Expand Down
Loading

0 comments on commit b3e791b

Please sign in to comment.