Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 fix: socialLogins default value #1730

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/server/services/AppService.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const paths = require('~/config/paths');
const AppService = async (app) => {
/** @type {TCustomConfig}*/
const config = (await loadCustomConfig()) ?? {};
const socialLogins = config.registration.socialLogins ?? [
const socialLogins = config?.registration?.socialLogins ?? [
'google',
'facebook',
'openid',
Expand Down
51 changes: 51 additions & 0 deletions api/server/services/AppService.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { FileSources } = require('librechat-data-provider');

const AppService = require('./AppService');

jest.mock('./Config/loadCustomConfig', () => {
return jest.fn(() =>
Promise.resolve({
registration: { socialLogins: ['testLogin'] },
fileStrategy: 'testStrategy',
}),
);
});
jest.mock('./Files/Firebase/initialize', () => ({
initializeFirebase: jest.fn(),
}));

describe('AppService', () => {
let app;

beforeEach(() => {
app = { locals: {} };
process.env.CDN_PROVIDER = undefined;
});

it('should correctly assign process.env and app.locals based on custom config', async () => {
await AppService(app);

expect(process.env.CDN_PROVIDER).toEqual('testStrategy');

expect(app.locals).toEqual({
socialLogins: ['testLogin'],
fileStrategy: 'testStrategy',
paths: expect.anything(),
});
});

it('should initialize Firebase when fileStrategy is firebase', async () => {
require('./Config/loadCustomConfig').mockImplementationOnce(() =>
Promise.resolve({
fileStrategy: FileSources.firebase,
}),
);

await AppService(app);

const { initializeFirebase } = require('./Files/Firebase/initialize');
expect(initializeFirebase).toHaveBeenCalled();

expect(process.env.CDN_PROVIDER).toEqual(FileSources.firebase);
});
});
Loading