feat(medusa): Add /admin/products/:id/variants end point (#1471)
* feat(medusa): Add /admin/products/:id/variants end point * test(medusa): Fix get-variants test casees * feat(medusa): Include the config to the ProdutService#retrieveVariants as a method parameter * feat(medusa): Improve get-variants endpoint * feat(medusa): Improve get-variants endpoint * test(medusa): Fix unit tests * test(medusa): Fix unit tests * feat(medusa): Improve typings * feat(medusa): Update according to feedback * feat(medusa): Update according to feedback * test(medusa): Fix list-variants tests * feat(medusa): Getting the variants from the product end point should use the productVariantService * fix(medusa): list-variants expand possibly undefined * Fix(medusa): List-variants endpoint * fix(medusa): Tests suite for list-variant * test(integration-tests): Fix yarn lock * test(integration-tests): Fix yarn lock
This commit is contained in:
committed by
GitHub
parent
79345d27ec
commit
edeac8ac72
@@ -1387,6 +1387,48 @@ describe("/admin/products", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /admin/products/:id/variants", () => {
|
||||
beforeEach(async() => {
|
||||
try {
|
||||
await productSeeder(dbConnection)
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async() => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it('should return the variants related to the requested product', async () => {
|
||||
const api = useApi()
|
||||
|
||||
const res = await api
|
||||
.get("/admin/products/test-product/variants", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.variants.length).toBe(4)
|
||||
expect(res.data.variants).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ id: "test-variant", product_id: "test-product" }),
|
||||
expect.objectContaining({ id: "test-variant_1", product_id: "test-product" }),
|
||||
expect.objectContaining({ id: "test-variant_2", product_id: "test-product" }),
|
||||
expect.objectContaining({ id: "test-variant-sale", product_id: "test-product" }),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("updates a variant's default prices (ignores prices associated with a Price List)", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
"build": "babel src -d dist --extensions \".ts,.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/medusa": "1.2.1-dev-1650573289860",
|
||||
"@medusajs/medusa": "1.3.0-dev-1652692202580",
|
||||
"faker": "^5.5.3",
|
||||
"medusa-interfaces": "1.2.1-dev-1650573289860",
|
||||
"medusa-interfaces": "1.3.0-dev-1652692202580",
|
||||
"typeorm": "^0.2.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.12.10",
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/node": "^7.12.10",
|
||||
"babel-preset-medusa-package": "1.1.19-dev-1650573289860",
|
||||
"babel-preset-medusa-package": "1.1.19-dev-1652692202580",
|
||||
"jest": "^26.6.3"
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user