@elisra-devops/docgen-data-provider 1.116.0 → 1.118.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,14 +52,9 @@ describe('PipelinesDataProvider', () => {
52
52
  // Create test method to access private method
53
53
  const invokeIsMatchingPipeline = (
54
54
  fromPipeline: PipelineRun,
55
- targetPipeline: PipelineRun,
56
- searchPrevPipelineFromDifferentCommit: boolean
55
+ targetPipeline: PipelineRun
57
56
  ): boolean => {
58
- return (pipelinesDataProvider as any).isMatchingPipeline(
59
- fromPipeline,
60
- targetPipeline,
61
- searchPrevPipelineFromDifferentCommit
62
- );
57
+ return (pipelinesDataProvider as any).isMatchingPipeline(fromPipeline, targetPipeline);
63
58
  };
64
59
 
65
60
  it('should return false when repository IDs are different', () => {
@@ -93,13 +88,13 @@ describe('PipelinesDataProvider', () => {
93
88
  } as unknown as PipelineRun;
94
89
 
95
90
  // Act
96
- const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline, false);
91
+ const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline);
97
92
 
98
93
  // Assert
99
94
  expect(result).toBe(false);
100
95
  });
101
96
 
102
- it('should return true when versions are the same and searchPrevPipelineFromDifferentCommit is false', () => {
97
+ it('should return true when versions are the same and refNames match', () => {
103
98
  // Arrange
104
99
  const fromPipeline = {
105
100
  resources: {
@@ -130,49 +125,12 @@ describe('PipelinesDataProvider', () => {
130
125
  } as unknown as PipelineRun;
131
126
 
132
127
  // Act
133
- const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline, false);
128
+ const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline);
134
129
 
135
130
  // Assert
136
131
  expect(result).toBe(true);
137
132
  });
138
133
 
139
- it('should return false when versions are the same and searchPrevPipelineFromDifferentCommit is true', () => {
140
- // Arrange
141
- const fromPipeline = {
142
- resources: {
143
- repositories: {
144
- '0': {
145
- self: {
146
- repository: { id: 'repo1' },
147
- version: 'v1',
148
- refName: 'refs/heads/main',
149
- },
150
- },
151
- },
152
- },
153
- } as unknown as PipelineRun;
154
-
155
- const targetPipeline = {
156
- resources: {
157
- repositories: {
158
- '0': {
159
- self: {
160
- repository: { id: 'repo1' },
161
- version: 'v1',
162
- refName: 'refs/heads/main',
163
- },
164
- },
165
- },
166
- },
167
- } as unknown as PipelineRun;
168
-
169
- // Act
170
- const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline, true);
171
-
172
- // Assert
173
- expect(result).toBe(false);
174
- });
175
-
176
134
  it('should return true when refNames match but versions differ', () => {
177
135
  // Arrange
178
136
  const fromPipeline = {
@@ -204,7 +162,7 @@ describe('PipelinesDataProvider', () => {
204
162
  } as unknown as PipelineRun;
205
163
 
206
164
  // Act
207
- const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline, true);
165
+ const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline);
208
166
 
209
167
  // Assert
210
168
  expect(result).toBe(true);
@@ -237,7 +195,7 @@ describe('PipelinesDataProvider', () => {
237
195
  } as unknown as PipelineRun;
238
196
 
239
197
  // Act
240
- const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline, false);
198
+ const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline);
241
199
 
242
200
  // Assert
243
201
  expect(result).toBe(true);
@@ -270,7 +228,7 @@ describe('PipelinesDataProvider', () => {
270
228
  },
271
229
  } as unknown as PipelineRun;
272
230
 
273
- const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline, false);
231
+ const result = invokeIsMatchingPipeline(fromPipeline, targetPipeline);
274
232
  expect(result).toBe(true);
275
233
  });
276
234
  });
@@ -1176,8 +1134,10 @@ describe('PipelinesDataProvider', () => {
1176
1134
  } as unknown as PipelineRun;
1177
1135
 
1178
1136
  const mockRepo = {
1137
+ id: 'repo-123',
1179
1138
  name: 'MyRepo',
1180
1139
  url: 'https://dev.azure.com/org/project/_git/MyRepo',
1140
+ // no project field → falls back to repo.url
1181
1141
  };
1182
1142
 
1183
1143
  const mockGitDataProvider = {
@@ -1199,6 +1159,45 @@ describe('PipelinesDataProvider', () => {
1199
1159
  });
1200
1160
  });
1201
1161
 
1162
+ it('should use project-name URL when repo response includes project.name (on-prem TFS WI fix)', async () => {
1163
+ // On-prem TFS canonicalizes repo.url to a project-UUID form, but commitsbatch only
1164
+ // resolves workItems when the URL uses the project name. This test verifies the URL
1165
+ // is rewritten to project-name form when project.name is available.
1166
+ const inPipeline = {
1167
+ resources: {
1168
+ repositories: {
1169
+ self: {
1170
+ repository: { id: 'b671b0fa-1111-2222-3333-444444444444', type: 'TfsGit' },
1171
+ version: 'abc123',
1172
+ },
1173
+ },
1174
+ },
1175
+ } as unknown as PipelineRun;
1176
+
1177
+ const mockRepo = {
1178
+ id: 'b671b0fa-1111-2222-3333-444444444444',
1179
+ name: 'eden1',
1180
+ url: 'http://elis-tfs:8080/tfs/ElisraCollection/5d662fe5-uuid/_apis/git/repositories/b671b0fa-1111-2222-3333-444444444444',
1181
+ project: { id: '5d662fe5-uuid', name: 'TestProject-CMMI' },
1182
+ };
1183
+
1184
+ const mockGitDataProvider = {
1185
+ GetGitRepoFromRepoId: jest.fn().mockResolvedValue(mockRepo),
1186
+ } as unknown as GitDataProvider;
1187
+
1188
+ // Act
1189
+ const result = await pipelinesDataProvider.getPipelineResourceRepositoriesFromObject(
1190
+ inPipeline,
1191
+ mockGitDataProvider
1192
+ );
1193
+
1194
+ // Assert — URL must use project NAME, not UUID
1195
+ expect(result).toHaveLength(1);
1196
+ expect((result as any[])[0].url).toContain('TestProject-CMMI');
1197
+ expect((result as any[])[0].url).not.toContain('5d662fe5-uuid');
1198
+ expect((result as any[])[0].url).toContain('b671b0fa-1111-2222-3333-444444444444');
1199
+ });
1200
+
1202
1201
  it('should skip non-azureReposGit repositories', async () => {
1203
1202
  // Arrange
1204
1203
  const inPipeline = {
@@ -1270,8 +1269,7 @@ describe('PipelinesDataProvider', () => {
1270
1269
  teamProject,
1271
1270
  pipelineId,
1272
1271
  toPipelineRunId,
1273
- targetPipeline,
1274
- false
1272
+ targetPipeline
1275
1273
  );
1276
1274
 
1277
1275
  // Assert
@@ -1315,8 +1313,7 @@ describe('PipelinesDataProvider', () => {
1315
1313
  teamProject,
1316
1314
  pipelineId,
1317
1315
  toPipelineRunId,
1318
- targetPipeline,
1319
- true
1316
+ targetPipeline
1320
1317
  );
1321
1318
  expect(res).toBe(99);
1322
1319
  });
@@ -1342,7 +1339,6 @@ describe('PipelinesDataProvider', () => {
1342
1339
  pipelineId,
1343
1340
  toPipelineRunId,
1344
1341
  targetPipeline,
1345
- false,
1346
1342
  'Deploy'
1347
1343
  );
1348
1344
 
@@ -1368,8 +1364,7 @@ describe('PipelinesDataProvider', () => {
1368
1364
  teamProject,
1369
1365
  pipelineId,
1370
1366
  toPipelineRunId,
1371
- targetPipeline,
1372
- false
1367
+ targetPipeline
1373
1368
  );
1374
1369
 
1375
1370
  expect(res).toBeUndefined();
@@ -1430,8 +1425,7 @@ describe('PipelinesDataProvider', () => {
1430
1425
  teamProject,
1431
1426
  pipelineId,
1432
1427
  toPipelineRunId,
1433
- targetPipeline,
1434
- true
1428
+ targetPipeline
1435
1429
  );
1436
1430
 
1437
1431
  // Assert
@@ -1453,8 +1447,7 @@ describe('PipelinesDataProvider', () => {
1453
1447
  'project1',
1454
1448
  '123',
1455
1449
  100,
1456
- targetPipelineRun,
1457
- true
1450
+ targetPipelineRun
1458
1451
  );
1459
1452
 
1460
1453
  expect(result).toBe(80);
@@ -1477,8 +1470,7 @@ describe('PipelinesDataProvider', () => {
1477
1470
  'project1',
1478
1471
  '123',
1479
1472
  100,
1480
- targetPipelineRun,
1481
- true
1473
+ targetPipelineRun
1482
1474
  );
1483
1475
 
1484
1476
  expect(result).toBe(90);
@@ -1503,8 +1495,7 @@ describe('PipelinesDataProvider', () => {
1503
1495
  'project1',
1504
1496
  '123',
1505
1497
  100,
1506
- targetPipelineRun,
1507
- true
1498
+ targetPipelineRun
1508
1499
  );
1509
1500
 
1510
1501
  expect(result).toBe(95);
@@ -1533,8 +1524,7 @@ describe('PipelinesDataProvider', () => {
1533
1524
  'project1',
1534
1525
  '123',
1535
1526
  100,
1536
- targetPipelineRun,
1537
- true
1527
+ targetPipelineRun
1538
1528
  );
1539
1529
 
1540
1530
  const url = (TFSServices.getItemContentWithHeaders as jest.Mock).mock.calls[0][0];
@@ -1549,7 +1539,7 @@ describe('PipelinesDataProvider', () => {
1549
1539
  (TFSServices.getItemContentWithHeaders as jest.Mock).mockRejectedValueOnce(new Error('same branch failed'));
1550
1540
 
1551
1541
  await expect(
1552
- pipelinesDataProvider.findPreviousPipeline('project1', '123', 100, targetPipelineRun, true)
1542
+ pipelinesDataProvider.findPreviousPipeline('project1', '123', 100, targetPipelineRun)
1553
1543
  ).rejects.toThrow('same branch failed');
1554
1544
 
1555
1545
  expect(TFSServices.getItemContentWithHeaders).toHaveBeenCalledTimes(1);
@@ -1568,7 +1558,7 @@ describe('PipelinesDataProvider', () => {
1568
1558
  .mockRejectedValueOnce(new Error('fallback failed'));
1569
1559
 
1570
1560
  await expect(
1571
- pipelinesDataProvider.findPreviousPipeline('project1', '123', 100, targetPipelineRun, true)
1561
+ pipelinesDataProvider.findPreviousPipeline('project1', '123', 100, targetPipelineRun)
1572
1562
  ).rejects.toThrow('fallback failed');
1573
1563
 
1574
1564
  expect(TFSServices.getItemContentWithHeaders).toHaveBeenCalledTimes(2);
@@ -1586,7 +1576,7 @@ describe('PipelinesDataProvider', () => {
1586
1576
  .mockRejectedValueOnce(new Error('build page failed'));
1587
1577
 
1588
1578
  await expect(
1589
- pipelinesDataProvider.findPreviousPipeline('project1', '123', 100, targetPipelineRun, true)
1579
+ pipelinesDataProvider.findPreviousPipeline('project1', '123', 100, targetPipelineRun)
1590
1580
  ).rejects.toThrow('build page failed');
1591
1581
  });
1592
1582
 
@@ -1599,7 +1589,7 @@ describe('PipelinesDataProvider', () => {
1599
1589
  );
1600
1590
 
1601
1591
  await expect(
1602
- pipelinesDataProvider.findPreviousPipeline('project1', '123', 100, targetPipelineRun, true)
1592
+ pipelinesDataProvider.findPreviousPipeline('project1', '123', 100, targetPipelineRun)
1603
1593
  ).rejects.toThrow('Pipeline discovery exceeded 50 pages');
1604
1594
  });
1605
1595
  });