fix(medusa): Product repo typeorm issues (#4084)

* fix(medusa): Product repo typeorm issues

* chore: fixed category scopes

* WIP fix categories

* fix product repo to attach categories

* fix uni tests

* Create eighty-icons-exercise.md

* revert package.json

* fix change set

* last fixes

* cleanup iteration

* fix repository deep relations joining aliasing

* improve response time

* improve category test case

* fix free texts search

* fix repo

* centralise repository manipulation into utils and use the utils in the product repo

* fix product repo

* fix customer group

* update changeset

* fix customer group

* include feedback

* fix repo

* remove query strategy

---------

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
Adrien de Peretti
2023-05-16 09:36:52 +02:00
committed by GitHub
parent 26963acc0a
commit 9518efccae
9 changed files with 827 additions and 139 deletions
@@ -98,7 +98,7 @@ describe("/store/products", () => {
internalCategoryWithProduct = await simpleProductCategoryFactory(
dbConnection,
{
id: inactiveCategoryWithProductId,
id: internalCategoryWithProductId,
name: "inactive category with Product",
products: [{ id: testProductFilteringId2 }],
parent_category: nestedCategoryWithProduct,
@@ -219,6 +219,51 @@ describe("/store/products", () => {
)
})
it("returns only active and public products with include_category_children when categories are expanded", async () => {
const api = useApi()
const params = `id[]=${testProductFilteringId2}&expand=categories`
let response = await api.get(`/store/products?${params}`)
expect(response.status).toEqual(200)
expect(response.data.products).toHaveLength(1)
expect(response.data.products).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: testProductFilteringId2,
categories: [],
}),
])
)
const category = await simpleProductCategoryFactory(dbConnection, {
id: categoryWithProductId,
name: "category with Product 2",
products: [{ id: response.data.products[0].id }],
is_active: true,
is_internal: false,
})
response = await api.get(`/store/products?${params}`)
expect(response.status).toEqual(200)
expect(response.data.products).toHaveLength(1)
expect(response.data.products).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: testProductFilteringId2,
categories: expect.arrayContaining([
expect.objectContaining({
id: category.id,
}),
]),
}),
])
)
})
it("does not query products with category that are inactive", async () => {
const api = useApi()