Skip to content

Commit 57ee954

Browse files
committed
fix test paths, separate test runs
1 parent 617da9a commit 57ee954

7 files changed

Lines changed: 215 additions & 12 deletions

apps/temporal/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"lint:fix": "npm run lint -- --write",
1717
"pretest": "npm run build:logging && npm run build:graph-insertion-slots && npm run build:graph-workflow",
1818
"build:graph-workflow": "cd ../../packages/graph-workflow && npm run build",
19-
"test": "jest",
19+
"test": "jest --testPathIgnorePatterns experiment-",
20+
"test:integration": "jest experiment-",
2021
"build:graph-insertion-slots": "cd ../../packages/graph-insertion-slots && npm run build",
2122
"type-check:scripts": "tsc --noEmit -p tsconfig.scripts.json"
2223
},
@@ -30,6 +31,7 @@
3031
"author": "",
3132
"license": "MIT",
3233
"dependencies": {
34+
"@ai-di/billing": "file:../../packages/billing",
3335
"@ai-di/blob-storage-paths": "file:../../packages/blob-storage-paths",
3436
"@ai-di/graph-insertion-slots": "file:../../packages/graph-insertion-slots",
3537
"@ai-di/graph-workflow": "file:../../packages/graph-workflow",

apps/temporal/src/__testlib__/integration-harness.ts

Lines changed: 202 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
import "../env-loader";
2424
import { randomUUID } from "node:crypto";
2525
import * as path from "node:path";
26-
import { DocumentStatus } from "@generated/client";
26+
import {
27+
DocumentStatus,
28+
FieldType,
29+
TemplateModelStatus,
30+
} from "@generated/client";
2731
import axios from "axios";
2832
import MockAdapter from "axios-mock-adapter";
2933
import { getPrismaClient } from "../activities/database-client";
@@ -44,6 +48,202 @@ export const TEMPORAL_NAMESPACE =
4448

4549
/** Seeded default group every test document is attached to. */
4650
export const SEED_GROUP_ID = "seeddefaultgroup";
51+
const SEED_ACTOR_ID = "seed-test-actor";
52+
53+
/** Tracks whether the seed group has been upserted in this process. */
54+
let seedGroupEnsured = false;
55+
56+
/** SDPR Monthly Report field definitions — mirrors apps/shared/prisma/seed.ts */
57+
const SDPR_FIELDS: Array<{
58+
fieldKey: string;
59+
fieldType: FieldType;
60+
fieldFormat?: string;
61+
}> = [
62+
{
63+
fieldKey: "checkbox_need_assistance_yes",
64+
fieldType: FieldType.selectionMark,
65+
},
66+
{
67+
fieldKey: "checkbox_need_assistance_no",
68+
fieldType: FieldType.selectionMark,
69+
},
70+
{
71+
fieldKey: "checkbox_family_assets_yes",
72+
fieldType: FieldType.selectionMark,
73+
},
74+
{ fieldKey: "checkbox_family_assets_no", fieldType: FieldType.selectionMark },
75+
{ fieldKey: "checkbox_shelter_yes", fieldType: FieldType.selectionMark },
76+
{ fieldKey: "checkbox_shelter_no", fieldType: FieldType.selectionMark },
77+
{ fieldKey: "checkbox_dependants_yes", fieldType: FieldType.selectionMark },
78+
{ fieldKey: "checkbox_dependants_no", fieldType: FieldType.selectionMark },
79+
{
80+
fieldKey: "checkbox_employment_changes_yes",
81+
fieldType: FieldType.selectionMark,
82+
},
83+
{
84+
fieldKey: "checkbox_employment_changes_no",
85+
fieldType: FieldType.selectionMark,
86+
},
87+
{
88+
fieldKey: "checkbox_employment_changes_spouse_yes",
89+
fieldType: FieldType.selectionMark,
90+
},
91+
{
92+
fieldKey: "checkbox_employment_changes_spouse_no",
93+
fieldType: FieldType.selectionMark,
94+
},
95+
{ fieldKey: "checkbox_school_yes", fieldType: FieldType.selectionMark },
96+
{ fieldKey: "checkbox_school_no", fieldType: FieldType.selectionMark },
97+
{
98+
fieldKey: "checkbox_school_spouse_yes",
99+
fieldType: FieldType.selectionMark,
100+
},
101+
{ fieldKey: "checkbox_school_spouse_no", fieldType: FieldType.selectionMark },
102+
{ fieldKey: "checkbox_work_yes", fieldType: FieldType.selectionMark },
103+
{ fieldKey: "checkbox_work_no", fieldType: FieldType.selectionMark },
104+
{ fieldKey: "checkbox_work_spouse_yes", fieldType: FieldType.selectionMark },
105+
{ fieldKey: "checkbox_work_spouse_no", fieldType: FieldType.selectionMark },
106+
{ fieldKey: "checkbox_moved_yes", fieldType: FieldType.selectionMark },
107+
{ fieldKey: "checkbox_moved_no", fieldType: FieldType.selectionMark },
108+
{ fieldKey: "checkbox_moved_spouse_yes", fieldType: FieldType.selectionMark },
109+
{ fieldKey: "checkbox_moved_spouse_no", fieldType: FieldType.selectionMark },
110+
{ fieldKey: "checkbox_warrant_yes", fieldType: FieldType.selectionMark },
111+
{ fieldKey: "checkbox_warrant_no", fieldType: FieldType.selectionMark },
112+
{
113+
fieldKey: "checkbox_warrant_spouse_yes",
114+
fieldType: FieldType.selectionMark,
115+
},
116+
{
117+
fieldKey: "checkbox_warrant_spouse_no",
118+
fieldType: FieldType.selectionMark,
119+
},
120+
{ fieldKey: "explain_changes", fieldType: FieldType.string },
121+
{ fieldKey: "signature", fieldType: FieldType.string },
122+
{ fieldKey: "spouse_signature", fieldType: FieldType.string },
123+
{ fieldKey: "date", fieldType: FieldType.date, fieldFormat: "ymd" },
124+
{ fieldKey: "spouse_date", fieldType: FieldType.date, fieldFormat: "ymd" },
125+
{ fieldKey: "name", fieldType: FieldType.string },
126+
{ fieldKey: "spouse_name", fieldType: FieldType.string },
127+
{ fieldKey: "phone", fieldType: FieldType.string },
128+
{ fieldKey: "spouse_phone", fieldType: FieldType.string },
129+
{ fieldKey: "sin", fieldType: FieldType.string },
130+
{ fieldKey: "spouse_sin", fieldType: FieldType.string },
131+
{ fieldKey: "applicant_net_employment_income", fieldType: FieldType.number },
132+
{ fieldKey: "applicant_employment_insurance", fieldType: FieldType.number },
133+
{
134+
fieldKey: "applicant_spousal_support_alimony",
135+
fieldType: FieldType.number,
136+
},
137+
{ fieldKey: "applicant_child_support", fieldType: FieldType.number },
138+
{
139+
fieldKey: "applicant_workbc_financial_support",
140+
fieldType: FieldType.number,
141+
},
142+
{
143+
fieldKey: "applicant_student_funding_loans_bursaries",
144+
fieldType: FieldType.number,
145+
},
146+
{ fieldKey: "applicant_rental_income", fieldType: FieldType.number },
147+
{ fieldKey: "applicant_room_board_income", fieldType: FieldType.number },
148+
{ fieldKey: "applicant_workers_compensation", fieldType: FieldType.number },
149+
{
150+
fieldKey: "applicant_private_pensions_retirement_disability",
151+
fieldType: FieldType.number,
152+
},
153+
{ fieldKey: "applicant_oas_gis", fieldType: FieldType.number },
154+
{ fieldKey: "applicant_trust_income", fieldType: FieldType.number },
155+
{
156+
fieldKey: "applicant_canada_pension_plan_cpp",
157+
fieldType: FieldType.number,
158+
},
159+
{ fieldKey: "applicant_tax_credits_gst_credit", fieldType: FieldType.number },
160+
{ fieldKey: "applicant_child_tax_benefits", fieldType: FieldType.number },
161+
{ fieldKey: "applicant_income_tax_refund", fieldType: FieldType.number },
162+
{
163+
fieldKey: "applicant_other_income_money_received",
164+
fieldType: FieldType.number,
165+
},
166+
{
167+
fieldKey: "applicant_income_of_dependent_children",
168+
fieldType: FieldType.number,
169+
},
170+
{ fieldKey: "spouse_net_employment_income", fieldType: FieldType.number },
171+
{ fieldKey: "spouse_employment_insurance", fieldType: FieldType.number },
172+
{ fieldKey: "spouse_spousal_support_alimony", fieldType: FieldType.number },
173+
{ fieldKey: "spouse_child_support", fieldType: FieldType.number },
174+
{ fieldKey: "spouse_workbc_financial_support", fieldType: FieldType.number },
175+
{
176+
fieldKey: "spouse_student_funding_loans_bursaries",
177+
fieldType: FieldType.number,
178+
},
179+
{ fieldKey: "spouse_rental_income", fieldType: FieldType.number },
180+
{ fieldKey: "spouse_room_board_income", fieldType: FieldType.number },
181+
{ fieldKey: "spouse_workers_compensation", fieldType: FieldType.number },
182+
{
183+
fieldKey: "spouse_private_pensions_retirement_disability",
184+
fieldType: FieldType.number,
185+
},
186+
{ fieldKey: "spouse_oas_gis", fieldType: FieldType.number },
187+
{ fieldKey: "spouse_trust_income", fieldType: FieldType.number },
188+
{ fieldKey: "spouse_canada_pension_plan_cpp", fieldType: FieldType.number },
189+
{ fieldKey: "spouse_tax_credits_gst_credit", fieldType: FieldType.number },
190+
{ fieldKey: "spouse_child_tax_benefits", fieldType: FieldType.number },
191+
{ fieldKey: "spouse_income_tax_refund", fieldType: FieldType.number },
192+
{
193+
fieldKey: "spouse_other_income_money_received",
194+
fieldType: FieldType.number,
195+
},
196+
];
197+
198+
/**
199+
* Upsert a minimal Actor, the default seed Group, and the SDPR Monthly Report
200+
* TemplateModel so integration tests are self-contained and work even on a
201+
* freshly-migrated (un-seeded) database.
202+
*/
203+
async function ensureSeedGroup(): Promise<void> {
204+
if (seedGroupEnsured) return;
205+
const prisma = getPrismaClient();
206+
await prisma.actor.upsert({
207+
where: { id: SEED_ACTOR_ID },
208+
update: {},
209+
create: { id: SEED_ACTOR_ID },
210+
});
211+
await prisma.group.upsert({
212+
where: { id: SEED_GROUP_ID },
213+
update: {},
214+
create: {
215+
id: SEED_GROUP_ID,
216+
name: "Default",
217+
created_by: SEED_ACTOR_ID,
218+
},
219+
});
220+
// Upsert the SDPR template model so vlmDirect.extract and loadSeededFieldDefs
221+
// can resolve field types without requiring the full seed script.
222+
// Use model_id as the upsert key to avoid duplicate-model_id conflicts.
223+
const template = await prisma.templateModel.upsert({
224+
where: { model_id: "sdpr-monthly-report" },
225+
update: {},
226+
create: {
227+
id: "seed-sdpr-monthly-report-template",
228+
name: "SDPR Monthly Report",
229+
model_id: "sdpr-monthly-report",
230+
created_by: SEED_ACTOR_ID,
231+
group_id: SEED_GROUP_ID,
232+
status: TemplateModelStatus.trained,
233+
},
234+
});
235+
await prisma.fieldDefinition.createMany({
236+
data: SDPR_FIELDS.map((f, i) => ({
237+
template_model_id: template.id,
238+
field_key: f.fieldKey,
239+
field_type: f.fieldType,
240+
field_format: f.fieldFormat ?? null,
241+
display_order: i,
242+
})),
243+
skipDuplicates: true,
244+
});
245+
seedGroupEnsured = true;
246+
}
47247

48248
/**
49249
* Absolute path to a real sample image on disk. `file.prepare`/provider
@@ -97,6 +297,7 @@ export async function seedTestDocument(opts?: {
97297
id?: string;
98298
fileName?: string;
99299
}): Promise<{ documentId: string; cleanup: () => Promise<void> }> {
300+
await ensureSeedGroup();
100301
const prisma = getPrismaClient();
101302
const documentId = opts?.id ?? `itest-${randomUUID()}`;
102303
const fileName = opts?.fileName ?? "1 81.jpg";

apps/temporal/src/experiment-01-neural-doc-intelligence.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Experiment 01 — Neural Document Intelligence + post-processing
33
*
44
* Two-layer test suite for the
5-
* `docs-md/graph-workflows/templates/experiment-01-neural-doc-intelligence-workflow.json`
5+
* `docs-md/workflows/templates/experiment-01-neural-doc-intelligence-workflow.json`
66
* template:
77
*
88
* 1. **Static + structural** assertions on the JSON template (cheap, no
@@ -117,7 +117,7 @@ const TEMPLATE_PATH = path.join(
117117
"..",
118118
"..",
119119
"docs-md",
120-
"graph-workflows",
120+
"workflows",
121121
"templates",
122122
"experiment-01-neural-doc-intelligence-workflow.json",
123123
);

apps/temporal/src/experiment-02-mistral-doc-ai-azure.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Experiment 02 — Mistral Document AI on Azure AI Foundry
33
*
44
* Two-layer test suite for the
5-
* `docs-md/graph-workflows/templates/experiment-02-mistral-doc-ai-azure-workflow.json`
5+
* `docs-md/workflows/templates/experiment-02-mistral-doc-ai-azure-workflow.json`
66
* template:
77
*
88
* 1. **Static + structural** assertions on the JSON template (cheap, no
@@ -64,7 +64,7 @@ const TEMPLATE_PATH = path.join(
6464
"..",
6565
"..",
6666
"docs-md",
67-
"graph-workflows",
67+
"workflows",
6868
"templates",
6969
"experiment-02-mistral-doc-ai-azure-workflow.json",
7070
);

apps/temporal/src/experiment-03-content-understanding.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Experiment 03 — Azure Content Understanding
33
*
44
* Two-layer test suite for the
5-
* `docs-md/graph-workflows/templates/experiment-03-content-understanding-workflow.json`
5+
* `docs-md/workflows/templates/experiment-03-content-understanding-workflow.json`
66
* template:
77
*
88
* 1. **Static + structural** assertions on the JSON template (cheap, no
@@ -89,7 +89,7 @@ const TEMPLATE_PATH = path.join(
8989
"..",
9090
"..",
9191
"docs-md",
92-
"graph-workflows",
92+
"workflows",
9393
"templates",
9494
"experiment-03-content-understanding-workflow.json",
9595
);

apps/temporal/src/experiment-04-vlm-direct.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Experiment 04 — VLM-direct (gpt-5.4)
33
*
44
* Two-layer test suite for the
5-
* `docs-md/graph-workflows/templates/experiment-04-vlm-direct-workflow.json`
5+
* `docs-md/workflows/templates/experiment-04-vlm-direct-workflow.json`
66
* template:
77
*
88
* 1. **Static + structural** assertions on the JSON template (cheap, no
@@ -76,7 +76,7 @@ const TEMPLATE_PATH = path.join(
7676
"..",
7777
"..",
7878
"docs-md",
79-
"graph-workflows",
79+
"workflows",
8080
"templates",
8181
"experiment-04-vlm-direct-workflow.json",
8282
);

apps/temporal/src/experiment-05-vlm-ocr-hybrid.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Experiment 05 — VLM + OCR hybrid (gpt-5.4)
33
*
44
* Two-layer test suite for the
5-
* `docs-md/graph-workflows/templates/experiment-05-vlm-ocr-hybrid-workflow.json`
5+
* `docs-md/workflows/templates/experiment-05-vlm-ocr-hybrid-workflow.json`
66
* template:
77
*
88
* 1. **Static + structural** assertions on the JSON template (no
@@ -68,7 +68,7 @@ const TEMPLATE_PATH = path.join(
6868
"..",
6969
"..",
7070
"docs-md",
71-
"graph-workflows",
71+
"workflows",
7272
"templates",
7373
"experiment-05-vlm-ocr-hybrid-workflow.json",
7474
);

0 commit comments

Comments
 (0)