chore(orchestration): validate PK when throwIfKeyNotFound (#11190)
CLOSES: FRMW-2895
This commit is contained in:
committed by
GitHub
parent
e0bd2a79b0
commit
e98d3c615e
@@ -1,6 +1,6 @@
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { IRegionModuleService, RemoteQueryFunction } from "@medusajs/types"
|
||||
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import { createAdminUser } from "../../..//helpers/create-admin-user"
|
||||
import { adminHeaders } from "../../../helpers/create-admin-user"
|
||||
|
||||
@@ -70,6 +70,77 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
})
|
||||
|
||||
it("should fail to retrieve not passing primary key in filters", async () => {
|
||||
const noPk = remoteQuery(
|
||||
{
|
||||
region: {
|
||||
fields: ["id", "currency_code"],
|
||||
},
|
||||
},
|
||||
{ throwIfKeyNotFound: true }
|
||||
)
|
||||
await expect(noPk).rejects.toThrow(
|
||||
"Region: Primary key(s) [id, iso_2] not found in filters"
|
||||
)
|
||||
|
||||
const noPk2 = remoteQuery(
|
||||
{
|
||||
country: {
|
||||
fields: ["*"],
|
||||
},
|
||||
},
|
||||
{ throwIfKeyNotFound: true }
|
||||
)
|
||||
await expect(noPk2).rejects.toThrow(
|
||||
"Country: Primary key(s) [id, iso_2] not found in filters"
|
||||
)
|
||||
|
||||
const noPk3 = remoteQuery(
|
||||
{
|
||||
country: {
|
||||
fields: ["*"],
|
||||
__args: {
|
||||
iso_2: undefined,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ throwIfKeyNotFound: true }
|
||||
)
|
||||
await expect(noPk3).rejects.toThrow(
|
||||
"Country: Value for primary key iso_2 not found in filters"
|
||||
)
|
||||
|
||||
const noPk4 = remoteQuery(
|
||||
{
|
||||
region: {
|
||||
fields: ["id", "currency_code"],
|
||||
__args: {
|
||||
id: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ throwIfKeyNotFound: true }
|
||||
)
|
||||
await expect(noPk4).rejects.toThrow(
|
||||
"Region: Value for primary key id not found in filters"
|
||||
)
|
||||
|
||||
const noPk5 = remoteQuery(
|
||||
{
|
||||
region: {
|
||||
fields: ["id", "currency_code"],
|
||||
__args: {
|
||||
currency_code: "EUR",
|
||||
},
|
||||
},
|
||||
},
|
||||
{ throwIfKeyNotFound: true }
|
||||
)
|
||||
await expect(noPk5).rejects.toThrow(
|
||||
"Region: Primary key(s) [id, iso_2] not found in filters"
|
||||
)
|
||||
})
|
||||
|
||||
it("should fail if a expected relation is not found", async () => {
|
||||
const region = await regionModule.createRegions({
|
||||
name: "Test Region",
|
||||
|
||||
Reference in New Issue
Block a user