e115934061
Publish `@librechat/data-schemas` to NPM / pack (push) Failing after 8s
Publish `@librechat/client` to NPM / pack (push) Failing after 0s
GitNexus Index / index (push) Failing after 1s
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been skipped
Sync Helm Chart Tags / Sync chart tags (push) Failing after 2s
Publish `librechat-data-provider` to NPM / pack (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Failing after 0s
Sync Helm Chart Tags / Ignore non-main push (push) Has been skipped
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Failing after 1s
Publish `@librechat/client` to NPM / publish-npm (push) Has been cancelled
Publish `librechat-data-provider` to NPM / publish-npm (push) Has been cancelled
GitNexus Index / post-index (push) Has been cancelled
Publish `@librechat/data-schemas` to NPM / publish-npm (push) Has been cancelled
72 lines
2.0 KiB
JavaScript
72 lines
2.0 KiB
JavaScript
const DALLE3 = require('../DALLE3');
|
|
|
|
const processFileURL = jest.fn();
|
|
const proxyEnvKeys = [
|
|
'PROXY',
|
|
'proxy',
|
|
'HTTP_PROXY',
|
|
'HTTPS_PROXY',
|
|
'NO_PROXY',
|
|
'http_proxy',
|
|
'https_proxy',
|
|
'no_proxy',
|
|
];
|
|
|
|
function clearProxyEnv() {
|
|
proxyEnvKeys.forEach((key) => delete process.env[key]);
|
|
}
|
|
|
|
describe('DALLE3 Proxy Configuration', () => {
|
|
let originalEnv;
|
|
|
|
beforeAll(() => {
|
|
originalEnv = { ...process.env };
|
|
});
|
|
|
|
beforeEach(() => {
|
|
jest.resetModules();
|
|
process.env = { ...originalEnv };
|
|
clearProxyEnv();
|
|
});
|
|
|
|
afterEach(() => {
|
|
process.env = originalEnv;
|
|
});
|
|
|
|
it('should configure fetchOptions.dispatcher when proxy env is set', () => {
|
|
// Set proxy environment variable
|
|
process.env.PROXY = 'http://proxy.example.com:8080';
|
|
process.env.DALLE_API_KEY = 'test-api-key';
|
|
|
|
// Create instance
|
|
const dalleWithProxy = new DALLE3({ processFileURL });
|
|
|
|
// Check that the openai client exists
|
|
expect(dalleWithProxy.openai).toBeDefined();
|
|
|
|
// Check that _options exists and has fetchOptions with a dispatcher
|
|
expect(dalleWithProxy.openai._options).toBeDefined();
|
|
expect(dalleWithProxy.openai._options.fetchOptions).toBeDefined();
|
|
expect(dalleWithProxy.openai._options.fetchOptions.dispatcher).toBeDefined();
|
|
expect(dalleWithProxy.openai._options.fetchOptions.dispatcher).toBeDefined();
|
|
});
|
|
|
|
it('should not configure a dispatcher when proxy env is not set', () => {
|
|
process.env.DALLE_API_KEY = 'test-api-key';
|
|
|
|
// Create instance
|
|
const dalleWithoutProxy = new DALLE3({ processFileURL });
|
|
|
|
// Check that the openai client exists
|
|
expect(dalleWithoutProxy.openai).toBeDefined();
|
|
|
|
// Check that _options exists but fetchOptions either doesn't exist or doesn't have a dispatcher
|
|
expect(dalleWithoutProxy.openai._options).toBeDefined();
|
|
|
|
// fetchOptions should either not exist or not have a dispatcher
|
|
if (dalleWithoutProxy.openai._options.fetchOptions) {
|
|
expect(dalleWithoutProxy.openai._options.fetchOptions.dispatcher).toBeUndefined();
|
|
}
|
|
});
|
|
});
|