From 927a270c6b908c78df4aa048993d00fee807f54a Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 2 Jul 2021 12:38:46 +0200 Subject: [PATCH] removed changes wrongfully included --- integration-tests/api/__tests__/store/cart.js | 54 ------------------- .../api/helpers/product-seeder.js | 10 +--- integration-tests/helpers/use-db.js | 5 +- packages/medusa/src/models/line-item.ts | 2 +- 4 files changed, 3 insertions(+), 68 deletions(-) diff --git a/integration-tests/api/__tests__/store/cart.js b/integration-tests/api/__tests__/store/cart.js index 71c036b72d..9b5ceeb22b 100644 --- a/integration-tests/api/__tests__/store/cart.js +++ b/integration-tests/api/__tests__/store/cart.js @@ -5,10 +5,8 @@ const { Region } = require("@medusajs/medusa"); const setupServer = require("../../../helpers/setup-server"); const { useApi } = require("../../../helpers/use-api"); const { initDb } = require("../../../helpers/use-db"); -const { expectRelations } = require("../../helpers/expect-relations"); const cartSeeder = require("../../helpers/cart-seeder"); -const productSeeder = require("../../helpers/product-seeder"); jest.setTimeout(30000); @@ -332,56 +330,4 @@ describe("/store/carts", () => { expect(response.status).toEqual(200); }); }); - - describe("get-cart returns expected relations", () => { - beforeEach(async () => { - try { - await productSeeder(dbConnection); - await cartSeeder(dbConnection); - } catch (err) { - console.log(err); - throw err; - } - }); - - afterEach(async () => { - const manager = dbConnection.manager; - await doAfterEach(manager); - }); - - - it("returns default relations", async () => { - const api = useApi(); - - const expectedRelations = [ - "gift_cards", - "region", - "items.variant.prices", - "payment", - "shipping_address", - "billing_address", - "region.countries", - "region.payment_providers", - "payment_sessions", - "shipping_methods.shipping_option", - "discounts", - ] - - await api.post("/store/carts/test-cart/line-items", { - quantity: 1, - variant_id: "test-variant", - }) - - // await api.post("/store/carts/test-cart/shipping-methods", { - // option_id: "test-option" - // }) - - - const response = await api.get("/store/carts/test-cart") - - console.log(response.data.cart) - expectRelations(expectedRelations, response.data.cart) - - }); - }); }); diff --git a/integration-tests/api/helpers/product-seeder.js b/integration-tests/api/helpers/product-seeder.js index f11f70859b..77fd31a034 100644 --- a/integration-tests/api/helpers/product-seeder.js +++ b/integration-tests/api/helpers/product-seeder.js @@ -6,7 +6,6 @@ const { Product, ShippingProfile, ProductVariant, - MoneyAmount, Image, } = require("@medusajs/medusa"); @@ -81,14 +80,7 @@ module.exports = async (connection, data = {}) => { upc: "test-upc", barcode: "test-barcode", product_id: "test-product", - prices: [], + prices: [{ id: "test-price", currency_code: "usd", amount: 100 }], options: [{ id: "test-variant-option", value: "Default variant" }], }); - - await manager.insert(MoneyAmount, { - variant_id: "test-variant", - id: "test-price", - currency_code: "usd", - amount: 100, - }); }; diff --git a/integration-tests/helpers/use-db.js b/integration-tests/helpers/use-db.js index 74e420ec24..c9be67e7ae 100644 --- a/integration-tests/helpers/use-db.js +++ b/integration-tests/helpers/use-db.js @@ -36,10 +36,8 @@ module.exports = { ); const databaseName = "medusa-integration"; - await createDatabase({ databaseName }); - - + const connection = await createConnection({ type: "postgres", url: "postgres://localhost/medusa-integration", @@ -68,7 +66,6 @@ module.exports = { instance.setDb(dbConnection); return dbConnection; - }, useDb: function () { return instance; diff --git a/packages/medusa/src/models/line-item.ts b/packages/medusa/src/models/line-item.ts index e8d30aecff..3060050646 100644 --- a/packages/medusa/src/models/line-item.ts +++ b/packages/medusa/src/models/line-item.ts @@ -99,7 +99,7 @@ export class LineItem { @Column({ nullable: true }) variant_id: string - @ManyToOne(() => ProductVariant) + @ManyToOne(() => ProductVariant, { eager: true }) @JoinColumn({ name: "variant_id" }) variant: ProductVariant