fix(framework): exclude nested fields when excluding requested field (#9979)

This commit is contained in:
Carlos R. L. Rodrigues
2024-11-07 18:26:02 -03:00
committed by GitHub
parent af9eec73df
commit 6496789c65
3 changed files with 31 additions and 4 deletions
@@ -1,6 +1,7 @@
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
import { IStoreModuleService } from "@medusajs/types"
import { ApiKeyType, Modules, ProductStatus } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
import qs from "qs"
import {
adminHeaders,
createAdminUser,
@@ -8,7 +9,6 @@ import {
generateStoreHeaders,
} from "../../../../helpers/create-admin-user"
import { getProductFixture } from "../../../../helpers/fixtures"
import qs from "qs"
jest.setTimeout(30000)
@@ -589,6 +589,19 @@ medusaIntegrationTestRunner({
])
})
it("should list all products excluding variants", async () => {
let response = await api.get(
`/admin/products?fields=-variants`,
adminHeaders
)
expect(response.data.count).toEqual(4)
for (let product of response.data.products) {
expect(product.variants).toBeUndefined()
}
})
it("should list all products for a sales channel", async () => {
const salesChannel = await createSalesChannel(
{ name: "sales channel test" },