fix(search): limit from UI not applied (closes #920)

This commit is contained in:
Elian Doran
2025-01-10 20:10:41 +02:00
parent 7ea324bc5b
commit 180af2ce30
2 changed files with 22 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
// but we access properties like "subExpressions" which is not defined in the "Expression" class.
import Expression from "../../src/services/search/expressions/expression.js";
import OrderByAndLimitExp from "../../src/services/search/expressions/order_by_and_limit.js";
import SearchContext from "../../src/services/search/search_context.js";
import parse from "../../src/services/search/services/parse.js";
@@ -244,6 +245,21 @@ describe("Parser", () => {
expect(thirdSub.constructor.name).toEqual("AttributeExistsExp");
expect(thirdSub.attributeName).toEqual("fourth");
});
it("parses limit without order by", () => {
const rootExp = parse({
fulltextTokens: tokens(["hello", "hi"]),
expressionTokens: [],
searchContext: new SearchContext({
excludeArchived: true,
limit: 2
})
});
expect(rootExp).toBeInstanceOf(OrderByAndLimitExp);
expect(rootExp.limit).toBe(2);
expect(rootExp.subExpression).toBeInstanceOf(AndExp);
});
});
describe("Invalid expressions", () => {