mirror of
https://github.com/labring/FastGPT.git
synced 2026-03-28 01:02:13 +08:00
* feat: encapsulate logger (#6535) * feat: encapsulate logger * update engines --------- Co-authored-by: archer <545436317@qq.com> * next config * dev shell * Agent sandbox (#6532) * docs: switch to docs layout and apply black theme (#6533) * feat: add Gemini 3.1 models - Add gemini-3.1-pro-preview (released February 19, 2026) - Add gemini-3.1-flash-lite-preview (released March 3, 2026) Both models support: - 1M context window - 64k max response - Vision - Tool choice * docs: switch to docs layout and apply black theme - Change layout from notebook to docs - Update logo to icon + text format - Apply fumadocs black theme - Simplify global.css (keep only navbar and TOC styles) - Fix icon components to properly accept className props - Add mobile text overflow handling - Update Node engine requirement to >=20.x * doc * doc * lock * fix: ts * doc * doc --------- Co-authored-by: archer <archer@archerdeMac-mini.local> Co-authored-by: archer <545436317@qq.com> * Doc (#6493) * cloud doc * doc refactor * doc move * seo * remove doc * yml * doc * fix: tsconfig * fix: tsconfig * sandbox version (#6497) * sandbox version * add sandbox log * update lock * fix * fix: sandbox * doc * add console * i18n * sandbxo in agent * feat: agent sandbox * lock * feat: sandbox ui * sandbox check exists * env tempalte * doc * lock * sandbox in chat window * sandbox entry * fix: test * rename var * sandbox config tip * update sandbox lifecircle * update prompt * rename provider test * sandbox logger * yml --------- Co-authored-by: Archer <archer@fastgpt.io> Co-authored-by: archer <archer@archerdeMac-mini.local> * perf: sandbox error tip * Add sandbox limit and fix some issue (#6550) * sandbox in plan * fix: some issue * fix: test * editor default path * fix: comment * perf: sandbox worksapce * doc * perf: del sandbox * sandbox build * fix: test * fix: pr comment --------- Co-authored-by: Ryo <whoeverimf5@gmail.com> Co-authored-by: Archer <archer@fastgpt.io> Co-authored-by: archer <archer@archerdeMac-mini.local>
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import './mocks';
|
|
import { existsSync, readFileSync } from 'fs';
|
|
|
|
import { connectMongo } from '@fastgpt/service/common/mongo/init';
|
|
import { initGlobalVariables } from '@/service/common/system';
|
|
import { afterAll, beforeAll, beforeEach, inject, onTestFinished, vi } from 'vitest';
|
|
import setupModels from './setupModels';
|
|
import { clean } from './datas/users';
|
|
import { connectionLogMongo, connectionMongo } from '@fastgpt/service/common/mongo';
|
|
import { loadVectorDBEnv } from './utils/env';
|
|
|
|
vi.stubEnv('NODE_ENV', 'test');
|
|
|
|
loadVectorDBEnv({ envFileNames: ['.env.test.local'] });
|
|
|
|
beforeAll(async () => {
|
|
vi.stubEnv('MONGODB_URI', inject('MONGODB_URI'));
|
|
await connectMongo({ db: connectionMongo, url: inject('MONGODB_URI') });
|
|
await connectMongo({ db: connectionLogMongo, url: inject('MONGODB_URI') });
|
|
|
|
initGlobalVariables();
|
|
global.systemEnv = {} as any;
|
|
|
|
// await getInitConfig();
|
|
if (existsSync('projects/app/.env.local')) {
|
|
const str = readFileSync('projects/app/.env.local', 'utf-8');
|
|
const lines = str.split('\n');
|
|
const systemEnv: Record<string, string> = {};
|
|
for (const line of lines) {
|
|
const [key, value] = line.split('=');
|
|
if (key && value && !key.startsWith('#')) {
|
|
systemEnv[key] = value;
|
|
}
|
|
}
|
|
global.systemEnv.oneapiUrl = systemEnv['OPENAI_BASE_URL'];
|
|
global.systemEnv.chatApiKey = systemEnv['CHAT_API_KEY'];
|
|
}
|
|
global.feConfigs = {
|
|
isPlus: false
|
|
} as any;
|
|
await setupModels();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await connectionMongo?.connection.db?.dropDatabase();
|
|
await connectionLogMongo?.connection.db?.dropDatabase();
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
// await connectMongo({ db: connectionMongo, url: inject('MONGODB_URI') });
|
|
// await connectMongo({ db: connectionLogMongo, url: inject('MONGODB_URI') });
|
|
|
|
onTestFinished(async () => {
|
|
clean();
|
|
|
|
// Ensure all sessions are closed before dropping database
|
|
try {
|
|
await Promise.all([
|
|
connectionMongo?.connection.db?.dropDatabase(),
|
|
connectionLogMongo?.connection.db?.dropDatabase()
|
|
]);
|
|
} catch (error) {
|
|
// Ignore errors during cleanup
|
|
console.warn('Error during test cleanup:', error);
|
|
}
|
|
});
|
|
});
|