tunnel-rewriteport.test.ts 1008 B

1234567891011121314151617181920212223242526
  1. import { describe, expect, it } from 'vitest';
  2. import { TunnelInboundSettingsSchema } from '@/schemas/protocols/inbound/tunnel';
  3. // Regression for issue #5516: AntD InputNumber writes null when the Rewrite
  4. // port field is cleared, which used to crash validation with "Invalid input".
  5. describe('TunnelInboundSettingsSchema rewritePort', () => {
  6. it('accepts null (cleared field) and omits the port', () => {
  7. const parsed = TunnelInboundSettingsSchema.parse({ rewritePort: null });
  8. expect(parsed.rewritePort).toBeUndefined();
  9. });
  10. it('accepts a missing field', () => {
  11. const parsed = TunnelInboundSettingsSchema.parse({});
  12. expect(parsed.rewritePort).toBeUndefined();
  13. });
  14. it('preserves a valid port', () => {
  15. const parsed = TunnelInboundSettingsSchema.parse({ rewritePort: 8443 });
  16. expect(parsed.rewritePort).toBe(8443);
  17. });
  18. it('still rejects out-of-range ports', () => {
  19. expect(() => TunnelInboundSettingsSchema.parse({ rewritePort: 70000 })).toThrow();
  20. });
  21. });