mirror of
https://github.com/chrisbenincasa/tunarr.git
synced 2026-04-18 09:03:35 -04:00
fix(search): render "starts with" operator as < in filter string (#1762)
* fix(search): render "starts with" operator as < in filter string Add missing entry to `indexOperatorToSyntax` so that `searchFilterToString` converts the `starts with` API operator back to `<` instead of displaying the literal string "starts with" in the filter box. Add unit tests to prevent regression. Fixes #1760 * refactor: use helper method in test --------- Co-authored-by: Corey Vaillancourt <coreyjv@gmail.com>
This commit is contained in:
committed by
GitHub
parent
625deee506
commit
e09c46a19a
@@ -627,4 +627,26 @@ describe('searchFilterToString', () => {
|
||||
const request = parsedSearchToRequest(query);
|
||||
expect(searchFilterToString(request)).toEqual('genre in ["comedy"]');
|
||||
});
|
||||
|
||||
test('starts with renders as < not literal "starts with"', () => {
|
||||
const filter = {
|
||||
type: 'value',
|
||||
fieldSpec: {
|
||||
key: 'title',
|
||||
name: 'title',
|
||||
op: 'starts with',
|
||||
type: 'string',
|
||||
value: ['The'],
|
||||
},
|
||||
} satisfies SearchFilter;
|
||||
|
||||
expect(searchFilterToString(filter)).toEqual('title < "The"');
|
||||
});
|
||||
|
||||
test('round-trips starts with through parse and stringify', () => {
|
||||
const input = 'title < "The"';
|
||||
const query = parseAndCheckExpression(input);
|
||||
const request = parsedSearchToRequest(query);
|
||||
expect(searchFilterToString(request)).toEqual(input);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -234,7 +234,16 @@ const SearchExpressionLexer = new Lexer({
|
||||
defaultMode: 'normalMode',
|
||||
});
|
||||
|
||||
const StringOps = ['=', '!=', '<', '<=', 'in', 'not in', 'contains', 'not contains'] as const;
|
||||
const StringOps = [
|
||||
'=',
|
||||
'!=',
|
||||
'<',
|
||||
'<=',
|
||||
'in',
|
||||
'not in',
|
||||
'contains',
|
||||
'not contains',
|
||||
] as const;
|
||||
type StringOps = TupleToUnion<typeof StringOps>;
|
||||
const NumericOps = ['=', '!=', '<', '<=', '>', '>=', 'between'] as const;
|
||||
type NumericOps = TupleToUnion<typeof NumericOps>;
|
||||
@@ -364,6 +373,7 @@ const indexOperatorToSyntax: Dictionary<string> = {
|
||||
contains: '~',
|
||||
'not contains': '!~',
|
||||
to: 'between',
|
||||
'starts with': '<',
|
||||
};
|
||||
|
||||
function normalizeReleaseDate(value: string) {
|
||||
|
||||
Reference in New Issue
Block a user