feat(medusa,product,types): product type & tag store missing endpoints (#11057)
* wip: tag endpoints * feat: types, product types * feat: tests * fix: update product type schema
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import {
|
||||
createAdminUser,
|
||||
adminHeaders,
|
||||
generatePublishableKey,
|
||||
generateStoreHeaders,
|
||||
} from "../../../../helpers/create-admin-user"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
env: {},
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
let tag1
|
||||
let tag2
|
||||
let publishableKey
|
||||
let storeHeaders
|
||||
|
||||
beforeEach(async () => {
|
||||
const container = getContainer()
|
||||
await createAdminUser(dbConnection, adminHeaders, container)
|
||||
|
||||
publishableKey = await generatePublishableKey(container)
|
||||
storeHeaders = generateStoreHeaders({ publishableKey })
|
||||
|
||||
tag1 = (
|
||||
await api.post(
|
||||
"/admin/product-types",
|
||||
{
|
||||
value: "test1",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.product_type
|
||||
|
||||
tag2 = (
|
||||
await api.post(
|
||||
"/admin/product-types",
|
||||
{
|
||||
value: "test2",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.product_type
|
||||
})
|
||||
|
||||
describe("GET /store/product-types", () => {
|
||||
it("returns a list of product types", async () => {
|
||||
const res = await api.get("/store/product-types", storeHeaders)
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.product_types).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
value: "test1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
value: "test2",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("returns a list of product types matching free text search param", async () => {
|
||||
const res = await api.get("/store/product-types?q=1", storeHeaders)
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.product_types.length).toEqual(1)
|
||||
expect(res.data.product_types).toEqual(
|
||||
expect.arrayContaining([expect.objectContaining({ value: "test1" })])
|
||||
)
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,75 @@
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import {
|
||||
createAdminUser,
|
||||
adminHeaders,
|
||||
generatePublishableKey,
|
||||
generateStoreHeaders,
|
||||
} from "../../../../helpers/create-admin-user"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
env: {},
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
let tag1
|
||||
let tag2
|
||||
let publishableKey
|
||||
let storeHeaders
|
||||
|
||||
beforeEach(async () => {
|
||||
const container = getContainer()
|
||||
await createAdminUser(dbConnection, adminHeaders, container)
|
||||
|
||||
publishableKey = await generatePublishableKey(container)
|
||||
storeHeaders = generateStoreHeaders({ publishableKey })
|
||||
|
||||
tag1 = (
|
||||
await api.post(
|
||||
"/admin/product-tags",
|
||||
{
|
||||
value: "test1",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.product_tag
|
||||
|
||||
tag2 = (
|
||||
await api.post(
|
||||
"/admin/product-tags",
|
||||
{
|
||||
value: "test2",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.product_tag
|
||||
})
|
||||
|
||||
describe("GET /store/product-tags", () => {
|
||||
it("returns a list of product tags", async () => {
|
||||
const res = await api.get("/store/product-tags", storeHeaders)
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.product_tags).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
value: "test1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
value: "test2",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("returns a list of product tags matching free text search param", async () => {
|
||||
const res = await api.get("/admin/product-tags?q=1", adminHeaders)
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.product_tags.length).toEqual(1)
|
||||
expect(res.data.product_tags).toEqual(
|
||||
expect.arrayContaining([expect.objectContaining({ value: "test1" })])
|
||||
)
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user