Files
metapi/src/server/runtimeDatabaseBootstrap.test.ts
T
cita 0f8176cd04 feat: Implement compatibility strategies for responses and chat endpoints
- Added `routeCompatibility.ts` to handle response compatibility for different endpoints.
- Introduced `chatEndpointStrategy.ts` to manage chat endpoint recovery and downgrading logic.
- Created tests for chat formats and input file handling in `chatFormatsCore.test.ts` and `inputFile.test.ts`.
- Developed `endpointCompatibility.ts` to define compatibility checks and header building for various endpoints.
- Implemented protocol lifecycle management in `protocolLifecycle.ts` and corresponding tests in `protocolModel.test.ts`.
- Enhanced tooltip functionality with a new `TooltipLayer` component and associated tests.
- Refactored existing components to improve tooltip handling and ensure proper rendering in the application.
2026-03-09 22:48:10 +08:00

33 lines
1.1 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest';
import { ensureRuntimeDatabaseReady } from './runtimeDatabaseBootstrap.js';
describe('runtimeDatabaseBootstrap', () => {
it('runs sqlite runtime migrations when dialect is sqlite', async () => {
const runSqliteRuntimeMigrations = vi.fn(async () => {});
const ensureExternalRuntimeSchema = vi.fn(async () => {});
await ensureRuntimeDatabaseReady({
dialect: 'sqlite',
runSqliteRuntimeMigrations,
ensureExternalRuntimeSchema,
});
expect(runSqliteRuntimeMigrations).toHaveBeenCalledTimes(1);
expect(ensureExternalRuntimeSchema).not.toHaveBeenCalled();
});
it.each(['postgres', 'mysql'] as const)('bootstraps external schema when dialect is %s', async (dialect) => {
const runSqliteRuntimeMigrations = vi.fn(async () => {});
const ensureExternalRuntimeSchema = vi.fn(async () => {});
await ensureRuntimeDatabaseReady({
dialect,
runSqliteRuntimeMigrations,
ensureExternalRuntimeSchema,
});
expect(ensureExternalRuntimeSchema).toHaveBeenCalledTimes(1);
expect(runSqliteRuntimeMigrations).not.toHaveBeenCalled();
});
});