mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-14 18:39:54 +08:00
🐛 fix(sql-editor): 移除对象信息未命中误报提示
- 取消对象信息未命中时的提示弹窗 - 保留已识别对象的 hover 与超链接行为 - 补充未命中静默回归测试
This commit is contained in:
@@ -983,6 +983,35 @@ describe('QueryEditor external SQL save', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
it('keeps ctrl+q object info silent when no object is recognized', async () => {
|
||||
editorState.value = 'select 1';
|
||||
autoFetchState.visible = true;
|
||||
backendApp.DBGetDatabases.mockResolvedValueOnce({ success: true, data: [{ Database: 'main' }] });
|
||||
backendApp.DBGetTables.mockResolvedValueOnce({ success: true, data: [{ Tables_in_main: 'users' }] });
|
||||
backendApp.DBGetAllColumns.mockResolvedValueOnce({ success: true, data: [] });
|
||||
|
||||
await act(async () => {
|
||||
create(<QueryEditor tab={createTab({ query: editorState.value, dbName: 'main' })} />);
|
||||
});
|
||||
await act(async () => {
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
});
|
||||
|
||||
const showObjectInfoAction = editorState.editor.addAction.mock.calls
|
||||
.map((call: any[]) => call[0])
|
||||
.find((action: any) => action?.id === 'gonavi.queryEditor.showObjectInfo');
|
||||
expect(showObjectInfoAction).toBeTruthy();
|
||||
|
||||
editorState.position = { lineNumber: 1, column: 1 };
|
||||
await act(async () => {
|
||||
showObjectInfoAction.run();
|
||||
});
|
||||
|
||||
expect(editorState.contentHoverCalls).toHaveLength(0);
|
||||
expect(messageApi.info).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('adds separate object and column color decorations', async () => {
|
||||
editorState.value = 'select users.id from users';
|
||||
autoFetchState.visible = true;
|
||||
|
||||
@@ -2820,13 +2820,7 @@ const QueryEditor: React.FC<{ tab: TabData; isActive?: boolean }> = ({ tab, isAc
|
||||
keybindings: showObjectInfoKeybinding,
|
||||
run: () => {
|
||||
const preferredPosition = lastHoverTargetPositionRef.current || editor.getPosition?.();
|
||||
const shown = showObjectInfoAtPosition(preferredPosition);
|
||||
if (!shown) {
|
||||
void message.info({
|
||||
key: 'gonavi-query-editor-object-info-miss',
|
||||
content: '当前光标未定位到可识别的表或字段。',
|
||||
});
|
||||
}
|
||||
showObjectInfoAtPosition(preferredPosition);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user