Skip to content

Commit e85d10f

Browse files
Merge pull request #300 from salesforcecli/wr/pinSDR
chore: bump SDR, fix test-setup @W-20838930@
2 parents 578d94c + 28a98d3 commit e85d10f

13 files changed

+768
-660
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"@oclif/core": "^4",
1111
"@oclif/multi-stage-output": "^0.8.29",
1212
"@salesforce/agents": "^0.20.0",
13-
"@salesforce/core": "^8.23.7",
13+
"@salesforce/core": "^8.24.0",
1414
"@salesforce/kit": "^3.2.3",
1515
"@salesforce/sf-plugins-core": "^12.2.6",
16-
"@salesforce/source-deploy-retrieve": "^12.31.2",
16+
"@salesforce/source-deploy-retrieve": "^12.31.6",
1717
"@salesforce/types": "^1.5.0",
1818
"ansis": "^3.3.2",
1919
"fast-xml-parser": "^4.5.1",

test/nuts/agent.activate.nut.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ describe('agent activate/deactivate NUTs', function () {
4747
return lastBotVersion.Status;
4848
};
4949

50-
before(async () => {
50+
before(async function () {
51+
this.timeout(30 * 60 * 1000); // 30 minutes for setup
5152
await getTestSession();
5253
username = getUsername();
5354
defaultOrg = await Org.create({ aliasOrUsername: username });

test/nuts/agent.create.nut.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ import { getTestSession, getUsername } from './shared-setup.js';
2525

2626
/* eslint-disable no-console */
2727

28-
describe('agent create', () => {
28+
describe('agent create', function () {
29+
// Increase timeout for setup since shared setup includes long waits and deployments
30+
this.timeout(30 * 60 * 1000); // 30 minutes
31+
2932
let session: TestSession;
3033
let username: string;
3134
const specFileName = genUniqueString('agentSpec_%s.yaml');
3235

33-
before(async () => {
36+
before(async function () {
37+
this.timeout(30 * 60 * 1000); // 30 minutes for setup
3438
session = await getTestSession();
3539
username = getUsername();
3640
});

test/nuts/agent.generate.authoring-bundle.nut.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ import { getTestSession, getUsername } from './shared-setup.js';
2424

2525
let session: TestSession;
2626

27-
describe('agent generate authoring-bundle NUTs', () => {
28-
before(async () => {
27+
describe('agent generate authoring-bundle NUTs', function () {
28+
// Increase timeout for setup since shared setup includes long waits and deployments
29+
this.timeout(30 * 60 * 1000); // 30 minutes
30+
31+
before(async function () {
32+
this.timeout(30 * 60 * 1000); // 30 minutes for setup
2933
session = await getTestSession();
3034
});
3135

test/nuts/agent.generate.template.nut.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ import { execCmd } from '@salesforce/cli-plugins-testkit';
2222
import type { AgentGenerateTemplateResult } from '../../src/commands/agent/generate/template.js';
2323
import { getTestSession } from './shared-setup.js';
2424

25-
describe('agent generate template NUTs', () => {
25+
describe('agent generate template NUTs', function () {
26+
// Increase timeout for setup since shared setup includes long waits and deployments
27+
this.timeout(30 * 60 * 1000); // 30 minutes
28+
2629
let session: TestSession;
27-
before(async () => {
30+
before(async function () {
31+
this.timeout(30 * 60 * 1000); // 30 minutes for setup
2832
session = await getTestSession();
2933
});
3034

test/nuts/agent.generate.test-spec.nut.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ import { genUniqueString, TestSession } from '@salesforce/cli-plugins-testkit';
2121
import { execCmd } from '@salesforce/cli-plugins-testkit';
2222
import { getTestSession } from './shared-setup.js';
2323

24-
describe('agent generate test-spec NUTs', () => {
24+
describe('agent generate test-spec NUTs', function () {
25+
// Increase timeout for setup since shared setup includes long waits and deployments
26+
this.timeout(30 * 60 * 1000); // 30 minutes
27+
2528
let session: TestSession;
26-
before(async () => {
29+
before(async function () {
30+
this.timeout(30 * 60 * 1000); // 30 minutes for setup
2731
session = await getTestSession();
2832
});
2933

test/nuts/agent.test.create.nut.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ import { execCmd } from '@salesforce/cli-plugins-testkit';
2323
import type { AgentTestCreateResult } from '../../src/commands/agent/test/create.js';
2424
import { getTestSession, getUsername } from './shared-setup.js';
2525

26-
describe('agent test create', () => {
26+
describe('agent test create', function () {
27+
// Increase timeout for setup since shared setup includes long waits and deployments
28+
this.timeout(30 * 60 * 1000); // 30 minutes
29+
2730
let session: TestSession;
28-
before(async () => {
31+
before(async function () {
32+
this.timeout(30 * 60 * 1000); // 30 minutes for setup
2933
session = await getTestSession();
3034
});
3135
// this NUT is failing on windows due to an invalid api name, but it seems valid to me, passes on unix

test/nuts/agent.test.nut.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ import { getTestSession, getUsername } from './shared-setup.js';
2424

2525
/* eslint-disable no-console */
2626

27-
describe('agent test', () => {
27+
describe('agent test', function () {
28+
// Increase timeout for setup since shared setup includes long waits and deployments
29+
this.timeout(30 * 60 * 1000); // 30 minutes
30+
2831
const agentTestName = 'Local_Info_Agent_Test';
2932

30-
before(async () => {
33+
before(async function () {
34+
this.timeout(30 * 60 * 1000); // 30 minutes for setup
3135
await getTestSession();
3236
});
3337

test/nuts/shared-setup.ts

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
import { join } from 'node:path';
1818
import { Duration, TestSession } from '@salesforce/cli-plugins-testkit';
19-
import { ComponentSetBuilder } from '@salesforce/source-deploy-retrieve';
20-
import { Org, SfError, User } from '@salesforce/core';
21-
import { sleep } from '@salesforce/kit';
19+
import { ComponentSetBuilder, RequestStatus, type ScopedPostDeploy } from '@salesforce/source-deploy-retrieve';
20+
import { Org, SfError, User, Lifecycle } from '@salesforce/core';
21+
import { sleep, ensureArray } from '@salesforce/kit';
2222

2323
/* eslint-disable no-console */
2424

@@ -131,6 +131,74 @@ export async function getTestSession(): Promise<TestSession> {
131131

132132
// Set environment variable for string replacement
133133
process.env.AGENT_USER_USERNAME = agentUsername;
134+
process.env.SF_AAB_COMPILATION = 'false';
135+
136+
// Set up deploy event listeners to log progress
137+
const lifecycle = Lifecycle.getInstance();
138+
let lastDeployed = 0;
139+
let lastTotal = 0;
140+
141+
lifecycle.on('scopedPreDeploy', () => {
142+
console.log('[DEPLOY] Starting deployment...');
143+
// Reset progress tracking for new deployment
144+
lastDeployed = 0;
145+
lastTotal = 0;
146+
return Promise.resolve();
147+
});
148+
149+
lifecycle.on('scopedPostDeploy', (result: ScopedPostDeploy) => {
150+
const deployResult = result.deployResult.response;
151+
const status = deployResult.status;
152+
const numberComponentErrors = deployResult.numberComponentErrors ?? 0;
153+
const numberComponentsDeployed = deployResult.numberComponentsDeployed ?? 0;
154+
const numberComponentsTotal = deployResult.numberComponentsTotal ?? 0;
155+
const numberTestErrors = deployResult.numberTestErrors ?? 0;
156+
const numberTestsCompleted = deployResult.numberTestsCompleted ?? 0;
157+
const numberTestsTotal = deployResult.numberTestsTotal ?? 0;
158+
159+
// Log progress during polling (only if changed)
160+
if (
161+
(numberComponentsDeployed !== lastDeployed || numberComponentsTotal !== lastTotal) &&
162+
numberComponentsTotal > 0
163+
) {
164+
console.log(
165+
`[DEPLOY] Progress: ${numberComponentsDeployed}/${numberComponentsTotal} components deployed${
166+
numberComponentErrors > 0 ? `, ${numberComponentErrors} errors` : ''
167+
}`
168+
);
169+
lastDeployed = numberComponentsDeployed;
170+
lastTotal = numberComponentsTotal;
171+
}
172+
173+
// Log final status when deployment is complete
174+
const isComplete =
175+
status === RequestStatus.Succeeded ||
176+
status === RequestStatus.Failed ||
177+
status === RequestStatus.Canceled;
178+
if (isComplete) {
179+
console.log(`[DEPLOY] Deployment completed - Status: ${status}`);
180+
console.log(
181+
`[DEPLOY] Components: ${numberComponentsDeployed}/${numberComponentsTotal} deployed, ${numberComponentErrors} errors`
182+
);
183+
if (numberTestsTotal > 0) {
184+
console.log(
185+
`[DEPLOY] Tests: ${numberTestsCompleted}/${numberTestsTotal} completed, ${numberTestErrors} errors`
186+
);
187+
}
188+
const componentFailures = ensureArray(deployResult.details?.componentFailures);
189+
if (componentFailures.length > 0) {
190+
console.log(`[DEPLOY] Component failures: ${componentFailures.length}`);
191+
componentFailures.slice(0, 5).forEach((failure, idx) => {
192+
console.log(
193+
`[DEPLOY] Failure ${idx + 1}: ${failure.fullName ?? 'unknown'} - ${
194+
failure.problemType ?? 'unknown'
195+
}: ${failure.problem ?? 'unknown'}`
196+
);
197+
});
198+
}
199+
}
200+
return Promise.resolve();
201+
});
134202

135203
console.log('deploying metadata (no AiEvaluationDefinition)');
136204

@@ -141,7 +209,13 @@ export async function getTestSession(): Promise<TestSession> {
141209
},
142210
});
143211
const deploy1 = await cs1.deploy({ usernameOrConnection: defaultOrg.username });
144-
await deploy1.pollStatus({ frequency: Duration.seconds(10) });
212+
// pollStatus waits until deployment completes - will throw if deployment fails
213+
await deploy1.pollStatus({ frequency: Duration.seconds(10), timeout: Duration.minutes(30) });
214+
console.log('[DEPLOY] First deployment completed successfully');
215+
216+
// Reset for second deployment
217+
lastDeployed = 0;
218+
lastTotal = 0;
145219

146220
console.log('deploying metadata (AiEvaluationDefinition)');
147221

@@ -152,7 +226,10 @@ export async function getTestSession(): Promise<TestSession> {
152226
},
153227
});
154228
const deploy2 = await cs2.deploy({ usernameOrConnection: defaultOrg.username });
155-
await deploy2.pollStatus({ frequency: Duration.seconds(10) });
229+
// pollStatus waits until deployment completes - will throw if deployment fails
230+
await deploy2.pollStatus({ frequency: Duration.seconds(10), timeout: Duration.minutes(30) });
231+
console.log('[DEPLOY] Second deployment completed successfully');
232+
console.log('[DEPLOY] All deployments complete, tests can now run');
156233
}
157234
}
158235

test/nuts/template.nut.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ import {
2525
} from '../../src/commands/agent/generate/template.js';
2626
import { getTestSession } from './shared-setup.js';
2727

28-
describe('agent generate template NUTs', () => {
28+
describe('agent generate template NUTs', function () {
29+
// Increase timeout for setup since shared setup includes long waits and deployments
30+
this.timeout(30 * 60 * 1000); // 30 minutes
31+
2932
let session: TestSession;
3033

31-
before(async () => {
34+
before(async function () {
35+
this.timeout(30 * 60 * 1000); // 30 minutes for setup
3236
session = await getTestSession();
3337
});
3438

0 commit comments

Comments
 (0)