Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,17 @@
"command": "agent:test:results",
"flagAliases": [],
"flagChars": ["d", "i", "o"],
"flags": ["api-version", "flags-dir", "job-id", "json", "output-dir", "result-format", "target-org", "verbose"],
"flags": [
"api-version",
"flags-dir",
"job-id",
"json",
"output-dir",
"result-format",
"target-org",
"test-runner",
"verbose"
],
"plugin": "@salesforce/plugin-agent"
},
{
Expand All @@ -198,6 +208,7 @@
"output-dir",
"result-format",
"target-org",
"test-runner",
"use-most-recent",
"verbose",
"wait"
Expand All @@ -217,6 +228,7 @@
"output-dir",
"result-format",
"target-org",
"test-runner",
"verbose",
"wait"
],
Expand Down
8 changes: 8 additions & 0 deletions messages/shared.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ When enabled, includes detailed generated data (such as invoked actions) in the

The generated data is in JSON format and includes the Apex classes or Flows that were invoked, the Salesforce objects that were touched, and so on. Use the JSON structure of this information to build the test case JSONPath expression when using custom evaluations.

# flags.test-runner.summary

Explicitly specify which test runner to use (agentforce-studio or testing-center).

# flags.test-runner.description

By default, the command automatically detects which test runner to use based on the test definition metadata type in your org. Use this flag to explicitly specify the runner type. 'agentforce-studio' uses AiTestingDefinition metadata. 'testing-center' uses AiEvaluationDefinition metadata.

# error.invalidAgentType

agentType must be either "customer" or "internal". Found: [%s]
Expand Down
57 changes: 56 additions & 1 deletion schemas/agent-test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
"$ref": "#/definitions/AgentTestResultsResult",
"definitions": {
"AgentTestResultsResult": {
"$ref": "#/definitions/AgentTestResultsResponse"
"anyOf": [
{
"$ref": "#/definitions/AgentTestResultsResponse"
},
{
"$ref": "#/definitions/AgentTestNGTResultsResponse"
}
]
},
"AgentTestResultsResponse": {
"type": "object",
Expand Down Expand Up @@ -148,6 +155,54 @@
},
"required": ["status", "startTime", "inputs", "generatedData", "testResults", "testNumber"],
"additionalProperties": false
},
"AgentTestNGTResultsResponse": {
"type": "object",
"properties": {
"status": {
"type": "string"
},
"testCases": {
"type": "array",
"items": {
"$ref": "#/definitions/NGTTestCaseResult"
}
}
},
"required": ["status", "testCases"],
"additionalProperties": false
},
"NGTTestCaseResult": {
"type": "object",
"properties": {
"subjectResponse": {
"type": "string"
},
"testNumber": {
"type": "number"
},
"testScorerResults": {
"type": "array",
"items": {
"$ref": "#/definitions/TestScorerResult"
}
}
},
"required": ["subjectResponse", "testNumber", "testScorerResults"],
"additionalProperties": false
},
"TestScorerResult": {
"type": "object",
"properties": {
"scorerName": {
"type": "string"
},
"scorerResponse": {
"type": "string"
}
},
"required": ["scorerName", "scorerResponse"],
"additionalProperties": false
}
}
}
52 changes: 52 additions & 0 deletions schemas/agent-test-resume.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@
}
},
"required": ["runId", "startTime", "status", "subjectName", "testCases"]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"status": {
"type": "string",
"const": "COMPLETED"
},
"runId": {
"type": "string"
},
"testCases": {
"type": "array",
"items": {
"$ref": "#/definitions/NGTTestCaseResult"
}
}
},
"required": ["runId", "status", "testCases"]
}
]
},
Expand Down Expand Up @@ -183,6 +203,38 @@
},
"required": ["status", "startTime", "inputs", "generatedData", "testResults", "testNumber"],
"additionalProperties": false
},
"NGTTestCaseResult": {
"type": "object",
"properties": {
"subjectResponse": {
"type": "string"
},
"testNumber": {
"type": "number"
},
"testScorerResults": {
"type": "array",
"items": {
"$ref": "#/definitions/TestScorerResult"
}
}
},
"required": ["subjectResponse", "testNumber", "testScorerResults"],
"additionalProperties": false
},
"TestScorerResult": {
"type": "object",
"properties": {
"scorerName": {
"type": "string"
},
"scorerResponse": {
"type": "string"
}
},
"required": ["scorerName", "scorerResponse"],
"additionalProperties": false
}
}
}
52 changes: 52 additions & 0 deletions schemas/agent-test-run.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@
}
},
"required": ["runId", "startTime", "status", "subjectName", "testCases"]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"status": {
"type": "string",
"const": "COMPLETED"
},
"runId": {
"type": "string"
},
"testCases": {
"type": "array",
"items": {
"$ref": "#/definitions/NGTTestCaseResult"
}
}
},
"required": ["runId", "status", "testCases"]
}
]
},
Expand Down Expand Up @@ -183,6 +203,38 @@
},
"required": ["status", "startTime", "inputs", "generatedData", "testResults", "testNumber"],
"additionalProperties": false
},
"NGTTestCaseResult": {
"type": "object",
"properties": {
"subjectResponse": {
"type": "string"
},
"testNumber": {
"type": "number"
},
"testScorerResults": {
"type": "array",
"items": {
"$ref": "#/definitions/TestScorerResult"
}
}
},
"required": ["subjectResponse", "testNumber", "testScorerResults"],
"additionalProperties": false
},
"TestScorerResult": {
"type": "object",
"properties": {
"scorerName": {
"type": "string"
},
"scorerResponse": {
"type": "string"
}
},
"required": ["scorerName", "scorerResponse"],
"additionalProperties": false
}
}
}
9 changes: 6 additions & 3 deletions src/agentTestCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { Global, SfError, TTLConfig } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import type { TestRunnerType } from '@salesforce/agents';

type ResultFormat = 'json' | 'human' | 'junit' | 'tap';

Expand All @@ -24,6 +25,7 @@ type CacheContents = {
name: string;
outputDir?: string;
resultFormat?: ResultFormat;
runnerType?: TestRunnerType;
};

export class AgentTestCache extends TTLConfig<TTLConfig.Options, CacheContents> {
Expand All @@ -45,11 +47,12 @@ export class AgentTestCache extends TTLConfig<TTLConfig.Options, CacheContents>
runId: string,
name: string,
outputDir?: string,
resultFormat?: ResultFormat
resultFormat?: ResultFormat,
runnerType?: TestRunnerType
): Promise<void> {
if (!runId) throw new SfError('runId is required to create a cache entry');

this.set(runId, { runId, name, outputDir, resultFormat });
this.set(runId, { runId, name, outputDir, resultFormat, runnerType });
await this.write();
}

Expand All @@ -70,7 +73,7 @@ export class AgentTestCache extends TTLConfig<TTLConfig.Options, CacheContents>
public useIdOrMostRecent(
runId: string | undefined,
useMostRecent: boolean
): { runId: string; name?: string; outputDir?: string; resultFormat?: ResultFormat } {
): { runId: string; name?: string; outputDir?: string; resultFormat?: ResultFormat; runnerType?: TestRunnerType } {
if (runId && useMostRecent) {
throw new SfError('Cannot specify both a runId and use most recent flag');
}
Expand Down
16 changes: 12 additions & 4 deletions src/commands/agent/test/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

import { SfCommand, Flags, toHelpSection } from '@salesforce/sf-plugins-core';
import { EnvironmentVariable, Messages, SfError } from '@salesforce/core';
import { AgentTester, AgentTestResultsResponse } from '@salesforce/agents';
import { resultFormatFlag, testOutputDirFlag, verboseFlag } from '../../../flags.js';
import { AgentTestResultsResponse, AgentTestNGTResultsResponse } from '@salesforce/agents';
import { resultFormatFlag, testOutputDirFlag, testRunnerFlag, verboseFlag } from '../../../flags.js';
import { handleTestResults } from '../../../handleTestResults.js';
import { createTestRunner } from '../../../testRunnerFactory.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.results');

export type AgentTestResultsResult = AgentTestResultsResponse;
export type AgentTestResultsResult = AgentTestResultsResponse | AgentTestNGTResultsResponse;

export default class AgentTestResults extends SfCommand<AgentTestResultsResult> {
public static readonly summary = messages.getMessage('summary');
Expand Down Expand Up @@ -51,13 +52,20 @@ export default class AgentTestResults extends SfCommand<AgentTestResultsResult>
}),
'result-format': resultFormatFlag(),
'output-dir': testOutputDirFlag(),
'test-runner': testRunnerFlag,
verbose: verboseFlag,
};

public async run(): Promise<AgentTestResultsResult> {
const { flags } = await this.parse(AgentTestResults);

const agentTester = new AgentTester(flags['target-org'].getConnection(flags['api-version']));
const connection = flags['target-org'].getConnection(flags['api-version']);
const { runner: agentTester } = await createTestRunner(
connection,
flags['test-runner'],
undefined,
flags['job-id']
);

let response;
try {
Expand Down
Loading
Loading