Skip to content

Commit

Permalink
feat: Add collection and category endpoints to store (#7155)
Browse files Browse the repository at this point in the history
* feat: Add collection endpoints to store

* feat: Add category store endpoints
  • Loading branch information
sradevski committed May 1, 2024
1 parent 2c807df commit ec37576
Show file tree
Hide file tree
Showing 25 changed files with 838 additions and 496 deletions.

This file was deleted.

90 changes: 0 additions & 90 deletions integration-tests/api/__tests__/store/collections.js

This file was deleted.

92 changes: 92 additions & 0 deletions integration-tests/api/__tests__/store/collections.ts
@@ -0,0 +1,92 @@
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import {
createAdminUser,
adminHeaders,
} from "../../../helpers/create-admin-user"

jest.setTimeout(30000)

medusaIntegrationTestRunner({
env: { MEDUSA_FF_PRODUCT_CATEGORIES: true },
testSuite: ({ dbConnection, getContainer, api }) => {
let baseCollection
let baseCollection1
let baseCollection2

beforeEach(async () => {
const container = getContainer()
await createAdminUser(dbConnection, adminHeaders, container)

baseCollection = (
await api.post(
"/admin/collections",
{ title: "test-collection" },
adminHeaders
)
).data.collection

baseCollection1 = (
await api.post(
"/admin/collections",
{ title: "test-collection1" },
adminHeaders
)
).data.collection

baseCollection2 = (
await api.post(
"/admin/collections",
{ title: "test-collection2" },
adminHeaders
)
).data.collection
})

describe("/store/collections", () => {
describe("/store/collections/:id", () => {
it("gets collection", async () => {
const response = await api.get(
`/store/collections/${baseCollection.id}`
)

expect(response.data.collection).toEqual(
expect.objectContaining({
id: baseCollection.id,
created_at: expect.any(String),
updated_at: expect.any(String),
})
)
})
})

describe("/store/collections", () => {
it("lists collections", async () => {
const response = await api.get("/store/collections")

expect(response.data).toEqual({
collections: [
expect.objectContaining({
id: baseCollection2.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
expect.objectContaining({
id: baseCollection1.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
expect.objectContaining({
id: baseCollection.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
],
count: 3,
limit: 10,
offset: 0,
})
})
})
})
},
})

0 comments on commit ec37576

Please sign in to comment.