@@ -9,7 +9,7 @@ import path from 'node:path';
99import { EOL } from 'node:os' ;
1010import { execCmd , TestSession } from '@salesforce/cli-plugins-testkit' ;
1111import { expect } from 'chai' ;
12- import { ensureString } from '@salesforce/ts-types' ;
12+ import { AnyJson , ensureString } from '@salesforce/ts-types' ;
1313import { validateCsv } from '../../../testUtil.js' ;
1414import { DataImportBulkResult } from '../../../../src/commands/data/import/bulk.js' ;
1515import { DataBulkResultsResult } from '../../../../src/commands/data/bulk/results.js' ;
@@ -61,15 +61,22 @@ describe('data bulk results NUTs', () => {
6161 it ( 'should get success/failure results from a bulk import' , async ( ) => {
6262 const csvFile = await generateAccountsCsv ( session . project . dir , 5000 ) ;
6363
64- const bulkImportAsync = execCmd < DataImportBulkResult > (
65- `data import bulk --file ${ csvFile } --sobject account --wait 3 --json` ,
66- { ensureExitCode : 0 }
67- ) . jsonOutput ?. result as DataImportBulkResult ;
64+ type bulkImportErrResponse = AnyJson & {
65+ data : {
66+ jobId : string ;
67+ state : string ;
68+ } ;
69+ } ;
70+
71+ // the CSV will have 5000 wrong rows so the command is expected to fail, we just need the job ID from the response to get results
72+ const bulkImportErr = execCmd ( `data import bulk --file ${ csvFile } --sobject account --wait 5 --json` , {
73+ ensureExitCode : 1 ,
74+ } ) . jsonOutput as unknown as bulkImportErrResponse ;
6875
69- expect ( bulkImportAsync . jobId ) . not . to . be . undefined ;
70- expect ( bulkImportAsync . jobId ) . to . be . length ( 18 ) ;
76+ expect ( bulkImportErr . data . jobId ) . not . to . be . undefined ;
77+ expect ( bulkImportErr . data . jobId ) . to . be . length ( 18 ) ;
7178
72- const results = execCmd < DataBulkResultsResult > ( `data bulk results --job-id ${ bulkImportAsync . jobId } --json` , {
79+ const results = execCmd < DataBulkResultsResult > ( `data bulk results --job-id ${ bulkImportErr . data . jobId } --json` , {
7380 ensureExitCode : 0 ,
7481 } ) . jsonOutput ?. result as DataBulkResultsResult ;
7582
0 commit comments