Files
MyGoNavi/frontend/src/utils/customConnectionDsn.test.ts
tianqijiuyun-latiao 255cc14bf6 🐛 fix(config-secret-storage): 修复密文编辑与状态残留问题
- 修复自定义连接编辑时已保存 DSN 无法留空沿用的问题
- 重置 AI 供应商编辑态与清空密钥开关,避免关闭后状态残留
- 对齐浏览器 mock 复制连接的 config.id 语义并补充回归测试
2026-04-05 11:59:38 +08:00

38 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { shouldAllowBlankCustomDsn } from './customConnectionDsn';
describe('shouldAllowBlankCustomDsn', () => {
it('allows a blank DSN when editing a connection that already has a stored opaque DSN', () => {
expect(shouldAllowBlankCustomDsn({
dsnInput: '',
hasStoredSecret: true,
clearStoredSecret: false,
})).toBe(true);
});
it('requires a new DSN when the user chooses to clear the stored opaque DSN', () => {
expect(shouldAllowBlankCustomDsn({
dsnInput: '',
hasStoredSecret: true,
clearStoredSecret: true,
})).toBe(false);
});
it('requires a DSN for brand new custom connections', () => {
expect(shouldAllowBlankCustomDsn({
dsnInput: '',
hasStoredSecret: false,
clearStoredSecret: false,
})).toBe(false);
});
it('accepts a newly entered DSN even when a stored secret already exists', () => {
expect(shouldAllowBlankCustomDsn({
dsnInput: 'driver://demo',
hasStoredSecret: true,
clearStoredSecret: true,
})).toBe(true);
});
});