feat(redis): 新增 Key 精确搜索模式

- 增加 Redis Key 模糊/精确搜索切换
- 精确模式不再追加通配符并保留大小写敏感匹配
- 转义 Redis glob 特殊字符避免误匹配
- 补充搜索模式回归测试
This commit is contained in:
Syngnat
2026-04-26 20:34:07 +08:00
parent 21222cf9f4
commit a06f45da28
3 changed files with 52 additions and 9 deletions

View File

@@ -31,6 +31,20 @@ describe('normalizeRedisSearchInput', () => {
});
});
it('uses literal key pattern without fuzzy wildcards in exact mode', () => {
expect(normalizeRedisSearchInput('Order:1001', 'exact')).toEqual({
keyword: 'Order:1001',
pattern: 'Order:1001',
});
});
it('escapes redis glob special characters in exact mode without adding wildcards', () => {
expect(normalizeRedisSearchInput('user:*:[id]?\\raw', 'exact')).toEqual({
keyword: 'user:*:[id]?\\raw',
pattern: 'user:\\*:\\[id\\]\\?\\\\raw',
});
});
it('marks empty draft changes for immediate reset search', () => {
expect(normalizeRedisSearchDraftChange('')).toEqual({
keyword: '',