Feat: Add product tag endpoints, move tests to HTTP folder (#7591)
* chore: Move product type tests to HTTP folder * feat: Add product tags endpoints and move tests to HTTP folder
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import {
|
||||
createAdminUser,
|
||||
adminHeaders,
|
||||
} from "../../../../helpers/create-admin-user"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
env: {},
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
let tag1
|
||||
let tag2
|
||||
|
||||
beforeEach(async () => {
|
||||
const container = getContainer()
|
||||
await createAdminUser(dbConnection, adminHeaders, container)
|
||||
|
||||
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 /admin/product-tags", () => {
|
||||
it("returns a list of product tags", async () => {
|
||||
const res = await api.get("/admin/product-tags", adminHeaders)
|
||||
|
||||
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" })])
|
||||
)
|
||||
})
|
||||
})
|
||||
// BREAKING: Removed a test that filtered tags by discount condition id, which is no longer supported
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,73 @@
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import {
|
||||
createAdminUser,
|
||||
adminHeaders,
|
||||
} from "../../../../helpers/create-admin-user"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
env: {},
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
let type1
|
||||
let type2
|
||||
|
||||
beforeEach(async () => {
|
||||
const container = getContainer()
|
||||
await createAdminUser(dbConnection, adminHeaders, container)
|
||||
|
||||
type1 = (
|
||||
await api.post(
|
||||
"/admin/product-types",
|
||||
{
|
||||
value: "test1",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.product_type
|
||||
|
||||
type2 = (
|
||||
await api.post(
|
||||
"/admin/product-types",
|
||||
{
|
||||
value: "test2",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.product_type
|
||||
})
|
||||
|
||||
describe("/admin/product-types", () => {
|
||||
it("returns a list of product types", async () => {
|
||||
const res = await api.get("/admin/product-types", adminHeaders)
|
||||
|
||||
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("/admin/product-types?q=test1", adminHeaders)
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
|
||||
// The value of the type should match the search param
|
||||
expect(res.data.product_types).toEqual([
|
||||
expect.objectContaining({
|
||||
value: "test1",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
// BREAKING: Removed a test around filtering based on discount condition id, which is no longer supported
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user