chore(types, api): support shipping option type api endpoints (#13191)

* chore(types, api): support shipping option type api endpoints

* core flows

* api

* typos

* compiler errors

* integration tests

* remove metadata

* changeset

* modify test

* upsert

* change remote query

* minor to patch

* description optional

* description optional

* woops my bad

* my bad again

---------

Co-authored-by: william bouchard <williambouchard@williams-MacBook-Pro.local>
This commit is contained in:
William Bouchard
2025-08-14 10:15:51 -04:00
committed by GitHub
parent aa27240b7f
commit 34c3c14e0a
29 changed files with 1240 additions and 105 deletions

View File

@@ -0,0 +1,105 @@
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
import { adminHeaders, createAdminUser, } 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/shipping-option-types",
{
label: "Test1",
code: "test1",
description: "Test1 description",
},
adminHeaders
)
).data.shipping_option_type
type2 = (
await api.post(
"/admin/shipping-option-types",
{
label: "Test2",
code: "test2",
description: "Test2 description",
},
adminHeaders
)
).data.shipping_option_type
})
describe("/admin/shipping-option-types", () => {
it("returns a list of shipping option types", async () => {
const res = await api.get("/admin/shipping-option-types", adminHeaders)
expect(res.status).toEqual(200)
expect(res.data.shipping_option_types).toEqual(
expect.arrayContaining([
{
id: expect.stringMatching(/sotype_.{24}/),
label: "Test1",
code: "test1",
description: "Test1 description",
created_at: expect.any(String),
updated_at: expect.any(String),
},
{
id: expect.stringMatching(/sotype_.{24}/),
label: "Test2",
code: "test2",
description: "Test2 description",
created_at: expect.any(String),
updated_at: expect.any(String),
},
])
)
})
it("returns a list of shipping option types matching free text search param", async () => {
const res = await api.get("/admin/shipping-option-types?code=test1", adminHeaders)
expect(res.status).toEqual(200)
expect(res.data.shipping_option_types).toEqual([
{
id: expect.stringMatching(/sotype_.{24}/),
label: "Test1",
code: "test1",
description: "Test1 description",
created_at: expect.any(String),
updated_at: expect.any(String),
},
])
})
})
describe("/admin/shipping-option-types/:id", () => {
it("returns a shipping option type", async () => {
const res = await api.get(
`/admin/shipping-option-types/${type1.id}`,
adminHeaders
)
expect(res.status).toEqual(200)
expect(res.data.shipping_option_type).toEqual({
id: expect.stringMatching(/sotype_.{24}/),
label: "Test1",
code: "test1",
description: "Test1 description",
created_at: expect.any(String),
updated_at: expect.any(String),
})
})
})
},
})