mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🔧 fix: socialLogins default value (#1730)
* fix: socialLogins default value * ci: add test for `AppService`
This commit is contained in:
parent
a2c35e8415
commit
f30d6bd689
2 changed files with 52 additions and 1 deletions
|
|
@ -12,7 +12,7 @@ const paths = require('~/config/paths');
|
||||||
const AppService = async (app) => {
|
const AppService = async (app) => {
|
||||||
/** @type {TCustomConfig}*/
|
/** @type {TCustomConfig}*/
|
||||||
const config = (await loadCustomConfig()) ?? {};
|
const config = (await loadCustomConfig()) ?? {};
|
||||||
const socialLogins = config.registration.socialLogins ?? [
|
const socialLogins = config?.registration?.socialLogins ?? [
|
||||||
'google',
|
'google',
|
||||||
'facebook',
|
'facebook',
|
||||||
'openid',
|
'openid',
|
||||||
|
|
|
||||||
51
api/server/services/AppService.spec.js
Normal file
51
api/server/services/AppService.spec.js
Normal file
|
|
@ -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…
Add table
Add a link
Reference in a new issue