Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add TAP option #43

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 7 additions & 1 deletion schemas/agent-test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@
"errorMessage": {
"type": "string"
},
"subjectName": {
"type": "string"
},
"testSetName": {
"type": "string"
},
"testCases": {
"type": "array",
"items": {
"$ref": "#/definitions/TestCaseResult"
}
}
},
"required": ["status", "startTime", "testCases"],
"required": ["status", "startTime", "subjectName", "testSetName", "testCases"],
"additionalProperties": false
},
"TestStatus": {
Expand Down
7 changes: 1 addition & 6 deletions src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'shared');

export const resultFormatFlag = Flags.option({
options: [
'json',
'human',
'junit',
// 'tap',
] as const,
options: ['json', 'human', 'junit', 'tap'] as const,
default: 'human',
summary: messages.getMessage('flags.result-format.summary'),
});
Expand Down
12 changes: 10 additions & 2 deletions src/handleTestResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { join } from 'node:path';
import { writeFile, mkdir } from 'node:fs/promises';
import { AgentTestDetailsResponse, jsonFormat, humanFormat, junitFormat } from '@salesforce/agents';
import { AgentTestDetailsResponse, jsonFormat, humanFormat, junitFormat, tapFormat } from '@salesforce/agents';
import { Ux } from '@salesforce/sf-plugins-core/Ux';

async function writeFileToDir(outputDir: string, fileName: string, content: string): Promise<void> {
Expand All @@ -24,7 +24,7 @@ export async function handleTestResults({
outputDir,
}: {
id: string;
format: 'human' | 'json' | 'junit';
format: 'human' | 'json' | 'junit' | 'tap';
results: AgentTestDetailsResponse | undefined;
jsonEnabled: boolean;
outputDir?: string;
Expand Down Expand Up @@ -59,4 +59,12 @@ export async function handleTestResults({
await writeFileToDir(outputDir, `test-result-${id}.xml`, formatted);
}
}

if (format === 'tap') {
const formatted = await tapFormat(results);
ux.log(formatted);
if (outputDir) {
await writeFileToDir(outputDir, `test-result-${id}.txt`, formatted);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"startTime": "2024-11-28T12:00:00Z",
"endTime": "2024-11-28T12:05:00Z",
"errorMessage": null,
"subjectName": "Copilot_for_Salesforce",
"testSetName": "CRM_Sanity_v1",
"testCases": [
{
"status": "COMPLETED",
Expand Down
Loading