feat(utils,types,framework,medusa): store endpoints should require publishable key (#9068)
* feat(utils,types,framework,medusa): store endpoints should require publishable key * chore: fix specs * chore: fix more specs * chore: update js-sdk * chore: fix specs wrt to default SC * chore: revert custom headers + change error message * chore: fix specs * chore: fix new store specs
This commit is contained in:
+24
-10
@@ -2,6 +2,8 @@ import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import {
|
||||
adminHeaders,
|
||||
createAdminUser,
|
||||
generatePublishableKey,
|
||||
generateStoreHeaders,
|
||||
} from "../../../../helpers/create-admin-user"
|
||||
import { getProductFixture } from "../../../../helpers/fixtures"
|
||||
|
||||
@@ -9,10 +11,12 @@ jest.setTimeout(30000)
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
beforeAll(() => {})
|
||||
let storeHeaders
|
||||
|
||||
beforeEach(async () => {
|
||||
const container = getContainer()
|
||||
const publishableKey = await generatePublishableKey(container)
|
||||
storeHeaders = generateStoreHeaders({ publishableKey })
|
||||
await createAdminUser(dbConnection, adminHeaders, container)
|
||||
})
|
||||
|
||||
@@ -55,23 +59,32 @@ medusaIntegrationTestRunner({
|
||||
).data.product
|
||||
|
||||
cart = (
|
||||
await api.post("/store/carts", {
|
||||
region_id: region.id,
|
||||
items: [{ variant_id: product.variants[0].id, quantity: 1 }],
|
||||
})
|
||||
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,
|
||||
})
|
||||
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" }
|
||||
{ provider_id: "pp_system_default" },
|
||||
storeHeaders
|
||||
)
|
||||
|
||||
// Adding a second payment session to ensure only one session gets created
|
||||
@@ -79,7 +92,8 @@ medusaIntegrationTestRunner({
|
||||
data: { payment_collection },
|
||||
} = await api.post(
|
||||
`/store/payment-collections/${paymentCollection.id}/payment-sessions`,
|
||||
{ provider_id: "pp_system_default" }
|
||||
{ provider_id: "pp_system_default" },
|
||||
storeHeaders
|
||||
)
|
||||
|
||||
expect(payment_collection.payment_sessions).toEqual([
|
||||
|
||||
Reference in New Issue
Block a user