Skip to content

Commit

Permalink
chore(medusa): Typeorm upgrade to 0.3.11 (#3041)
Browse files Browse the repository at this point in the history
  • Loading branch information
riqwan authored Feb 15, 2023
1 parent 8137061 commit 121b42a
Show file tree
Hide file tree
Showing 275 changed files with 4,490 additions and 4,777 deletions.
16 changes: 16 additions & 0 deletions .changeset/brave-guests-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@medusajs/medusa": minor
"medusa-plugin-sendgrid": patch
"medusa-payment-stripe": patch
"medusa-plugin-algolia": patch
"medusa-source-shopify": patch
"medusa-core-utils": patch
"medusa-file-minio": patch
"medusa-interfaces": patch
"medusa-test-utils": patch
"@medusajs/stock-location": patch
"@medusajs/inventory": patch
"@medusajs/medusa-js": patch
---

chore(medusa): upgrade typeorm from 0.2.51 to 0.3.11
3 changes: 2 additions & 1 deletion .github/workflows/test-cli-with-database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ jobs:
run: npm i -g @medusajs/medusa-cli

- name: Create Medusa project
# TODO: Remove the branch when typeorm is no longer a dependency for starter
run: |
medusa new cli-test
medusa new cli-test 'https://github.com/medusajs/medusa-starter-default/tree/typeorm-upgrade'
working-directory: ..

- name: Install postgres config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ describe("/admin/order-edits", () => {
withDeleted: true,
})

expect(orderEdit).toBeUndefined()
expect(orderEdit).toBeNull()
expect(response.status).toEqual(200)
expect(response.data).toEqual({
id,
Expand Down Expand Up @@ -534,7 +534,7 @@ describe("/admin/order-edits", () => {
withDeleted: true,
})

expect(orderEdit).toBeUndefined()
expect(orderEdit).toBeNull()
expect(response.status).toEqual(200)
expect(response.data).toEqual({
id: orderEditId,
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/api/__tests__/admin/order/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,9 @@ describe("/admin/orders", () => {

const manager = dbConnection.manager
const customOptions = await manager.find(CustomShippingOption, {
shipping_option_id: "test-option",
where: {
shipping_option_id: "test-option",
},
})

expect(response.status).toEqual(200)
Expand Down
108 changes: 61 additions & 47 deletions integration-tests/api/__tests__/admin/price-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const adminReqConfig = {
},
}

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

describe("/admin/price-lists", () => {
let medusaProcess
Expand Down Expand Up @@ -1108,52 +1108,66 @@ describe("/admin/price-lists", () => {
expect(response.status).toEqual(200)
expect(response.data.count).toEqual(2)
expect(response.data.products).toHaveLength(2)
expect(response.data.products).toEqual([
expect.objectContaining({
id: "test-prod-2",
variants: expect.arrayContaining([
expect.objectContaining({
id: "test-variant-3",
prices: expect.arrayContaining([
expect.objectContaining({ currency_code: "usd", amount: 100 }),
]),
}),
expect.objectContaining({
id: "test-variant-4",
prices: expect.arrayContaining([
expect.objectContaining({ currency_code: "usd", amount: 100 }),
expect.objectContaining({
currency_code: "usd",
amount: 150,
price_list_id: "test-list",
}),
]),
}),
]),
}),
expect.objectContaining({
id: "test-prod-1",
variants: expect.arrayContaining([
expect.objectContaining({
id: "test-variant-1",
prices: expect.arrayContaining([
expect.objectContaining({ currency_code: "usd", amount: 100 }),
expect.objectContaining({
currency_code: "usd",
amount: 150,
price_list_id: "test-list",
}),
]),
}),
expect.objectContaining({
id: "test-variant-2",
prices: expect.arrayContaining([
expect.objectContaining({ currency_code: "usd", amount: 100 }),
]),
}),
]),
}),
])
expect(response.data.products).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: "test-prod-1",
variants: expect.arrayContaining([
expect.objectContaining({
id: "test-variant-1",
prices: expect.arrayContaining([
expect.objectContaining({
currency_code: "usd",
amount: 100,
}),
expect.objectContaining({
currency_code: "usd",
amount: 150,
price_list_id: "test-list",
}),
]),
}),
expect.objectContaining({
id: "test-variant-2",
prices: expect.arrayContaining([
expect.objectContaining({
currency_code: "usd",
amount: 100,
}),
]),
}),
]),
}),
expect.objectContaining({
id: "test-prod-2",
variants: expect.arrayContaining([
expect.objectContaining({
id: "test-variant-3",
prices: expect.arrayContaining([
expect.objectContaining({
currency_code: "usd",
amount: 100,
}),
]),
}),
expect.objectContaining({
id: "test-variant-4",
prices: expect.arrayContaining([
expect.objectContaining({
currency_code: "usd",
amount: 100,
}),
expect.objectContaining({
currency_code: "usd",
amount: 150,
price_list_id: "test-list",
}),
]),
}),
]),
}),
])
)
})

it("lists only product 2", async () => {
Expand Down
77 changes: 34 additions & 43 deletions integration-tests/api/__tests__/admin/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,6 @@ describe("/admin/products", () => {
const variant = response.data.product.variants.find(
(v) => v.id === variantId
)

expect(variant.prices.length).toEqual(data.prices.length)

expect(variant.prices).toEqual(
Expand Down Expand Up @@ -2467,10 +2466,10 @@ describe("/admin/products", () => {
const api = useApi()

const variantPre = await dbConnection.manager.findOne(ProductVariant, {
id: "test-variant",
where: { id: "test-variant" },
})

expect(variantPre).not.toEqual(undefined)
expect(variantPre).toBeTruthy()

const response = await api
.delete("/admin/products/test-product", adminHeaders)
Expand All @@ -2488,21 +2487,21 @@ describe("/admin/products", () => {
)

const variant = await dbConnection.manager.findOne(ProductVariant, {
id: "test-variant",
where: { id: "test-variant" },
})

expect(variant).toEqual(undefined)
expect(variant).not.toBeTruthy()
})

it("successfully deletes a product variant and its associated option values", async () => {
const api = useApi()

// Validate that the option value exists
const optValPre = await dbConnection.manager.findOne(ProductOptionValue, {
variant_id: "test-variant_2",
where: { variant_id: "test-variant_2" },
})

expect(optValPre).not.toEqual(undefined)
expect(optValPre).toBeTruthy()

// Soft delete the variant
const response = await api.delete(
Expand All @@ -2515,20 +2514,18 @@ describe("/admin/products", () => {
// Validate that the option value was deleted
const optValPost = await dbConnection.manager.findOne(
ProductOptionValue,
{
variant_id: "test-variant_2",
}
{ where: { variant_id: "test-variant_2" } }
)

expect(optValPost).toEqual(undefined)
expect(optValPost).not.toBeTruthy()

// Validate that the option still exists in the DB with deleted_at
const optValDeleted = await dbConnection.manager.findOne(
ProductOptionValue,
{
variant_id: "test-variant_2",
},
{
where: {
variant_id: "test-variant_2",
},
withDeleted: true,
}
)
Expand All @@ -2546,10 +2543,10 @@ describe("/admin/products", () => {

// Validate that the option value exists
const optValPre = await dbConnection.manager.findOne(ProductOptionValue, {
variant_id: "test-variant_2",
where: { variant_id: "test-variant_2" },
})

expect(optValPre).not.toEqual(undefined)
expect(optValPre).toBeTruthy()

// Soft delete the product
const response = await api.delete(
Expand All @@ -2563,19 +2560,19 @@ describe("/admin/products", () => {
const optValPost = await dbConnection.manager.findOne(
ProductOptionValue,
{
variant_id: "test-variant_2",
where: { variant_id: "test-variant_2" },
}
)

expect(optValPost).toEqual(undefined)
expect(optValPost).not.toBeTruthy()

// Validate that the option still exists in the DB with deleted_at
const optValDeleted = await dbConnection.manager.findOne(
ProductOptionValue,
{
variant_id: "test-variant_2",
},
{
where: {
variant_id: "test-variant_2",
},
withDeleted: true,
}
)
Expand All @@ -2593,10 +2590,10 @@ describe("/admin/products", () => {

// Validate that the price exists
const pricePre = await dbConnection.manager.findOne(MoneyAmount, {
id: "test-price",
where: { id: "test-price" },
})

expect(pricePre).not.toEqual(undefined)
expect(pricePre).toBeTruthy()

// Soft delete the variant
const response = await api.delete(
Expand All @@ -2608,21 +2605,18 @@ describe("/admin/products", () => {

// Validate that the price was deleted
const pricePost = await dbConnection.manager.findOne(MoneyAmount, {
id: "test-price",
where: { id: "test-price" },
})

expect(pricePost).toEqual(undefined)
expect(pricePost).not.toBeTruthy()

// Validate that the price still exists in the DB with deleted_at
const optValDeleted = await dbConnection.manager.findOne(
MoneyAmount,
{
const optValDeleted = await dbConnection.manager.findOne(MoneyAmount, {
where: {
id: "test-price",
},
{
withDeleted: true,
}
)
withDeleted: true,
})

expect(optValDeleted).toEqual(
expect.objectContaining({
Expand All @@ -2637,10 +2631,10 @@ describe("/admin/products", () => {

// Validate that the price exists
const pricePre = await dbConnection.manager.findOne(MoneyAmount, {
id: "test-price",
where: { id: "test-price" },
})

expect(pricePre).not.toEqual(undefined)
expect(pricePre).toBeTruthy()

// Soft delete the product
const response = await api.delete(
Expand All @@ -2652,21 +2646,18 @@ describe("/admin/products", () => {

// Validate that the price has been deleted
const pricePost = await dbConnection.manager.findOne(MoneyAmount, {
id: "test-price",
where: { id: "test-price" },
})

expect(pricePost).toEqual(undefined)
expect(pricePost).not.toBeTruthy()

// Validate that the price still exists in the DB with deleted_at
const optValDeleted = await dbConnection.manager.findOne(
MoneyAmount,
{
const optValDeleted = await dbConnection.manager.findOne(MoneyAmount, {
where: {
id: "test-price",
},
{
withDeleted: true,
}
)
withDeleted: true,
})

expect(optValDeleted).toEqual(
expect.objectContaining({
Expand Down
Loading

0 comments on commit 121b42a

Please sign in to comment.