**What** - product <> shipping profile link - create and update product workflows/endpoints accepts shipping profile - pass shipping option id when creating fulfillment to allow overriding customer selected SO - validate shipping profile delete - dashboard - set shipping profile on product create - manage shipping profile for a product - **update the create fulfillment form** - other - fix create product form infinite rerenders --- CLOSES CMRC-831 CMRC-834 CMRC-836 CMRC-837 CMRC-838 CMRC-857 TRI-761
121 lines
3.3 KiB
TypeScript
121 lines
3.3 KiB
TypeScript
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
import {
|
|
adminHeaders,
|
|
createAdminUser,
|
|
generatePublishableKey,
|
|
generateStoreHeaders,
|
|
} from "../../../../helpers/create-admin-user"
|
|
import { getProductFixture } from "../../../../helpers/fixtures"
|
|
|
|
jest.setTimeout(30000)
|
|
|
|
medusaIntegrationTestRunner({
|
|
testSuite: ({ dbConnection, getContainer, api }) => {
|
|
let storeHeaders
|
|
|
|
beforeEach(async () => {
|
|
const container = getContainer()
|
|
const publishableKey = await generatePublishableKey(container)
|
|
storeHeaders = generateStoreHeaders({ publishableKey })
|
|
await createAdminUser(dbConnection, adminHeaders, container)
|
|
})
|
|
|
|
describe("POST /admin/payment-collections/:id/payment-sessions", () => {
|
|
let region
|
|
let product
|
|
let cart
|
|
let shippingProfile
|
|
|
|
beforeEach(async () => {
|
|
region = (
|
|
await api.post(
|
|
"/admin/regions",
|
|
{ name: "United States", currency_code: "usd", countries: ["us"] },
|
|
adminHeaders
|
|
)
|
|
).data.region
|
|
|
|
shippingProfile = (
|
|
await api.post(
|
|
`/admin/shipping-profiles`,
|
|
{ name: "Test", type: "default" },
|
|
adminHeaders
|
|
)
|
|
).data.shipping_profile
|
|
|
|
product = (
|
|
await api.post(
|
|
"/admin/products",
|
|
getProductFixture({
|
|
title: "test",
|
|
status: "published",
|
|
shipping_profile_id: shippingProfile.id,
|
|
variants: [
|
|
{
|
|
title: "Test variant",
|
|
manage_inventory: false,
|
|
prices: [
|
|
{
|
|
amount: 150,
|
|
currency_code: "usd",
|
|
rules: { region_id: region.id },
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}),
|
|
adminHeaders
|
|
)
|
|
).data.product
|
|
|
|
cart = (
|
|
await api.post(
|
|
"/store/carts",
|
|
{
|
|
region_id: region.id,
|
|
items: [{ variant_id: product.variants[0].id, quantity: 1 }],
|
|
},
|
|
storeHeaders
|
|
)
|
|
).data.cart
|
|
})
|
|
|
|
it("should create a payment session", async () => {
|
|
const paymentCollection = (
|
|
await api.post(
|
|
`/store/payment-collections`,
|
|
{
|
|
cart_id: cart.id,
|
|
},
|
|
storeHeaders
|
|
)
|
|
).data.payment_collection
|
|
|
|
await api.post(
|
|
`/store/payment-collections/${paymentCollection.id}/payment-sessions`,
|
|
{ provider_id: "pp_system_default" },
|
|
storeHeaders
|
|
)
|
|
|
|
// Adding a second payment session to ensure only one session gets created
|
|
const {
|
|
data: { payment_collection },
|
|
} = await api.post(
|
|
`/store/payment-collections/${paymentCollection.id}/payment-sessions`,
|
|
{ provider_id: "pp_system_default" },
|
|
storeHeaders
|
|
)
|
|
|
|
expect(payment_collection.payment_sessions).toEqual([
|
|
expect.objectContaining({
|
|
currency_code: "usd",
|
|
provider_id: "pp_system_default",
|
|
status: "pending",
|
|
amount: 150,
|
|
}),
|
|
])
|
|
})
|
|
})
|
|
},
|
|
})
|