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:
@@ -1,6 +1,10 @@
|
||||
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||
import {
|
||||
createAdminUser,
|
||||
generatePublishableKey,
|
||||
generateStoreHeaders,
|
||||
} from "../../../../helpers/create-admin-user"
|
||||
import { getProductFixture } from "../../../../helpers/fixtures"
|
||||
|
||||
jest.setTimeout(50000)
|
||||
@@ -23,6 +27,7 @@ medusaIntegrationTestRunner({
|
||||
let product
|
||||
let variant
|
||||
let region
|
||||
let storeHeaders
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
@@ -30,6 +35,9 @@ medusaIntegrationTestRunner({
|
||||
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
appContainer = getContainer()
|
||||
const publishableKey = await generatePublishableKey(appContainer)
|
||||
storeHeaders = generateStoreHeaders({ publishableKey })
|
||||
|
||||
region = (
|
||||
await api.post(
|
||||
@@ -87,7 +95,8 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
|
||||
let response = await api.get(
|
||||
`/store/products/${product.id}?currency_code=usd`
|
||||
`/store/products/${product.id}?currency_code=usd`,
|
||||
storeHeaders
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -149,7 +158,8 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
|
||||
let response = await api.get(
|
||||
`/store/products/${product.id}?currency_code=usd`
|
||||
`/store/products/${product.id}?currency_code=usd`,
|
||||
storeHeaders
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
@@ -184,10 +194,14 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.customer_group
|
||||
|
||||
const authResponse = await api.post("/store/auth", {
|
||||
email: "test5@email-pl.com",
|
||||
password: "test",
|
||||
})
|
||||
const authResponse = await api.post(
|
||||
"/store/auth",
|
||||
{
|
||||
email: "test5@email-pl.com",
|
||||
password: "test",
|
||||
},
|
||||
storeHeaders
|
||||
)
|
||||
|
||||
const [authCookie] = authResponse.headers["set-cookie"][0].split(";")
|
||||
|
||||
@@ -215,6 +229,7 @@ medusaIntegrationTestRunner({
|
||||
{
|
||||
headers: {
|
||||
Cookie: authCookie,
|
||||
...storeHeaders.headers,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user