fix: adjustments based on seb's feedback

- remove eager from shipping_option relationship in `models/custom-shipping-options.ts`
- remove custom_shipping_options relation from cart model
This commit is contained in:
zakariaelas
2021-10-13 17:06:35 +01:00
parent 3d088c351b
commit dba1d5bb69
19 changed files with 424 additions and 139 deletions

View File

@@ -32,7 +32,7 @@ describe("/admin/orders", () => {
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
dbConnection = await initDb({ cwd })
medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd, verbose: true })
})
afterAll(async () => {

View File

@@ -30,7 +30,7 @@ describe("/store/carts", () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
try {
dbConnection = await initDb({ cwd })
medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd, verbose: true })
} catch (error) {
console.log(error)
}
@@ -467,6 +467,13 @@ describe("/store/carts", () => {
})
cartWithCustomSo = await manager.save(_cart)
await manager.insert(CustomShippingOption, {
id: "another-cso-test",
cart_id: "test-cart-with-cso",
shipping_option_id: "test-option",
price: 5,
})
} catch (err) {
console.log(err)
}
@@ -494,8 +501,7 @@ describe("/store/carts", () => {
})
it("given a cart with custom options and a shipping option already belonging to said cart, then it should add a shipping method based on the given custom shipping option", async () => {
const shippingOptionId =
cartWithCustomSo.custom_shipping_options[0].shipping_option_id
const shippingOptionId = "test-option"
const api = useApi()

View File

@@ -16,7 +16,7 @@ describe("/store/shipping-options", () => {
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
dbConnection = await initDb({ cwd })
medusaProcess = await setupServer({ cwd })
medusaProcess = await setupServer({ cwd, verbose: true })
})
afterAll(async () => {

View File

@@ -15,6 +15,9 @@ const {
Cart,
Return,
} = require("@medusajs/medusa")
const {
CustomShippingOption,
} = require("@medusajs/medusa/dist/models/custom-shipping-option")
module.exports = async (connection, data = {}) => {
const manager = connection.manager
@@ -109,12 +112,6 @@ module.exports = async (connection, data = {}) => {
billing_address_id: "test-billing-address",
region_id: "test-region",
type: "swap",
custom_shipping_options: [
{
shipping_option_id: "test-option",
price: 0,
},
],
metadata: {
swap_id: "test-swap",
parent_order_id: orderWithSwap.id,
@@ -123,6 +120,13 @@ module.exports = async (connection, data = {}) => {
await manager.save(cartWithCustomSo)
manager.insert(CustomShippingOption, {
id: "cso-test",
cart_id: cartWithCustomSo.id,
price: 0,
shipping_option_id: "test-option",
})
const swapWithRMAMethod = manager.create(Swap, {
id: "test-swap-rma",
order_id: "order-with-swap",

View File

@@ -8,15 +8,15 @@
"build": "babel src -d dist --extensions \".ts,.js\""
},
"dependencies": {
"@medusajs/medusa": "1.1.41-dev-1633520747607",
"medusa-interfaces": "1.1.23-dev-1633520747607",
"@medusajs/medusa": "1.1.41-dev-1634206968632",
"medusa-interfaces": "1.1.23-dev-1634206968632",
"typeorm": "^0.2.31"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/node": "^7.12.10",
"babel-preset-medusa-package": "1.1.15-dev-1633520747607",
"babel-preset-medusa-package": "1.1.15-dev-1634206968632",
"jest": "^26.6.3"
}
}

View File

@@ -1223,10 +1223,10 @@
"@types/yargs" "^15.0.0"
chalk "^4.0.0"
"@medusajs/medusa-cli@1.1.18-dev-1633520747607":
version "1.1.18-dev-1633520747607"
resolved "http://localhost:4873/@medusajs%2fmedusa-cli/-/medusa-cli-1.1.18-dev-1633520747607.tgz#46a3f73f6aff016f50a8123f47d69c64b7a52037"
integrity sha512-4KLnR6gq8R3sCAhOcYCI5SE+G9vyt2l6RyImvvPw7I03iDiNMc3URwoq2cFwV+V4dSrW59WFIlMJR7ALCTygdA==
"@medusajs/medusa-cli@1.1.18-dev-1634206968632":
version "1.1.18-dev-1634206968632"
resolved "http://localhost:4873/@medusajs%2fmedusa-cli/-/medusa-cli-1.1.18-dev-1634206968632.tgz#26c12ed689f9d0485c14eccdd377b67bff505f90"
integrity sha512-oQwdVu2M2v5JRC+gwNXoL/fyGkH6nRaEBDG1rJk0YAmMawMxOIAAd/t1tMK16P69xK4eIUb4fkwX7BpC7kWKiA==
dependencies:
"@babel/polyfill" "^7.8.7"
"@babel/runtime" "^7.9.6"
@@ -1244,8 +1244,8 @@
is-valid-path "^0.1.1"
joi-objectid "^3.0.1"
meant "^1.0.1"
medusa-core-utils "1.1.22-dev-1633520747607"
medusa-telemetry "0.0.5-dev-1633520747607"
medusa-core-utils "1.1.22-dev-1634206968632"
medusa-telemetry "0.0.5-dev-1634206968632"
netrc-parser "^3.1.6"
open "^8.0.6"
ora "^5.4.1"
@@ -1259,13 +1259,13 @@
winston "^3.3.3"
yargs "^15.3.1"
"@medusajs/medusa@1.1.41-dev-1633520747607":
version "1.1.41-dev-1633520747607"
resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.41-dev-1633520747607.tgz#82efd5b0bbaaaac76ce740dc9b35fe47c780592f"
integrity sha512-D+1WVpMWDaVki+Ti3rXYAl+3rb3eaX16BZ1RU/bG7FbhFJt8P1a1LXwMMQLV2rG/mUDgs6kDyl2qhYTzZ7X7aA==
"@medusajs/medusa@1.1.41-dev-1634206968632":
version "1.1.41-dev-1634206968632"
resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.41-dev-1634206968632.tgz#f4fb24416aab594401d4a8de91f2bcd63f4078d9"
integrity sha512-3nbKX3vcB1sDCkt9FUs611ZxBrGGWBGArEXwtwHpJ/PScesPE1Gl9y+q8lfnu8NInYD3hw1Tpp4JMaOrfpifgw==
dependencies:
"@hapi/joi" "^16.1.8"
"@medusajs/medusa-cli" "1.1.18-dev-1633520747607"
"@medusajs/medusa-cli" "1.1.18-dev-1634206968632"
"@types/lodash" "^4.14.168"
awilix "^4.2.3"
body-parser "^1.19.0"
@@ -1287,8 +1287,8 @@
joi "^17.3.0"
joi-objectid "^3.0.1"
jsonwebtoken "^8.5.1"
medusa-core-utils "1.1.22-dev-1633520747607"
medusa-test-utils "1.1.25-dev-1633520747607"
medusa-core-utils "1.1.22-dev-1634206968632"
medusa-test-utils "1.1.25-dev-1634206968632"
morgan "^1.9.1"
multer "^1.4.2"
passport "^0.4.0"
@@ -1933,10 +1933,10 @@ babel-preset-jest@^26.6.2:
babel-plugin-jest-hoist "^26.6.2"
babel-preset-current-node-syntax "^1.0.0"
babel-preset-medusa-package@1.1.15-dev-1633520747607:
version "1.1.15-dev-1633520747607"
resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.15-dev-1633520747607.tgz#ac970d565ac9803333bb5fecc7d16c162302c97b"
integrity sha512-XpU4J3xmdk8y2QRrxXFbkCq+9OzqUNeZlPAffiGlFTWYx0VRD4tZS4DWazrA5ub3RfqMFl/cxZA6NBcbJhZ/iQ==
babel-preset-medusa-package@1.1.15-dev-1634206968632:
version "1.1.15-dev-1634206968632"
resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.15-dev-1634206968632.tgz#752d6b645d0d09ad53d955bc823572b8d05ecda6"
integrity sha512-AvhdeUwC2uUnMFN9qA4oPDyZ+P0IO+rmiG/Udl7mssh43o3thDATllZSNbRBIwr4jy9M67oj+dbtrO6o8vJoBQ==
dependencies:
"@babel/plugin-proposal-class-properties" "^7.12.1"
"@babel/plugin-proposal-decorators" "^7.12.1"
@@ -5110,25 +5110,25 @@ media-typer@0.3.0:
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
medusa-core-utils@1.1.22-dev-1633520747607:
version "1.1.22-dev-1633520747607"
resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.22-dev-1633520747607.tgz#d18c79e4ba9ee8b373bfc02024e23763f079ab87"
integrity sha512-pP1FdbrXbHqRxzMh2nKX6ByxtCrNSjJzOIJ45k1/Kl41VortD9EYiOpuLGOdodkD1jbuf6aV4x0zNIoWpGyHew==
medusa-core-utils@1.1.22-dev-1634206968632:
version "1.1.22-dev-1634206968632"
resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.22-dev-1634206968632.tgz#7eb0e6f95d8bd494aec706aa081ffbba8825e4ba"
integrity sha512-htkx9927dyEWdfOXw2xj58O7GPtPaTY5p9JO/Sja6LuN9QaotMPVrOkqy7drHiGtdn3IzjIMq4i7iub2DgJy0w==
dependencies:
joi "^17.3.0"
joi-objectid "^3.0.1"
medusa-interfaces@1.1.23-dev-1633520747607:
version "1.1.23-dev-1633520747607"
resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.23-dev-1633520747607.tgz#9487b2979cee9784b219a2117cf7199fbfadceb7"
integrity sha512-jyoc0wemXrZBtJMA6e7FcdnB/7do7j6oyLevCon7A6HibqQkuxLZ7TfWLHGROj4qy8aP8sAvtuXq9gpwkIm3CQ==
medusa-interfaces@1.1.23-dev-1634206968632:
version "1.1.23-dev-1634206968632"
resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.23-dev-1634206968632.tgz#1b9de0742daf85ddeacb11424857f5d6cc75e8f0"
integrity sha512-8KsXxuMF+jFczyGa088DLVHzfejwD0X74g/AuXhCTkHbc52cbCZr9o7GMok7hfOCz7wp2kKUDBACL0y6PzxHrQ==
dependencies:
medusa-core-utils "1.1.22-dev-1633520747607"
medusa-core-utils "1.1.22-dev-1634206968632"
medusa-telemetry@0.0.5-dev-1633520747607:
version "0.0.5-dev-1633520747607"
resolved "http://localhost:4873/medusa-telemetry/-/medusa-telemetry-0.0.5-dev-1633520747607.tgz#c8d23d5acf744eea8c88102a792b481051f84fb9"
integrity sha512-YX2hKGIANC0Ha9QKkMz5se9wDLJ940VEXwlMMGZzIRHoCoNpmxnsgXQXgeCtC1LKmlcaOaOzMqYyk19fgVCybQ==
medusa-telemetry@0.0.5-dev-1634206968632:
version "0.0.5-dev-1634206968632"
resolved "http://localhost:4873/medusa-telemetry/-/medusa-telemetry-0.0.5-dev-1634206968632.tgz#a9a1161aacfe0aaa476ba3ce3c15cb199c201cef"
integrity sha512-z3a5mXplM+XxkY3vJ8t159odgmkdMUHAWBZEM9PGaltkCh9Ew3RWkNXZeC60nW7tc85sfn1/nRxWpLgIywbruQ==
dependencies:
axios "^0.21.1"
axios-retry "^3.1.9"
@@ -5140,13 +5140,13 @@ medusa-telemetry@0.0.5-dev-1633520747607:
remove-trailing-slash "^0.1.1"
uuid "^8.3.2"
medusa-test-utils@1.1.25-dev-1633520747607:
version "1.1.25-dev-1633520747607"
resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.25-dev-1633520747607.tgz#7c283312d241e012ce9814841ab0fcb0e141245e"
integrity sha512-rW4GRGXlKBoqHeX3AvPWpV9R6AWe5CXEhDcTxxPNk/Nog8E8zBlWDHsff1057RagVIMjd4wkFx4Kz3mgUMgQAg==
medusa-test-utils@1.1.25-dev-1634206968632:
version "1.1.25-dev-1634206968632"
resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.25-dev-1634206968632.tgz#7306ff294c23bc2f229ae3112e8fc5b5ea362500"
integrity sha512-P+aa/Z7qywZt7z+6vj/owZhX8bHJCPsn1/Ak/9cGM0oJM/QGPzrQ00auikE13XyD95/53fPMh5G5mB8cJ+QbNg==
dependencies:
"@babel/plugin-transform-classes" "^7.9.5"
medusa-core-utils "1.1.22-dev-1633520747607"
medusa-core-utils "1.1.22-dev-1634206968632"
randomatic "^3.1.1"
merge-descriptors@1.0.1: