mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-05 10:01:30 +08:00
🐛 fix(frontend): 修复 Redis 搜索匹配与输入交互体验
- Redis Key 搜索默认补全包含匹配并支持 ASCII 大小写不敏感 - Redis 标签页增加连接名与 host 摘要,区分同名 db 标签 - 抽取 inputAutoCap、redisSearchPattern、tabDisplay 共享工具并补充回归测试 - 覆盖连接配置、Redis 搜索、表设计、表概览和数据表筛选输入的自动纠正问题 - 在 macOS 文本输入面板关闭局部毛玻璃,修复输入法切换出现透明框
This commit is contained in:
41
frontend/src/utils/redisSearchPattern.test.ts
Normal file
41
frontend/src/utils/redisSearchPattern.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { normalizeRedisSearchDraftChange, normalizeRedisSearchInput } from './redisSearchPattern';
|
||||
|
||||
describe('normalizeRedisSearchInput', () => {
|
||||
it('returns wildcard for empty input', () => {
|
||||
expect(normalizeRedisSearchInput('')).toEqual({
|
||||
keyword: '',
|
||||
pattern: '*',
|
||||
});
|
||||
});
|
||||
|
||||
it('wraps plain keywords with wildcard for contains matching', () => {
|
||||
expect(normalizeRedisSearchInput('order')).toEqual({
|
||||
keyword: 'order',
|
||||
pattern: '*[oO][rR][dD][eE][rR]*',
|
||||
});
|
||||
});
|
||||
|
||||
it('builds ascii case-insensitive patterns for letter keywords', () => {
|
||||
expect(normalizeRedisSearchInput('agent')).toEqual({
|
||||
keyword: 'agent',
|
||||
pattern: '*[aA][gG][eE][nN][tT]*',
|
||||
});
|
||||
});
|
||||
|
||||
it('escapes redis glob special characters as literals', () => {
|
||||
expect(normalizeRedisSearchInput('user:*:[id]?')).toEqual({
|
||||
keyword: 'user:*:[id]?',
|
||||
pattern: '*[uU][sS][eE][rR]:\\*:\\[[iI][dD]\\]\\?*',
|
||||
});
|
||||
});
|
||||
|
||||
it('marks empty draft changes for immediate reset search', () => {
|
||||
expect(normalizeRedisSearchDraftChange('')).toEqual({
|
||||
keyword: '',
|
||||
pattern: '*',
|
||||
shouldSearchImmediately: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user