feat: define optimizer domain model
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
articleInputSchema,
|
||||
confirmedFactCardSchema,
|
||||
candidateFactCardSchema,
|
||||
qaReportSchema,
|
||||
} from "../validation";
|
||||
|
||||
describe("domain validation", () => {
|
||||
it("accepts article input with title, body, images, platform, and instructions", () => {
|
||||
const parsed = articleInputSchema.parse({
|
||||
title: "How GEO Optimization Improves Brand Visibility",
|
||||
body: "A practical overview of GEO optimization for marketing teams.",
|
||||
images: [
|
||||
{ type: "description", content: "Dashboard screenshot" },
|
||||
{ type: "link", content: "https://example.com/image.png" },
|
||||
],
|
||||
platform: "official_site",
|
||||
user_instructions: "Keep the article factual and concise.",
|
||||
});
|
||||
|
||||
expect(parsed.images).toHaveLength(2);
|
||||
expect(parsed.platform).toBe("official_site");
|
||||
});
|
||||
|
||||
it("marks a fact card with unresolved uncertain items as not ready for optimization", () => {
|
||||
const parsed = candidateFactCardSchema.parse({
|
||||
company_full_name: "Example Technology Co., Ltd.",
|
||||
company_short_names: ["Example Tech"],
|
||||
brand_names: ["Example"],
|
||||
product_names: ["Example GEO"],
|
||||
target_industry: "GEO optimization",
|
||||
target_audience: "Marketing teams",
|
||||
experience_years: 8,
|
||||
core_claims: ["Eight years of GEO optimization experience"],
|
||||
forbidden_claims: [],
|
||||
image_topics: ["Product dashboard"],
|
||||
uncertain_items: ["Conflicting product names found"],
|
||||
});
|
||||
|
||||
expect(parsed.is_ready_for_optimization).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects a confirmed fact card with an empty company full name", () => {
|
||||
expect(() =>
|
||||
confirmedFactCardSchema.parse({
|
||||
company_full_name: "",
|
||||
company_short_names: ["Example"],
|
||||
brand_names: ["Example"],
|
||||
product_names: ["Example GEO"],
|
||||
target_industry: "GEO optimization",
|
||||
target_audience: "Marketing teams",
|
||||
experience_years: 8,
|
||||
core_claims: ["Eight years of GEO optimization experience"],
|
||||
forbidden_claims: [],
|
||||
image_topics: [],
|
||||
uncertain_items: [],
|
||||
confirmed_by_user: true,
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("accepts QA reports only with pass, warn, or fail statuses", () => {
|
||||
const valid = qaReportSchema.parse({
|
||||
job_id: "job_123",
|
||||
revision: 1,
|
||||
overall_status: "warn",
|
||||
checks: [
|
||||
{
|
||||
rule_id: "title_quality",
|
||||
status: "pass",
|
||||
evidence: "Title reads naturally.",
|
||||
reason: "No grammar issue detected.",
|
||||
suggested_fix: "",
|
||||
target_agent: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(valid.checks[0]?.status).toBe("pass");
|
||||
expect(() =>
|
||||
qaReportSchema.parse({
|
||||
job_id: "job_123",
|
||||
revision: 1,
|
||||
overall_status: "blocked",
|
||||
checks: [],
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user