README + add tests cases

This commit is contained in:
2026-04-29 03:25:57 -03:00
parent 8662a153fe
commit 728d56bb5b
8 changed files with 876 additions and 9 deletions

View File

@@ -67,6 +67,29 @@ function globalParameterFlags(parameters) {
return new Set((parameters || []).map((parameter) => parameter.cli));
}
const expectedFocusedIntentCapabilities = {
"opportunities-by-owner-close-window": {
required: ["--owner-email"],
optional: ["--date", "--month", "--quarter", "--week", "--week-year", "--from-date", "--to-date", "--cluster", "--opty-status", "--limit"],
},
"opportunities-by-owner-manager-close-window": {
required: ["--owner-manager-email"],
optional: ["--date", "--month", "--quarter", "--week", "--week-year", "--from-date", "--to-date", "--cluster", "--opty-status", "--limit"],
},
"workloads-by-resource-close-window": {
required: ["--resource"],
optional: ["--date", "--month", "--quarter", "--week", "--week-year", "--from-date", "--to-date", "--cluster", "--forecast-type", "--limit"],
},
"workloads-by-owner-close-window": {
required: ["--owner-email"],
optional: ["--date", "--month", "--quarter", "--week", "--week-year", "--from-date", "--to-date", "--cluster", "--forecast-type", "--limit"],
},
"workloads-by-owner-manager-close-window": {
required: ["--owner-manager-email"],
optional: ["--date", "--month", "--quarter", "--week", "--week-year", "--from-date", "--to-date", "--cluster", "--forecast-type", "--limit"],
},
};
test("sales prompt commands are short, direct, and documented in references", () => {
const flagsFromReferences = documentedFlags(catalogs);
@@ -170,6 +193,32 @@ test("intent prompt commands match the live CLI contract without local flag copi
}
});
test("focused owner/resource close-window intents expose the expected offline contract", async () => {
for (const [intentName, expected] of Object.entries(expectedFocusedIntentCapabilities)) {
const result = await runFetch(["--describe-intent", intentName]);
const parameters = result.json.intent.parameters || [];
const flags = new Set(parameters.map((parameter) => parameter.cli));
const requiredFlags = new Set(
parameters.filter((parameter) => parameter.required).map((parameter) => parameter.cli)
);
assert.equal(result.json.intent.name, intentName);
assert.ok(catalogMentionsIntent(catalogs, intentName), `${intentName} must be documented.`);
for (const flag of expected.required) {
assert.ok(flags.has(flag), `${intentName} is missing ${flag}`);
assert.ok(requiredFlags.has(flag), `${intentName} must require ${flag}`);
}
for (const flag of expected.optional) {
assert.ok(flags.has(flag), `${intentName} is missing optional ${flag}`);
assert.equal(requiredFlags.has(flag), false, `${intentName} should not require optional ${flag}`);
}
assert.equal(flags.has("--country"), false, `${intentName} should use --cluster, not a new --country flag.`);
}
});
test("ad hoc sales prompt renders an org-wide opportunity query", async () => {
const item = promptCases.find((entry) => entry.id === "ad-hoc-query");
const args = caseArgs(item);
@@ -208,6 +257,79 @@ test("org-wide query money aliases use the pipeline measure that Oracle DV accep
assert.match(result.json.expandedSql, /"Columns"\."Revenue Line Close Date" >= DATE '2026-04-26'/);
});
test("query mode keeps commercial auto-scope and SR auto-scope separated", async () => {
const commercial = await runFetch([
"--query",
"--select",
"opportunityId,customerName",
"--where",
"cluster = 'Brazil'",
"--render-sql",
]);
assert.equal(commercial.json.query.source, parsePrimaryCommercialSourceName(catalogs.apiMap));
assert.equal(commercial.json.scope.scopeMode, "org-wide");
assert.doesNotMatch(commercial.json.expandedSql, /SEC_ARIA_SI-SR-TEAM/);
const sr = await runFetch([
"--query",
"--select",
"srNumber,customerName",
"--render-sql",
]);
assert.equal(sr.json.query.source, "DV - SE Team");
assert.equal(sr.json.scope.scopeMode, "my-team-only");
assert.match(sr.json.expandedSql, /SEC_ARIA_SI-SR-TEAM/);
});
test("query mode honors my-team scope aliases for otherwise org-wide commercial fields", async () => {
for (const scopeAlias of ["team", "current-team"]) {
const result = await runFetch([
"--query",
"--select",
"opportunityId,customerName",
"--scope",
scopeAlias,
"--render-sql",
]);
assert.equal(result.json.query.requestedScope, "my-team-only", scopeAlias);
assert.equal(result.json.query.effectiveScope, "my-team-only", scopeAlias);
assert.equal(result.json.query.source, "DV - SE Team", scopeAlias);
assert.match(result.json.expandedSql, /SEC_ARIA_SI-SR-TEAM/, scopeAlias);
}
});
test("CLI rejects conflicting execution modes and unsupported scopes before backend execution", async () => {
const cases = [
{
args: ["--query", "--select", "opportunityId", "--sql", "select 1", "--render-sql"],
message: /Use either --query or --sql, not both/,
},
{
args: ["--query", "--select", "opportunityId", "--intent", "opportunities-default", "--render-sql"],
message: /Use either --query or --intent, not both/,
},
{
args: ["--query", "--select", "opportunityId", "--view", "opportunity-details", "--render-sql"],
message: /Use either --query or --view, not both/,
},
{
args: ["--query", "--select", "opportunityId", "--scope", "nope", "--render-sql"],
message: /Unsupported --scope "nope"/,
},
{
args: ["--render-sql"],
message: /Pass --sql or --query together with --render-sql/,
},
];
for (const item of cases) {
const result = await runFetch(item.args, { expectCode: 1 });
assert.match(result.stderr, item.message);
assert.equal(result.stdout, "");
}
});
test("CLI rejects invalid limit values before backend execution", async () => {
for (const value of ["abc", "0", "-1", "1.5"]) {
const result = await runFetch(