mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 15:22:12 +03:00
## New Features - Combo Builder v2 wizard UI (multi-stage: Basics → Steps → Strategy → Review) - Combo Step Architecture Schema v2 (ComboModelStep, ComboRefStep, pinned accounts) - Composite Tiers system for tiered model routing with fallback chains - Model Capabilities Registry (unified resolver merging specs + registry + synced data) - Observability module (buildHealthPayload, buildTelemetryPayload, buildSessionsSummary) - Session & Quota Monitor panels on Health dashboard - Combo Health per-target analytics via resolveNestedComboTargets() - Combo Builder Options API (GET /api/combos/builder/options) ## Performance - Middleware lazy loading (apiAuth, db/settings, modelSyncScheduler) - E2E auth bypass mode (NEXT_PUBLIC_OMNIROUTE_E2E_MODE) ## Bug Fixes - P2C credential selection with quota headroom awareness - Fixed-account combo steps bypass model cooldowns/circuit breakers - Combo metrics per-target tracking (byTarget with executionKey) - Call logs schema expansion (7 new columns + composite index) - Quota monitor lifecycle enrichment (status, snapshots, summary) - Codex quota fetcher hardening ## Maintenance - DB migration 021 (combo_call_log_targets) - Combo CRUD normalization on read - Playwright config + build script improvements - OpenAPI spec version sync to 3.6.4 ## Tests - 16 new test suites + 12 existing test updates - 86 files changed, +8318 -1378 lines
104 lines
3.2 KiB
JavaScript
104 lines
3.2 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs/promises";
|
|
import fsSync from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const { movePath, resolveNextBuildEnv } = await import("../../scripts/build-next-isolated.mjs");
|
|
|
|
async function withTempDir(fn) {
|
|
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "omniroute-build-next-isolated-"));
|
|
|
|
try {
|
|
await fn(tempDir);
|
|
} finally {
|
|
await fs.rm(tempDir, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
test("movePath falls back to copy/remove when rename raises EXDEV", async () => {
|
|
await withTempDir(async (tempDir) => {
|
|
const sourceDir = path.join(tempDir, "app");
|
|
const destinationDir = path.join(tempDir, ".app-build-backup");
|
|
const nestedFile = path.join(sourceDir, "nested", "file.txt");
|
|
|
|
await fs.mkdir(path.dirname(nestedFile), { recursive: true });
|
|
await fs.writeFile(nestedFile, "legacy payload");
|
|
|
|
let copyCalled = false;
|
|
let removeCalled = false;
|
|
const warnings = [];
|
|
const originalWarn = console.warn;
|
|
console.warn = (message) => warnings.push(String(message));
|
|
|
|
try {
|
|
await movePath(sourceDir, destinationDir, {
|
|
rename: async () => {
|
|
const error = new Error("cross-device link not permitted");
|
|
error.code = "EXDEV";
|
|
throw error;
|
|
},
|
|
cp: async (...args) => {
|
|
copyCalled = true;
|
|
return fs.cp(...args);
|
|
},
|
|
rm: async (...args) => {
|
|
removeCalled = true;
|
|
return fs.rm(...args);
|
|
},
|
|
});
|
|
} finally {
|
|
console.warn = originalWarn;
|
|
}
|
|
|
|
assert.equal(copyCalled, true);
|
|
assert.equal(removeCalled, true);
|
|
assert.equal(fsSync.existsSync(sourceDir), false);
|
|
assert.equal(
|
|
await fs.readFile(path.join(destinationDir, "nested", "file.txt"), "utf8"),
|
|
"legacy payload"
|
|
);
|
|
assert.match(warnings[0] ?? "", /EXDEV while moving/);
|
|
});
|
|
});
|
|
|
|
test("movePath rethrows non-EXDEV rename failures", async () => {
|
|
await withTempDir(async (tempDir) => {
|
|
const sourceDir = path.join(tempDir, "app");
|
|
const destinationDir = path.join(tempDir, ".app-build-backup");
|
|
|
|
await fs.mkdir(sourceDir, { recursive: true });
|
|
|
|
await assert.rejects(
|
|
movePath(sourceDir, destinationDir, {
|
|
rename: async () => {
|
|
const error = new Error("permission denied");
|
|
error.code = "EACCES";
|
|
throw error;
|
|
},
|
|
cp: async () => {
|
|
throw new Error("copy fallback should not run");
|
|
},
|
|
rm: async () => {
|
|
throw new Error("remove fallback should not run");
|
|
},
|
|
}),
|
|
(error) => error?.code === "EACCES"
|
|
);
|
|
});
|
|
});
|
|
|
|
test("resolveNextBuildEnv forces stable build worker mode unless already provided", () => {
|
|
const defaultEnv = resolveNextBuildEnv({ NODE_ENV: "test" });
|
|
assert.equal(defaultEnv.NEXT_PRIVATE_BUILD_WORKER, "0");
|
|
assert.equal(defaultEnv.NODE_ENV, "test");
|
|
|
|
const preservedEnv = resolveNextBuildEnv({
|
|
NODE_ENV: "production",
|
|
NEXT_PRIVATE_BUILD_WORKER: "1",
|
|
});
|
|
assert.equal(preservedEnv.NEXT_PRIVATE_BUILD_WORKER, "1");
|
|
assert.equal(preservedEnv.NODE_ENV, "production");
|
|
});
|