feat(import): add central yaml import for all exportable kinds
- add POST /import, an import page and the import_yaml mcp tool; items are validated up front and imported in dependency order - switch list page import buttons to the central import - write scenario exports as separate --- yaml documents per entity - give each test app its own files dir to avoid cross-suite races - use node: prefix for node built-in imports - bump version to 1.18.0
This commit is contained in:
1 parent
965f262c0f
commit
7418adf385
39 files changed
+848
-130
No files matched your search
@@ -1,8 +1,16 @@
|
||||
import { INestApplication, ValidationPipe } from "@nestjs/common";
|
||||
import * as fs from "node:fs";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { TypeOrmModule } from "@nestjs/typeorm";
|
||||
import { ConfigModule } from "@nestjs/config";
|
||||
import type { NestExpressApplication } from "@nestjs/platform-express";
|
||||
import { ScheduleModule } from "@nestjs/schedule";
|
||||
|
||||
import { configureBodyParsers } from "../src/common/body-parsers";
|
||||
import { ImportModule } from "../src/import/import.module";
|
||||
|
||||
jest.mock("@nestjs/common", () => {
|
||||
const actual = jest.requireActual("@nestjs/common");
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
@@ -55,6 +63,11 @@ import { ScenarioFileEntity } from "../src/file/scenario-file.entity";
|
||||
import { ScenarioRunFileEntity } from "../src/file/scenario-run-file.entity";
|
||||
|
||||
export async function buildTestApp(): Promise<INestApplication> {
|
||||
// Each test app stores files in its own temp dir: suites run in parallel and
|
||||
// some clean up their files dir, which must not affect other suites.
|
||||
const filesDir = fs.mkdtempSync(path.join(os.tmpdir(), "liqa-test-files-"));
|
||||
process.env.FILES_DIR = filesDir;
|
||||
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
@@ -89,15 +102,23 @@ export async function buildTestApp(): Promise<INestApplication> {
|
||||
SessionModule,
|
||||
EnvironmentModule,
|
||||
ScenarioModule,
|
||||
ImportModule,
|
||||
McpModule,
|
||||
],
|
||||
controllers: [HealthController],
|
||||
}).compile();
|
||||
|
||||
const app = module.createNestApplication();
|
||||
const app = module.createNestApplication<NestExpressApplication>();
|
||||
configureBodyParsers(app);
|
||||
app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true }));
|
||||
app.useGlobalFilters(new HttpExceptionFilter());
|
||||
app.useGlobalInterceptors(new LoggingInterceptor());
|
||||
await app.init();
|
||||
|
||||
const close = app.close.bind(app);
|
||||
app.close = async () => {
|
||||
await close();
|
||||
fs.rmSync(filesDir, { recursive: true, force: true });
|
||||
};
|
||||
return app;
|
||||
}
|
||||
Reference in new issue
Block a user