Skip to content

Commit 93bd6d1

Browse files
committed
fix: unit test
1 parent fe691ed commit 93bd6d1

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

command-snapshot.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
"command": "devops:project:list",
55
"flagAliases": [],
66
"flagChars": ["o"],
7-
"flags": ["json", "target-org"],
7+
"flags": ["api-version", "json", "target-org"],
88
"plugin": "@salesforce/plugin-devops-center"
99
},
1010
{
1111
"alias": [],
1212
"command": "devops:work-item:create",
1313
"flagAliases": [],
1414
"flagChars": ["d", "o", "p", "s"],
15-
"flags": ["description", "json", "project-id", "subject", "target-org"],
15+
"flags": ["api-version", "description", "json", "project-id", "subject", "target-org"],
1616
"plugin": "@salesforce/plugin-devops-center"
1717
},
1818
{
1919
"alias": [],
2020
"command": "devops:work-item:list",
2121
"flagAliases": [],
2222
"flagChars": ["o", "p"],
23-
"flags": ["json", "project-id", "target-org"],
23+
"flags": ["api-version", "json", "project-id", "target-org"],
2424
"plugin": "@salesforce/plugin-devops-center"
2525
},
2626
{

src/utils/pipelineUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { DevopsProjectPipelineQueryRecord, PipelineStageRecord } from './types';
1111
export async function getPipelineIdForProject(connection: Connection, projectId: string): Promise<string | undefined> {
1212
const query = `SELECT DevopsPipelineId FROM DevopsProjectPipeline WHERE DevopsProjectId = '${projectId}' LIMIT 1`;
1313
const result = await connection.query<DevopsProjectPipelineQueryRecord>(query);
14-
return result.records[0]?.DevopsPipelineId;
14+
return (result.records ?? [])[0]?.DevopsPipelineId;
1515
}
1616

1717
export async function fetchPipelineStages(connection: Connection, pipelineId: string): Promise<PipelineStageRecord[]> {

test/commands/devops/work-item/create.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('devops work-item create', () => {
4141
'--target-org',
4242
'testOrg',
4343
'--project-id',
44-
'PROJ001',
44+
'1Qg000000000001',
4545
'--subject',
4646
'Fix bug',
4747
])
@@ -67,7 +67,7 @@ describe('devops work-item create', () => {
6767
'--target-org',
6868
'testOrg',
6969
'--project-id',
70-
'PROJ001',
70+
'1Qg000000000001',
7171
'--subject',
7272
'Fix bug',
7373
])
@@ -93,7 +93,7 @@ describe('devops work-item create', () => {
9393
'--target-org',
9494
'testOrg',
9595
'--project-id',
96-
'PROJ001',
96+
'1Qg000000000001',
9797
'--subject',
9898
'Fix bug',
9999
])
@@ -119,7 +119,7 @@ describe('devops work-item create', () => {
119119
'--target-org',
120120
'testOrg',
121121
'--project-id',
122-
'PROJ001',
122+
'1Qg000000000001',
123123
'--subject',
124124
'Fix bug',
125125
])
@@ -143,7 +143,7 @@ describe('devops work-item create', () => {
143143
'--target-org',
144144
'testOrg',
145145
'--project-id',
146-
'PROJ001',
146+
'1Qg000000000001',
147147
'--subject',
148148
'Fix bug',
149149
])

test/commands/devops/work-item/list.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const MOCK_WORK_ITEM: WorkItem = {
1818
description: 'Details',
1919
status: 'In Progress',
2020
owner: 'USER001',
21-
DevopsProjectId: 'PROJ001',
21+
DevopsProjectId: '1Qg000000000001',
2222
WorkItemBranch: 'feature/branch',
2323
TargetBranch: 'main',
2424
};
@@ -43,7 +43,7 @@ describe('devops work-item list', () => {
4343
sandbox.stub(Org, 'create' as any).returns(mockOrg);
4444
sandbox.stub(workItemsModule, 'fetchWorkItems').resolves([MOCK_WORK_ITEM]);
4545
})
46-
.command(['devops:work-item:list', '--target-org', 'testOrg', '--project-id', 'PROJ001'])
46+
.command(['devops:work-item:list', '--target-org', 'testOrg', '--project-id', '1Qg000000000001'])
4747
.it('displays work items in table', (ctx) => {
4848
expect(ctx.stdout).to.contain('WI-001');
4949
});
@@ -57,7 +57,7 @@ describe('devops work-item list', () => {
5757
sandbox.stub(Org, 'create' as any).returns(mockOrg);
5858
sandbox.stub(workItemsModule, 'fetchWorkItems').resolves([]);
5959
})
60-
.command(['devops:work-item:list', '--target-org', 'testOrg', '--project-id', 'PROJ001'])
60+
.command(['devops:work-item:list', '--target-org', 'testOrg', '--project-id', '1Qg000000000001'])
6161
.it('logs message when no work items', (ctx) => {
6262
expect(ctx.stdout).to.contain('No work items found');
6363
});
@@ -72,7 +72,7 @@ describe('devops work-item list', () => {
7272
sandbox.stub(Org, 'create' as any).returns(mockOrg);
7373
sandbox.stub(workItemsModule, 'fetchWorkItems').rejects(new Error("sObject type 'WorkItem' is not supported"));
7474
})
75-
.command(['devops:work-item:list', '--target-org', 'testOrg', '--project-id', 'PROJ001'])
75+
.command(['devops:work-item:list', '--target-org', 'testOrg', '--project-id', '1Qg000000000001'])
7676
.catch(() => {})
7777
.it('shows DevOps Center not enabled error', (ctx) => {
7878
expect(ctx.stderr).to.contain('DevOps Center is not enabled');
@@ -88,7 +88,7 @@ describe('devops work-item list', () => {
8888
sandbox.stub(Org, 'create' as any).returns(mockOrg);
8989
sandbox.stub(workItemsModule, 'fetchWorkItems').rejects(new Error('Network error'));
9090
})
91-
.command(['devops:work-item:list', '--target-org', 'testOrg', '--project-id', 'PROJ001'])
91+
.command(['devops:work-item:list', '--target-org', 'testOrg', '--project-id', '1Qg000000000001'])
9292
.catch((err) => {
9393
expect(err.message).to.contain('Network error');
9494
})

0 commit comments

Comments
 (0)