mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-22 05:11:44 +08:00
✨ feat(query-editor): 支持还原 SQL 美化前内容
- 美化 SQL 前保存最近一次原始内容快照 - 在格式设置菜单提供还原上次美化入口 - 持久化查询标签页的美化恢复快照 - 补充编辑器与状态恢复回归测试
This commit is contained in:
@@ -1527,6 +1527,43 @@ describe('QueryEditor external SQL save', () => {
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(storeState.updateQueryTabDraft).toHaveBeenCalledWith('tab-1', {
|
||||
formatRestoreSnapshot: {
|
||||
query: 'select * from users where id=1',
|
||||
createdAt: expect.any(Number),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('restores the last pre-beautify SQL snapshot after reopening a query tab', async () => {
|
||||
let renderer!: ReactTestRenderer;
|
||||
const originalSql = 'select * from users where id=1';
|
||||
|
||||
await act(async () => {
|
||||
renderer = create(
|
||||
<QueryEditor
|
||||
tab={createTab({
|
||||
query: 'SELECT\n *\nFROM\n users\nWHERE\n id = 1',
|
||||
formatRestoreSnapshot: {
|
||||
query: originalSql,
|
||||
createdAt: 123,
|
||||
},
|
||||
})}
|
||||
/>,
|
||||
);
|
||||
});
|
||||
|
||||
const restoreButton = findButton(renderer, '还原上次美化');
|
||||
await act(async () => {
|
||||
await restoreButton.props.onClick();
|
||||
});
|
||||
|
||||
expect(editorState.value).toBe(originalSql);
|
||||
expect(storeState.updateQueryTabDraft).toHaveBeenCalledWith('tab-1', {
|
||||
query: originalSql,
|
||||
formatRestoreSnapshot: undefined,
|
||||
});
|
||||
expect(messageApi.success).toHaveBeenCalledWith('已还原到美化前 SQL');
|
||||
});
|
||||
|
||||
it('formats postgres window-function SQL with cast syntax through Monaco edits', async () => {
|
||||
|
||||
Reference in New Issue
Block a user