ci: fix backend tests due to new updates

This commit is contained in:
Danny Avila 2024-05-18 15:44:22 -04:00
parent 6082e26716
commit 3eabbd572e
No known key found for this signature in database
GPG key ID: 2DD9CC89B9B50364
5 changed files with 14 additions and 13 deletions

View file

@ -73,12 +73,12 @@ describe('domainParser', () => {
const TLD = '.com';
// Non-azure request
it('returns domain as is if not azure', async () => {
it('does not return domain as is if not azure', async () => {
const domain = `example.com${actionDomainSeparator}test${actionDomainSeparator}`;
const result1 = await domainParser(reqNoAzure, domain, false);
const result2 = await domainParser(reqNoAzure, domain, true);
expect(result1).toEqual(domain);
expect(result2).toEqual(domain);
expect(result1).not.toEqual(domain);
expect(result2).not.toEqual(domain);
});
// Test for Empty or Null Inputs

View file

@ -253,8 +253,8 @@ describe('AppService', () => {
process.env.EASTUS_API_KEY = 'eastus-key';
await AppService(app);
expect(app.locals).toHaveProperty(EModelEndpoint.assistants);
expect(app.locals[EModelEndpoint.assistants].capabilities.length).toEqual(3);
expect(app.locals).toHaveProperty(EModelEndpoint.azureAssistants);
expect(app.locals[EModelEndpoint.azureAssistants].capabilities.length).toEqual(3);
});
it('should correctly configure Azure OpenAI endpoint based on custom config', async () => {

View file

@ -33,8 +33,8 @@ describe('initializeClient', () => {
});
test('initializes OpenAI client with default API key and URL', async () => {
process.env.ASSISTANTS_API_KEY = 'default-api-key';
process.env.ASSISTANTS_BASE_URL = 'https://default.api.url';
process.env.AZURE_ASSISTANTS_API_KEY = 'default-api-key';
process.env.AZURE_ASSISTANTS_BASE_URL = 'https://default.api.url';
// Assuming 'isUserProvided' to return false for this test case
jest.mock('~/server/utils', () => ({
@ -51,8 +51,8 @@ describe('initializeClient', () => {
});
test('initializes OpenAI client with user-provided API key and URL', async () => {
process.env.ASSISTANTS_API_KEY = 'user_provided';
process.env.ASSISTANTS_BASE_URL = 'user_provided';
process.env.AZURE_ASSISTANTS_API_KEY = 'user_provided';
process.env.AZURE_ASSISTANTS_BASE_URL = 'user_provided';
getUserKeyValues.mockResolvedValue({ apiKey: 'user-api-key', baseURL: 'https://user.api.url' });
getUserKeyExpiry.mockResolvedValue(isoString);
@ -67,7 +67,7 @@ describe('initializeClient', () => {
});
test('throws error for invalid JSON in user-provided values', async () => {
process.env.ASSISTANTS_API_KEY = 'user_provided';
process.env.AZURE_ASSISTANTS_API_KEY = 'user_provided';
getUserKey.mockResolvedValue('invalid-json');
getUserKeyExpiry.mockResolvedValue(isoString);
getUserKeyValues.mockImplementation(() => {
@ -91,7 +91,7 @@ describe('initializeClient', () => {
});
test('throws error if API key is not provided', async () => {
delete process.env.ASSISTANTS_API_KEY; // Simulate missing API key
delete process.env.AZURE_ASSISTANTS_API_KEY; // Simulate missing API key
const req = { user: { id: 'user123' }, app };
const res = {};
@ -100,7 +100,7 @@ describe('initializeClient', () => {
});
test('initializes OpenAI client with proxy configuration', async () => {
process.env.ASSISTANTS_API_KEY = 'test-key';
process.env.AZURE_ASSISTANTS_API_KEY = 'test-key';
process.env.PROXY = 'http://proxy.server';
const req = { user: { id: 'user123' }, app };