@labdigital/commercetools-mock 2.53.0 → 2.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -88,6 +88,15 @@ const resolveValue = (obj: any, val: TypeSymbol): any => {
|
|
|
88
88
|
throw new PredicateError("Internal error");
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// variants() includes both masterVariant and variants for predicates
|
|
92
|
+
if (
|
|
93
|
+
val.value === "variants" &&
|
|
94
|
+
obj.masterVariant &&
|
|
95
|
+
obj.variants !== undefined
|
|
96
|
+
) {
|
|
97
|
+
return [obj.masterVariant, ...(obj.variants ?? [])];
|
|
98
|
+
}
|
|
99
|
+
|
|
91
100
|
if (!(val.value in obj)) {
|
|
92
101
|
if (Array.isArray(obj)) {
|
|
93
102
|
return Object.values(obj)
|
|
@@ -230,7 +239,7 @@ const generateMatchFunc = (predicate: string): MatchFunc => {
|
|
|
230
239
|
|
|
231
240
|
.led("AND", 5, ({ left, bp }) => {
|
|
232
241
|
const expr = parser.parse({ terminals: [bp - 1] });
|
|
233
|
-
return (obj: any) => left(obj) && expr(obj);
|
|
242
|
+
return (obj: any, vars: object) => left(obj, vars) && expr(obj, vars);
|
|
234
243
|
})
|
|
235
244
|
.led("OR", 5, ({ left, token, bp }) => {
|
|
236
245
|
const expr = parser.parse({ terminals: [bp - 1] });
|
|
@@ -97,6 +97,10 @@ beforeEach(async () => {
|
|
|
97
97
|
name: "number",
|
|
98
98
|
value: 4 as any,
|
|
99
99
|
},
|
|
100
|
+
{
|
|
101
|
+
name: "store",
|
|
102
|
+
value: ["test-store"],
|
|
103
|
+
},
|
|
100
104
|
],
|
|
101
105
|
},
|
|
102
106
|
variants: [
|
|
@@ -252,6 +256,30 @@ describe("Product Projection Query - Generic", () => {
|
|
|
252
256
|
}
|
|
253
257
|
});
|
|
254
258
|
|
|
259
|
+
test("Filter on complex query", async () => {
|
|
260
|
+
{
|
|
261
|
+
const response = await supertest(ctMock.app)
|
|
262
|
+
.get("/dummy/product-projections")
|
|
263
|
+
.query({
|
|
264
|
+
limit: 50,
|
|
265
|
+
where: [
|
|
266
|
+
'slug(nl-NL=:slug) and variants(attributes(name="store" and value="test-store"))',
|
|
267
|
+
],
|
|
268
|
+
"var.slug": "test-product",
|
|
269
|
+
"var.store": "test-store",
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const result: ProductProjectionPagedSearchResponse = response.body;
|
|
273
|
+
expect(result).toEqual({
|
|
274
|
+
count: 1,
|
|
275
|
+
limit: 50,
|
|
276
|
+
offset: 0,
|
|
277
|
+
total: 1,
|
|
278
|
+
results: [productProjection],
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
255
283
|
test("Filter on invalid slug", async () => {
|
|
256
284
|
{
|
|
257
285
|
const response = await supertest(ctMock.app)
|