Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into cd/support-mpd
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Mar 11, 2025
2 parents 704d354 + 9c02119 commit bcb3579
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 35 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"group": "inline"
},
{
"command": "sf.agent.test.view.goToDefinition",
"command": "sf.agent.test.view.goToTestResults",
"when": "view == sf.agent.test.view && viewItem =~ /(agentTest|agentTestGroup)(_Pass|_Skip|\\b)/"
}
],
Expand All @@ -154,7 +154,7 @@
},
"commandPalette": [
{
"command": "sf.agent.test.view.goToDefinition",
"command": "sf.agent.test.view.goToTestResults",
"when": "false"
},
{
Expand All @@ -180,8 +180,8 @@
],
"commands": [
{
"command": "sf.agent.test.view.goToDefinition",
"title": "%go_to_definition_title%",
"command": "sf.agent.test.view.goToTestResults",
"title": "%go_to_test_results%",
"icon": {
"light": "resources/light/notRun.svg",
"dark": "resources/dark/notRun.svg"
Expand Down
2 changes: 1 addition & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"run_all_tests_title": "Run All Test Definitions",
"run_test_title": "Run Test Definition",
"refresh_test_title": "Refresh Test Definitions",
"go_to_definition_title": "View Test Definition",
"go_to_test_results": "SFDX: View Test Results",
"collapse_tests_title": "Collapse All Test Cases"
}
2 changes: 1 addition & 1 deletion src/enums/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export enum Commands {
openAgentInOrg = 'salesforcedx-vscode-agents.openAgentInOrg',
goToDefinition = 'sf.agent.test.view.goToDefinition',
goToTestResults = 'sf.agent.test.view.goToTestResults',
runTest = 'sf.agent.test.view.runTest',
refreshTestView = 'sf.agent.test.view.refresh',
collapseAll = 'sf.agent.test.view.collapseAll'
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const registerTestView = (): vscode.Disposable => {
const testRunner = new AgentTestRunner(testOutlineProvider);

testViewItems.push(
vscode.commands.registerCommand(Commands.goToDefinition, (test: TestNode) => {
vscode.commands.registerCommand(Commands.goToTestResults, (test: TestNode) => {
testRunner.displayTestDetails(test);
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/types/TestNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export abstract class TestNode extends vscode.TreeItem {
) {
super(name, collapsibleState);
this.command = {
command: `sf.agent.test.view.goToDefinition`,
command: `sf.agent.test.view.goToTestResults`,
title: 'SHOW ERROR',
arguments: [this]
};
Expand Down
56 changes: 29 additions & 27 deletions src/views/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,38 @@ export class AgentTestRunner {
channelService.clear();

const resultFromMap = this.testGroupNameToResult.get(test.name) ?? this.testGroupNameToResult.get(test.parentName);
if (resultFromMap) {
// set to a new var so we can remove test cases and not affect saved information
const testInfo = structuredClone(resultFromMap);
if (test instanceof AgentTestNode) {
// filter to selected test case
testInfo.testCases = testInfo.testCases.filter(f => `#${f.testNumber}` === test.name);
}
testInfo.testCases.map(tc => {
channelService.appendLine('════════════════════════════════════════════════════════════════════════');
channelService.appendLine(`CASE #${tc.testNumber} - ${testInfo.subjectName}`);
channelService.appendLine('════════════════════════════════════════════════════════════════════════');
channelService.appendLine('');
channelService.appendLine(`"${tc.inputs.utterance}"`);
channelService.appendLine('');
tc.testResults.map(tr => {
channelService.appendLine(
`❯ ${humanFriendlyName(tr.name).toUpperCase()}: ${tr.result} ${tr.result === 'PASS' ? '✅' : '❌'}`
);
channelService.appendLine('────────────────────────────────────────────────────────────────────────');
channelService.appendLine(`EXPECTED : ${tr.expectedValue.replaceAll('\n', '')}`);
channelService.appendLine(`ACTUAL : ${tr.actualValue.replaceAll('\n', '')}`);
channelService.appendLine(`SCORE : ${tr.score}`);
channelService.appendLine('');
});
channelService.appendLine('────────────────────────────────────────────────────────────────────────');
if (!resultFromMap) {
vscode.window.showErrorMessage('You need to run the test first to see its results.');
return;
}
// set to a new var so we can remove test cases and not affect saved information
const testInfo = structuredClone(resultFromMap);
if (test instanceof AgentTestNode) {
// filter to selected test case
testInfo.testCases = testInfo.testCases.filter(f => `#${f.testNumber}` === test.name);
}
testInfo.testCases.map(tc => {
channelService.appendLine('════════════════════════════════════════════════════════════════════════');
channelService.appendLine(`CASE #${tc.testNumber} - ${testInfo.subjectName}`);
channelService.appendLine('════════════════════════════════════════════════════════════════════════');
channelService.appendLine('');
channelService.appendLine(`"${tc.inputs.utterance}"`);
channelService.appendLine('');
tc.testResults.map(tr => {
channelService.appendLine(
`TEST CASE SUMMARY: ${tc.testResults.length} tests run | ✅ ${tc.testResults.filter(tc => tc.result === 'PASS').length} passed | ❌ ${tc.testResults.filter(tc => tc.result === 'FAILURE').length} failed`
`${humanFriendlyName(tr.name).toUpperCase()}: ${tr.result} ${tr.result === 'PASS' ? '✅' : '❌'}`
);
channelService.appendLine('────────────────────────────────────────────────────────────────────────');
channelService.appendLine(`EXPECTED : ${tr.expectedValue.replaceAll('\n', '')}`);
channelService.appendLine(`ACTUAL : ${tr.actualValue.replaceAll('\n', '')}`);
channelService.appendLine(`SCORE : ${tr.score}`);
channelService.appendLine('');
});
}
channelService.appendLine('────────────────────────────────────────────────────────────────────────');
channelService.appendLine(
`TEST CASE SUMMARY: ${tc.testResults.length} tests run | ✅ ${tc.testResults.filter(tc => tc.result === 'PASS').length} passed | ❌ ${tc.testResults.filter(tc => tc.result === 'FAILURE').length} failed`
);
});
}

public async runAgentTest(test: AgentTestGroupNode) {
Expand Down

0 comments on commit bcb3579

Please sign in to comment.