import { tap, expect } from '@push.rocks/tapbundle'; import * as plugins from '../ts/plugins.js'; // First, import the components directly to avoid issues with compiled modules import { ForwardingHandlerFactory } from '../ts/forwarding/factory/forwarding-factory.js'; // Import route-based helpers from the correct location import { createHttpRoute, createHttpsTerminateRoute, createHttpsPassthroughRoute, createHttpToHttpsRedirect, createCompleteHttpsServer, createLoadBalancerRoute } from '../ts/proxies/smart-proxy/utils/route-patterns.js'; // Create helper functions for building forwarding configs const helpers = { httpOnly: () => ({ type: 'http-only' as const }), tlsTerminateToHttp: () => ({ type: 'https-terminate-to-http' as const }), tlsTerminateToHttps: () => ({ type: 'https-terminate-to-https' as const }), httpsPassthrough: () => ({ type: 'https-passthrough' as const }) }; tap.test('ForwardingHandlerFactory - apply defaults based on type', async () => { // HTTP-only defaults const httpConfig = { type: 'http-only' as const, target: { host: 'localhost', port: 3000 } }; const httpWithDefaults = ForwardingHandlerFactory['applyDefaults'](httpConfig); expect(httpWithDefaults.port).toEqual(80); expect(httpWithDefaults.socket).toEqual('/tmp/forwarding-http-only-80.sock'); // HTTPS passthrough defaults const httpsPassthroughConfig = { type: 'https-passthrough' as const, target: { host: 'localhost', port: 443 } }; const httpsPassthroughWithDefaults = ForwardingHandlerFactory['applyDefaults'](httpsPassthroughConfig); expect(httpsPassthroughWithDefaults.port).toEqual(443); expect(httpsPassthroughWithDefaults.socket).toEqual('/tmp/forwarding-https-passthrough-443.sock'); }); tap.test('ForwardingHandlerFactory - factory function for handlers', async () => { // @todo Implement unit tests for ForwardingHandlerFactory // These tests would need proper mocking of the handlers }); export default tap.start();