mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-07 07:55:16 +02:00
* refactor: carve out extraction panel * refactor: create spec versions for node types * refactor: create a GenericNode and remove custom nodes * feat: add python and typescript sdk * add dograh sdk * fix: fetch draft workflow definition over published one * fix: fix routes of SDKs to use code gen * chore: remove doclink dependency to reduce image size * chore: format files * chore: bump pipecat * feat: let mcp fetch archived workflows on demand * chore: fix tests * feat: add sdk documentation * chore: change banner and add badge
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
// Golden-test parity: run every case in
|
|
// api/services/workflow/node_specs/display_options_fixtures.json through
|
|
// the TypeScript evaluator and assert the result matches `expected`.
|
|
//
|
|
// Run via `npm run test:display-options` from ui/, or `node
|
|
// ui/scripts/test-display-options.mts` directly (Node 24+ strips TS types
|
|
// natively).
|
|
//
|
|
// Mirrors `api/tests/test_display_options_evaluator.py`.
|
|
|
|
import { readFileSync } from "node:fs";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { evaluateDisplayOptions } from "../src/components/flow/renderer/displayOptions.ts";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const FIXTURES_PATH = resolve(
|
|
__dirname,
|
|
"../../api/services/workflow/node_specs/display_options_fixtures.json",
|
|
);
|
|
|
|
interface Case {
|
|
name: string;
|
|
rules: Parameters<typeof evaluateDisplayOptions>[0];
|
|
values: Record<string, unknown>;
|
|
expected: boolean;
|
|
}
|
|
|
|
const data = JSON.parse(readFileSync(FIXTURES_PATH, "utf-8")) as { cases: Case[] };
|
|
|
|
let failed = 0;
|
|
for (const c of data.cases) {
|
|
const actual = evaluateDisplayOptions(c.rules, c.values);
|
|
if (actual !== c.expected) {
|
|
console.error(
|
|
`FAIL ${c.name}: expected ${c.expected}, got ${actual}\n` +
|
|
` rules=${JSON.stringify(c.rules)} values=${JSON.stringify(c.values)}`,
|
|
);
|
|
failed++;
|
|
} else {
|
|
console.log(`PASS ${c.name}`);
|
|
}
|
|
}
|
|
|
|
if (failed > 0) {
|
|
console.error(`\n${failed} of ${data.cases.length} cases failed`);
|
|
process.exit(1);
|
|
}
|
|
console.log(`\nAll ${data.cases.length} cases passed`);
|