chore: Use module test runner in Carts API test suite (#6679)

Nothing but migrating to our new module test runner. Hopefully, that'll make the actual test PRs easier to digest.
This commit is contained in:
Oli Juhl authored and GitHub committed 2024-03-13 07:32:58 +00:00
1 parent d4b921f3db
commit db26dafa85
3 files changed
+76 -240

No files matched your search

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`/store/carts POST /store/carts/:id fails to complete cart with items inventory not/partially covered 1`] = `
exports[` POST /store/carts/:id fails to complete cart with items inventory not/partially covered 1`] = `
Object {
"errors": Array [
Object {
@@ -12,7 +12,7 @@ Object {
}
`;
exports[`/store/carts POST /store/carts/:id fails to complete swap cart with items inventory not/partially covered 1`] = `
exports[` POST /store/carts/:id fails to complete swap cart with items inventory not/partially covered 1`] = `
Object {
"errors": Array [
Object {
@@ -24,7 +24,7 @@ Object {
}
`;
exports[`/store/carts shipping address + region updates updates region only - single to multiple countries 1`] = `
exports[` shipping address + region updates updates region only - single to multiple countries 1`] = `
Object {
"address_1": null,
"address_2": null,
@@ -1,5 +1,11 @@
const path = require("path")
const {
const { medusaIntegrationTestRunner } = require("medusa-test-utils")
const { useApi } = require("../../../../environment-helpers/use-api")
jest.setTimeout(30000)
let cartSeeder = undefined
let swapSeeder = undefined
let {
Region,
LineItem,
GiftCard,
@@ -7,15 +13,40 @@ const {
CustomShippingOption,
PriceList,
MoneyAmount,
} = require("@medusajs/medusa")
ProductVariantMoneyAmount,
} = {}
let {
simpleCustomerFactory,
simpleCartFactory,
simpleLineItemFactory,
simpleRegionFactory,
simpleProductFactory,
simpleSalesChannelFactory,
simpleShippingOptionFactory,
simplePriceListFactory,
simpleDiscountFactory,
simpleCustomerGroupFactory,
} = {}
const setupServer = require("../../../../environment-helpers/setup-server")
const { useApi } = require("../../../../environment-helpers/use-api")
const { initDb, useDb } = require("../../../../environment-helpers/use-db")
medusaIntegrationTestRunner({
env: { MEDUSA_FF_MEDUSA_V2: false },
testSuite: ({ dbConnection, getContainer, api }) => {
let container
const cartSeeder = require("../../../../helpers/cart-seeder")
const swapSeeder = require("../../../../helpers/swap-seeder")
const {
beforeAll(() => {
cartSeeder = require("../../../../helpers/cart-seeder")
swapSeeder = require("../../../../helpers/swap-seeder")
;({
Region,
LineItem,
GiftCard,
Cart,
CustomShippingOption,
PriceList,
MoneyAmount,
ProductVariantMoneyAmount,
} = require("@medusajs/medusa"))
;({
simpleCartFactory,
simpleRegionFactory,
simpleProductFactory,
@@ -23,39 +54,14 @@ const {
simpleLineItemFactory,
simpleSalesChannelFactory,
simplePriceListFactory,
} = require("../../../../factories")
const {
simpleDiscountFactory,
} = require("../../../../factories/simple-discount-factory")
const {
simpleCustomerFactory,
} = require("../../../../factories/simple-customer-factory")
const {
simpleCustomerGroupFactory,
} = require("../../../../factories/simple-customer-group-factory")
const { ProductVariantMoneyAmount } = require("@medusajs/medusa")
jest.setTimeout(30000)
describe("/store/carts", () => {
let medusaProcess
let dbConnection
const doAfterEach = async () => {
const db = useDb()
return await db.teardown()
}
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
dbConnection = await initDb({ cwd })
medusaProcess = await setupServer({ cwd })
} = require("../../../../factories"))
})
afterAll(async () => {
const db = useDb()
await db.shutdown()
medusaProcess.kill()
beforeEach(async () => {
container = getContainer()
})
describe("POST /store/carts", () => {
@@ -92,13 +98,7 @@ describe("/store/carts", () => {
})
})
afterEach(async () => {
await doAfterEach()
})
it("creates a cart", async () => {
const api = useApi()
const response = await api.post("/store/carts")
expect(response.status).toEqual(200)
@@ -107,8 +107,6 @@ describe("/store/carts", () => {
})
it("fails to create a cart when no region exist", async () => {
const api = useApi()
await dbConnection.manager.query(
`UPDATE "country"
SET region_id=null
@@ -159,8 +157,6 @@ describe("/store/carts", () => {
money_amount_id: ma_sale_1.id,
})
const api = useApi()
const response = await api
.post("/store/carts", {
items: [
@@ -199,8 +195,6 @@ describe("/store/carts", () => {
})
it("creates a cart with country", async () => {
const api = useApi()
const response = await api.post("/store/carts", {
country_code: "us",
})
@@ -212,7 +206,6 @@ describe("/store/carts", () => {
})
it("creates a cart with context", async () => {
const api = useApi()
const response = await api.post("/store/carts", {
context: {
test_id: "test",
@@ -225,7 +218,7 @@ describe("/store/carts", () => {
const cart = getRes.data.cart
expect(cart.context).toEqual({
ip: "::ffff:127.0.0.1",
ip: expect.any(String),
user_agent: expect.stringContaining("axios/0.21."),
test_id: "test",
})
@@ -238,13 +231,7 @@ describe("/store/carts", () => {
await swapSeeder(dbConnection)
})
afterEach(async () => {
await doAfterEach()
})
it("adds line item to cart", async () => {
const api = useApi()
// Add standard line item to cart
const response = await api
.post(
@@ -272,8 +259,6 @@ describe("/store/carts", () => {
})
it("adds line item to cart containing a total fixed discount", async () => {
const api = useApi()
const response = await api
.post(
"/store/carts/test-cart-w-total-fixed-discount/line-items",
@@ -306,8 +291,6 @@ describe("/store/carts", () => {
})
it("adds line item to cart containing a total percentage discount", async () => {
const api = useApi()
const response = await api
.post(
"/store/carts/test-cart-w-total-percentage-discount/line-items",
@@ -340,8 +323,6 @@ describe("/store/carts", () => {
})
it("adds line item to cart containing an item fixed discount", async () => {
const api = useApi()
const response = await api
.post(
"/store/carts/test-cart-w-item-fixed-discount/line-items",
@@ -374,8 +355,6 @@ describe("/store/carts", () => {
})
it("adds line item to cart containing an item percentage discount", async () => {
const api = useApi()
const response = await api
.post(
"/store/carts/test-cart-w-item-percentage-discount/line-items",
@@ -408,8 +387,6 @@ describe("/store/carts", () => {
})
it("adds line item to cart time limited sale", async () => {
const api = useApi()
const response = await api
.post(
"/store/carts/test-cart/line-items",
@@ -435,8 +412,6 @@ describe("/store/carts", () => {
})
it("adds line item to cart time customer pricing", async () => {
const api = useApi()
// customer with customer-group 5
const authResponse = await api.post("/store/auth", {
email: "test5@email.com",
@@ -476,8 +451,6 @@ describe("/store/carts", () => {
})
it("adds line item with quantity to cart with quantity discount", async () => {
const api = useApi()
const response = await api
.post(
"/store/carts/test-cart/line-items",
@@ -503,8 +476,6 @@ describe("/store/carts", () => {
})
it("adds line item with quantity to cart with quantity discount no ceiling", async () => {
const api = useApi()
const response = await api
.post(
"/store/carts/test-cart/line-items",
@@ -545,7 +516,11 @@ describe("/store/carts", () => {
let discount
beforeEach(async () => {
discount = await simpleDiscountFactory(dbConnection, discountData, 100)
discount = await simpleDiscountFactory(
dbConnection,
discountData,
100
)
discountCart = await simpleCartFactory(
dbConnection,
{
@@ -591,13 +566,7 @@ describe("/store/carts", () => {
.add(discount)
})
afterEach(async () => {
await doAfterEach()
})
it("updates an old line item adjustment when a new line item is added to a discount cart", async () => {
const api = useApi()
const response = await api
.post(
"/store/carts/discount-cart/line-items",
@@ -644,8 +613,6 @@ describe("/store/carts", () => {
})
it("updates an existing item adjustment when a line item is updated", async () => {
const api = useApi()
await simpleLineItemFactory(
dbConnection,
{
@@ -714,8 +681,6 @@ describe("/store/carts", () => {
})
it("updates an existing item adjustment when a line item is deleted from a discount cart", async () => {
const api = useApi()
await simpleLineItemFactory(
dbConnection,
{
@@ -767,13 +732,7 @@ describe("/store/carts", () => {
await swapSeeder(dbConnection)
})
afterEach(async () => {
await doAfterEach()
})
it("updates line item of cart", async () => {
const api = useApi()
const response = await api
.post(
"/store/carts/test-cart-3/line-items/test-item3/",
@@ -805,7 +764,6 @@ describe("/store/carts", () => {
})
it("updates line item of a cart containing a total fixed discount", async () => {
const api = useApi()
await simpleLineItemFactory(dbConnection, {
id: "test-li-disc",
allow_discounts: true,
@@ -849,7 +807,6 @@ describe("/store/carts", () => {
})
it("updates line item of a cart containing a total percentage discount", async () => {
const api = useApi()
await simpleLineItemFactory(dbConnection, {
id: "test-li-disc",
allow_discounts: true,
@@ -893,7 +850,6 @@ describe("/store/carts", () => {
})
it("updates line item of a cart containing an item fixed discount", async () => {
const api = useApi()
await simpleLineItemFactory(dbConnection, {
id: "test-li-disc",
allow_discounts: true,
@@ -937,7 +893,6 @@ describe("/store/carts", () => {
})
it("updates line item of a cart containing an item percentage discount", async () => {
const api = useApi()
await simpleLineItemFactory(dbConnection, {
id: "test-li-disc",
allow_discounts: true,
@@ -981,8 +936,6 @@ describe("/store/carts", () => {
})
it("updates line item quantity with unit price reflected", async () => {
const api = useApi()
await simplePriceListFactory(dbConnection, {
id: "pl_current",
prices: [
@@ -1018,8 +971,6 @@ describe("/store/carts", () => {
})
it("updates line item quantity with unit price reflected when merging line-items", async () => {
const api = useApi()
await simplePriceListFactory(dbConnection, {
id: "pl_current",
prices: [
@@ -1056,8 +1007,6 @@ describe("/store/carts", () => {
})
it("creates and updates line item quantity with unit price reflected", async () => {
const api = useApi()
await simplePriceListFactory(dbConnection, {
id: "pl_current",
prices: [
@@ -1135,17 +1084,11 @@ describe("/store/carts", () => {
})
})
afterEach(async () => {
await doAfterEach()
})
// We were experiencing some issues when having created a cart in a region
// containing multiple countries. At this point, the cart does not have a shipping
// address. Therefore, on subsequent requests to update the cart, the server
// would throw a 500 due to missing shipping address id on insertion.
it("updates a cart, that does not have a shipping address", async () => {
const api = useApi()
const response = await api.post("/store/carts", {
region_id: "test-region-multiple",
})
@@ -1158,8 +1101,6 @@ describe("/store/carts", () => {
})
it("fails on apply discount if limit has been reached", async () => {
const api = useApi()
const code = "SPENT"
const err = await api
@@ -1176,8 +1117,6 @@ describe("/store/carts", () => {
})
it("successfully passes customer conditions with `in` operator and applies discount", async () => {
const api = useApi()
await simpleCustomerFactory(dbConnection, {
id: "cus_1234",
email: "oli@medusajs.com",
@@ -1249,8 +1188,6 @@ describe("/store/carts", () => {
})
it("throws if no customer is associated with the cart while applying a customer groups discount", async () => {
const api = useApi()
await simpleCustomerGroupFactory(dbConnection, {
id: "customer-group-2",
name: "Loyal",
@@ -1353,8 +1290,6 @@ describe("/store/carts", () => {
.of(discountCart)
.add(discount)
const api = useApi()
let response = await api.post(`/store/carts/${cartId}/line-items`, {
quantity: 1,
variant_id: "test-variant-quantity",
@@ -1383,8 +1318,6 @@ describe("/store/carts", () => {
})
it("successfully passes customer conditions with `not_in` operator and applies discount", async () => {
const api = useApi()
await simpleCustomerFactory(dbConnection, {
id: "cus_1234",
email: "oli@medusajs.com",
@@ -1461,8 +1394,6 @@ describe("/store/carts", () => {
})
it("successfully applies discount in case no conditions is defined for group", async () => {
const api = useApi()
await simpleCustomerFactory(dbConnection, {
id: "cus_1234",
email: "oli@medusajs.com",
@@ -1522,8 +1453,6 @@ describe("/store/carts", () => {
})
it("fails to apply discount if customer group is part of `not_in` conditions", async () => {
const api = useApi()
await simpleCustomerFactory(dbConnection, {
id: "cus_1234",
email: "oli@medusajs.com",
@@ -1588,8 +1517,6 @@ describe("/store/carts", () => {
})
it("fails to apply discount if customer group is not part of `in` conditions", async () => {
const api = useApi()
await simpleCustomerFactory(dbConnection, {
id: "cus_1234",
email: "oli@medusajs.com",
@@ -1660,7 +1587,6 @@ describe("/store/carts", () => {
it("fails to apply expired discount", async () => {
expect.assertions(2)
const api = useApi()
const code = "EXP_DISC"
@@ -1676,7 +1602,6 @@ describe("/store/carts", () => {
it("fails on discount before start day", async () => {
expect.assertions(2)
const api = useApi()
const code = "PREM_DISC"
@@ -1693,8 +1618,6 @@ describe("/store/carts", () => {
})
it("fails on apply invalid dynamic discount", async () => {
const api = useApi()
const code = "INV_DYN_DISC"
const err = await api
@@ -1708,8 +1631,6 @@ describe("/store/carts", () => {
})
it("Applies dynamic discount to cart correctly", async () => {
const api = useApi()
const cart = await api.post("/store/carts/test-cart", {
discounts: [{ code: "DYN_DISC" }],
})
@@ -1719,8 +1640,6 @@ describe("/store/carts", () => {
})
it("successfully apply a fixed discount with total allocation and return the total with the right precision", async () => {
const api = useApi()
const cartId = "test-cart"
const quantity = 2
@@ -1803,8 +1722,6 @@ describe("/store/carts", () => {
})
it("updates cart customer id", async () => {
const api = useApi()
const response = await api.post("/store/carts/test-cart", {
customer_id: "test-customer-2",
})
@@ -1813,8 +1730,6 @@ describe("/store/carts", () => {
})
it("should remove shipping on line item remove", async () => {
const api = useApi()
const cartId = "test-cart-2"
const lineId = "test-item"
const optionId = "test-option"
@@ -1839,8 +1754,6 @@ describe("/store/carts", () => {
})
it("should remove shipping on line item update", async () => {
const api = useApi()
const cartId = "test-cart-2"
const lineId = "test-item"
const optionId = "test-option"
@@ -1868,8 +1781,6 @@ describe("/store/carts", () => {
})
it("should remove shipping on line item add", async () => {
const api = useApi()
const cartId = "test-cart-2"
const optionId = "test-option"
@@ -1894,8 +1805,6 @@ describe("/store/carts", () => {
})
it("updates prices when cart customer id is updated", async () => {
const api = useApi()
const beforeUpdate = await api
.get(`/store/carts/test-cart-3`)
.catch((error) => console.log(error))
@@ -1920,8 +1829,6 @@ describe("/store/carts", () => {
})
it("on region update: updates line item prices", async () => {
const api = useApi()
const beforeUpdate = await api
.get(`/store/carts/test-cart-3`)
.catch((error) => console.log(error))
@@ -1952,8 +1859,6 @@ describe("/store/carts", () => {
})
it("on region update: refreshes line item adjustments", async () => {
const api = useApi()
const usdRegion = await api
.post(`/store/carts/test-cart-3/`, {
discounts: [{ code: "10PERCENT" }],
@@ -1988,8 +1893,6 @@ describe("/store/carts", () => {
})
it("on region update: removes line item adjustment if discount is not applicable in region", async () => {
const api = useApi()
const withDiscount = await api
.post(`/store/carts/test-cart-3/`, {
discounts: [{ code: "15PERCENT" }],
@@ -2042,8 +1945,6 @@ describe("/store/carts", () => {
})
it("updates address using string id", async () => {
const api = useApi()
const response = await api.post("/store/carts/test-cart", {
billing_address: "test-general-address",
shipping_address: "test-general-address",
@@ -2059,8 +1960,6 @@ describe("/store/carts", () => {
})
it("updates address", async () => {
const api = useApi()
const response = await api.post("/store/carts/test-cart", {
shipping_address: {
first_name: "clark",
@@ -2077,8 +1976,6 @@ describe("/store/carts", () => {
})
it("partially updates shipping and billing address while retaining the addresses country codes", async () => {
const api = useApi()
// Partially update the shipping address
await api
.post("/store/carts/test-cart", {
@@ -2115,8 +2012,6 @@ describe("/store/carts", () => {
})
it("adds free shipping to cart then removes it again", async () => {
const api = useApi()
let cart = await api.post(
"/store/carts/test-cart",
{
@@ -2150,8 +2045,6 @@ describe("/store/carts", () => {
region_id: "test-region",
})
const api = useApi()
await api.post(`/store/carts/test-cart-3`, {
gift_cards: [{ code: "GC_TEST" }],
})
@@ -2176,8 +2069,6 @@ describe("/store/carts", () => {
regions: ["test-region"],
})
const api = useApi()
await api
.post(`/store/carts/test-cart-3`, {
discounts: [{ code: "100PERCENT" }],
@@ -2197,7 +2088,6 @@ describe("/store/carts", () => {
})
it("complete cart with items inventory covered", async () => {
const api = useApi()
const getRes = await api.post(`/store/carts/test-cart-2/complete-cart`)
expect(getRes.status).toEqual(200)
@@ -2209,8 +2099,6 @@ describe("/store/carts", () => {
})
it("calculates correct payment totals on cart completion taking into account line item adjustments", async () => {
const api = useApi()
await api.post("/store/carts/test-cart-3", {
discounts: [{ code: "CREATED" }],
})
@@ -2235,8 +2123,6 @@ describe("/store/carts", () => {
})
it("should return early, if cart is already completed", async () => {
const api = useApi()
const completedCart = await api.post(
`/store/carts/test-cart-2/complete-cart`
)
@@ -2272,8 +2158,6 @@ describe("/store/carts", () => {
})
await manager.save(li)
const api = useApi()
try {
await api.post(`/store/carts/test-cart-2/complete-cart`)
} catch (e) {
@@ -2308,8 +2192,6 @@ describe("/store/carts", () => {
"UPDATE swap SET cart_id='swap-cart' where id='test-swap'"
)
const api = useApi()
try {
await api.post(`/store/carts/swap-cart/complete-cart`)
} catch (e) {
@@ -2347,8 +2229,6 @@ describe("/store/carts", () => {
)
await manager.query("DELETE FROM payment where swap_id='test-swap'")
const api = useApi()
await api.post(`/store/carts/swap-cart/complete-cart`)
// check to see if payment is authorized and cart is completed
@@ -2365,8 +2245,6 @@ describe("/store/carts", () => {
await manager.query("DELETE FROM payment where swap_id='test-swap'")
const api = useApi()
await api.post(`/store/carts/swap-cart/complete-cart`)
const alreadyCompletedCart = await api.post(
@@ -2384,7 +2262,6 @@ describe("/store/carts", () => {
})
it("completes cart with a non-customer and for a customer with the same email created later the order doesn't show up", async () => {
const api = useApi()
const customerEmail = "test-email-for-non-existent-customer@test.com"
const product = await simpleProductFactory(dbConnection)
@@ -2419,7 +2296,8 @@ describe("/store/carts", () => {
password: "test",
})
const [authCookie] = customerResponse.headers["set-cookie"][0].split(";")
const [authCookie] =
customerResponse.headers["set-cookie"][0].split(";")
const customerOrdersResponse = await api
.get("/store/customers/me/orders?status[]=completed", {
@@ -2436,7 +2314,6 @@ describe("/store/carts", () => {
})
it("complete cart throws if there is no customer on the cart", async () => {
const api = useApi()
const product = await simpleProductFactory(dbConnection)
const region = await simpleRegionFactory(dbConnection, { tax_rate: 10 })
const cart = await simpleCartFactory(dbConnection, {
@@ -2492,13 +2369,7 @@ describe("/store/carts", () => {
})
})
afterEach(async () => {
await doAfterEach()
})
it("adds a normal shipping method to cart", async () => {
const api = useApi()
const cartWithShippingMethod = await api.post(
"/store/carts/test-cart/shipping-methods",
{
@@ -2507,7 +2378,9 @@ describe("/store/carts", () => {
{ withCredentials: true }
)
expect(cartWithShippingMethod.data.cart.shipping_methods).toContainEqual(
expect(
cartWithShippingMethod.data.cart.shipping_methods
).toContainEqual(
expect.objectContaining({ shipping_option_id: "test-option" })
)
expect(cartWithShippingMethod.status).toEqual(200)
@@ -2516,8 +2389,6 @@ 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 = "test-option"
const api = useApi()
const cartWithCustomShippingMethod = await api
.post(
"/store/carts/test-cart-with-cso/shipping-methods",
@@ -2540,8 +2411,6 @@ describe("/store/carts", () => {
})
it("given a cart with custom options and an option id not corresponding to any custom shipping option, then it should throw an invalid error", async () => {
const api = useApi()
try {
await api.post(
"/store/carts/test-cart-with-cso/shipping-methods",
@@ -2557,8 +2426,6 @@ describe("/store/carts", () => {
})
it("adds a giftcard to cart, but ensures discount only applied to discountable items", async () => {
const api = useApi()
// Add standard line item to cart
await api.post(
"/store/carts/test-cart/line-items",
@@ -2616,7 +2483,6 @@ describe("/store/carts", () => {
})
it("adds no more than 1 shipping method per shipping profile", async () => {
const api = useApi()
const addShippingMethod = async (option_id) => {
return await api.post(
"/store/carts/test-cart/shipping-methods",
@@ -2667,13 +2533,7 @@ describe("/store/carts", () => {
)
})
afterEach(async () => {
await doAfterEach()
})
it("removes free shipping and updates shipping total", async () => {
const api = useApi()
const cartWithFreeShipping = await api.post(
"/store/carts/test-cart",
{
@@ -2728,8 +2588,6 @@ describe("/store/carts", () => {
.of(discountCart)
.add(discount)
const api = useApi()
let response = await api.post(`/store/carts/${cartId}/line-items`, {
quantity: 1,
variant_id: "test-variant-quantity",
@@ -2767,13 +2625,7 @@ describe("/store/carts", () => {
})
})
afterEach(async () => {
await doAfterEach()
})
it("updates empty cart.customer_id on cart retrieval", async () => {
const api = useApi()
const customer = await api.post(
"/store/customers",
{
@@ -2787,7 +2639,11 @@ describe("/store/carts", () => {
const cookie = customer.headers["set-cookie"][0]
const cart = await api.post("/store/carts", {}, { withCredentials: true })
const cart = await api.post(
"/store/carts",
{},
{ withCredentials: true }
)
const response = await api.get(`/store/carts/${cart.data.cart.id}`, {
headers: {
@@ -2796,13 +2652,13 @@ describe("/store/carts", () => {
withCredentials: true,
})
expect(response.data.cart.customer_id).toEqual(customer.data.customer.id)
expect(response.data.cart.customer_id).toEqual(
customer.data.customer.id
)
expect(response.status).toEqual(200)
})
it("updates cart.customer_id on cart retrieval if cart.customer_id differ from session customer", async () => {
const api = useApi()
const customer = await api.post(
"/store/customers",
{
@@ -2818,9 +2674,12 @@ describe("/store/carts", () => {
const cart = await api.post("/store/carts")
const updatedCart = await api.post(`/store/carts/${cart.data.cart.id}`, {
const updatedCart = await api.post(
`/store/carts/${cart.data.cart.id}`,
{
customer_id: "test-customer",
})
}
)
const response = await api.get(
`/store/carts/${updatedCart.data.cart.id}`,
@@ -2831,7 +2690,9 @@ describe("/store/carts", () => {
}
)
expect(response.data.cart.customer_id).toEqual(customer.data.customer.id)
expect(response.data.cart.customer_id).toEqual(
customer.data.customer.id
)
expect(response.status).toEqual(200)
})
})
@@ -2841,13 +2702,7 @@ describe("/store/carts", () => {
await cartSeeder(dbConnection)
})
afterEach(async () => {
await doAfterEach()
})
it("updates region only - single to multiple countries", async () => {
const api = useApi()
const { data, status } = await api
.post(`/store/carts/test-cart`, {
region_id: `test-region-multiple`,
@@ -2868,8 +2723,6 @@ describe("/store/carts", () => {
})
it("should reset the shipping_address on null value", async () => {
const api = useApi()
const { data, status } = await api
.post(`/store/carts/test-cart`, {
shipping_address: null,
@@ -2885,10 +2738,6 @@ describe("/store/carts", () => {
})
describe("ignore region update if value didn't change", () => {
afterEach(async () => {
await doAfterEach()
})
it("has no side-effects when updating region with no change", async () => {
const region = await simpleRegionFactory(dbConnection, {
countries: ["us", "ca"],
@@ -2908,8 +2757,6 @@ describe("/store/carts", () => {
},
})
const api = useApi()
const { data: preconditionData } = await api.get(
`/store/carts/${cart.id}`
)
@@ -2928,10 +2775,6 @@ describe("/store/carts", () => {
})
describe("calculated prices for shipping option", () => {
afterEach(async () => {
await doAfterEach()
})
it("it fetches prices with calculated amount", async () => {
const region = await simpleRegionFactory(dbConnection)
const product = await simpleProductFactory(dbConnection)
@@ -2951,8 +2794,6 @@ describe("/store/carts", () => {
data: { price: 123 },
})
const api = useApi()
const { data, status } = await api
.get(`/store/shipping-options/${cart.id}`)
.catch((err) => {
@@ -2966,10 +2807,6 @@ describe("/store/carts", () => {
})
describe("mix of calculated and flat rate prices", () => {
afterEach(async () => {
await doAfterEach()
})
it("it fetches prices with calculated amount", async () => {
const region = await simpleRegionFactory(dbConnection)
const product = await simpleProductFactory(dbConnection)
@@ -2994,8 +2831,6 @@ describe("/store/carts", () => {
data: { price: 123 },
})
const api = useApi()
const { data, status } = await api
.get(`/store/shipping-options/${cart.id}`)
.catch((err) => {
@@ -3018,4 +2853,5 @@ describe("/store/carts", () => {
)
})
})
},
})
@@ -16,9 +16,9 @@ import {
simpleSalesChannelFactory,
} from "./simple-sales-channel-factory"
import { DataSource } from "typeorm"
import faker from "faker"
import { generateEntityId } from "@medusajs/utils"
import faker from "faker"
import { DataSource } from "typeorm"
export type ProductFactoryData = {
id?: string