@elisra-devops/docgen-data-provider 1.63.11 → 1.63.13

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.
@@ -30,9 +30,7 @@ describe('TicketsDataProvider', () => {
30
30
  const result = await ticketsDataProvider.FetchImageAsBase64(mockUrl);
31
31
 
32
32
  // Assert
33
- expect(TFSServices.fetchAzureDevOpsImageAsBase64).toHaveBeenCalledWith(
34
- mockUrl, mockToken, 'get', null
35
- );
33
+ expect(TFSServices.fetchAzureDevOpsImageAsBase64).toHaveBeenCalledWith(mockUrl, mockToken, 'get', null);
36
34
  expect(result).toBe(mockBase64);
37
35
  });
38
36
  });
@@ -62,7 +60,7 @@ describe('TicketsDataProvider', () => {
62
60
  const mockIds = [1, 2];
63
61
  const mockWorkItems = [
64
62
  { id: 1, fields: { 'System.Title': 'Item 1' } },
65
- { id: 2, fields: { 'System.Title': 'Item 2' } }
63
+ { id: 2, fields: { 'System.Title': 'Item 2' } },
66
64
  ];
67
65
  const mockLinksMap = new Map();
68
66
  mockLinksMap.set('1', { id: '1', rels: ['3'] });
@@ -73,7 +71,8 @@ describe('TicketsDataProvider', () => {
73
71
 
74
72
  jest.spyOn(ticketsDataProvider, 'PopulateWorkItemsByIds').mockResolvedValueOnce(mockWorkItems);
75
73
  jest.spyOn(ticketsDataProvider, 'GetRelationsIds').mockResolvedValueOnce(mockLinksMap);
76
- jest.spyOn(ticketsDataProvider, 'GetParentLink')
74
+ jest
75
+ .spyOn(ticketsDataProvider, 'GetParentLink')
77
76
  .mockResolvedValueOnce(mockTraceItem)
78
77
  .mockResolvedValueOnce({ id: '2', title: 'Item 2', url: 'url', customerId: 'customer', links: [] });
79
78
  jest.spyOn(ticketsDataProvider, 'PopulateWorkItemsByIds').mockResolvedValueOnce(mockRelatedItems);
@@ -94,11 +93,21 @@ describe('TicketsDataProvider', () => {
94
93
  // Arrange
95
94
  const mockPath = '';
96
95
  const mockDocType = 'STD';
97
- const mockQueries = { name: 'Query 1' };
98
- const mockResponse = { reqTestTree: {}, testReqTree: {} };
96
+ const mockQueries = { name: 'Query 1' } as any;
97
+ const mockBranchesResponse = {
98
+ reqToTest: { result: { reqTestTree: {} }, usedFolder: {} },
99
+ testToReq: { result: { testReqTree: {} }, usedFolder: {} },
100
+ mom: { result: { linkedMomTree: {} }, usedFolder: {} },
101
+ } as any;
99
102
 
100
103
  (TFSServices.getItemContent as jest.Mock).mockResolvedValueOnce(mockQueries);
101
- jest.spyOn(ticketsDataProvider as any, 'fetchLinkedQueries').mockResolvedValueOnce(mockResponse);
104
+ jest.spyOn(ticketsDataProvider as any, 'ensureQueryChildren').mockResolvedValueOnce(mockQueries);
105
+ jest
106
+ .spyOn(ticketsDataProvider as any, 'getDocTypeRoot')
107
+ .mockResolvedValueOnce({ root: mockQueries, found: true });
108
+ jest
109
+ .spyOn(ticketsDataProvider as any, 'fetchDocTypeBranches')
110
+ .mockResolvedValueOnce(mockBranchesResponse);
102
111
 
103
112
  // Act
104
113
  const result = await ticketsDataProvider.GetSharedQueries(mockProject, mockPath, mockDocType);
@@ -108,18 +117,30 @@ describe('TicketsDataProvider', () => {
108
117
  `${mockOrgUrl}${mockProject}/_apis/wit/queries/Shared%20Queries?$depth=2&$expand=all`,
109
118
  mockToken
110
119
  );
111
- expect(result).toEqual(mockResponse);
120
+ expect(result).toEqual({
121
+ reqTestQueries: { reqTestTree: {}, testReqTree: {} },
122
+ linkedMomQueries: { linkedMomTree: {} },
123
+ });
112
124
  });
113
125
 
114
126
  it('should fetch SVD shared queries and call fetchAnyQueries', async () => {
115
127
  // Arrange
116
128
  const mockPath = 'Custom Path';
117
129
  const mockDocType = 'SVD';
118
- const mockQueries = { name: 'Query 1' };
119
- const mockResponse = { systemOverviewQueryTree: {}, knownBugsQueryTree: {} };
130
+ const mockQueries = { name: 'Query 1' } as any;
131
+ const mockBranchesResponse = {
132
+ systemOverview: { result: {}, usedFolder: {} },
133
+ knownBugs: { result: {}, usedFolder: {} },
134
+ } as any;
120
135
 
121
136
  (TFSServices.getItemContent as jest.Mock).mockResolvedValueOnce(mockQueries);
122
- jest.spyOn(ticketsDataProvider as any, 'fetchAnyQueries').mockResolvedValueOnce(mockResponse);
137
+ jest.spyOn(ticketsDataProvider as any, 'ensureQueryChildren').mockResolvedValueOnce(mockQueries);
138
+ jest
139
+ .spyOn(ticketsDataProvider as any, 'getDocTypeRoot')
140
+ .mockResolvedValueOnce({ root: mockQueries, found: true });
141
+ jest
142
+ .spyOn(ticketsDataProvider as any, 'fetchDocTypeBranches')
143
+ .mockResolvedValueOnce(mockBranchesResponse);
123
144
 
124
145
  // Act
125
146
  const result = await ticketsDataProvider.GetSharedQueries(mockProject, mockPath, mockDocType);
@@ -129,7 +150,10 @@ describe('TicketsDataProvider', () => {
129
150
  `${mockOrgUrl}${mockProject}/_apis/wit/queries/${mockPath}?$depth=2&$expand=all`,
130
151
  mockToken
131
152
  );
132
- expect(result).toEqual(mockResponse);
153
+ expect(result).toEqual({
154
+ systemOverviewQueryTree: {},
155
+ knownBugsQueryTree: {},
156
+ });
133
157
  });
134
158
 
135
159
  it('should handle errors', async () => {
@@ -142,8 +166,7 @@ describe('TicketsDataProvider', () => {
142
166
  });
143
167
 
144
168
  // Act & Assert
145
- await expect(ticketsDataProvider.GetSharedQueries(mockProject, mockPath))
146
- .rejects.toThrow('API error');
169
+ await expect(ticketsDataProvider.GetSharedQueries(mockProject, mockPath)).rejects.toThrow('API error');
147
170
  expect(logger.error).toHaveBeenCalled();
148
171
  });
149
172
  });
@@ -156,22 +179,21 @@ describe('TicketsDataProvider', () => {
156
179
  const mockQueryResult = {
157
180
  queryType: QueryType.OneHop,
158
181
  columns: [],
159
- workItemRelations: [{ source: null, target: { id: 1, url: 'url' } }]
182
+ workItemRelations: [{ source: null, target: { id: 1, url: 'url' } }],
160
183
  };
161
184
  const mockTableResult = {
162
185
  sourceTargetsMap: new Map(),
163
186
  sortingSourceColumnsMap: new Map(),
164
- sortingTargetsColumnsMap: new Map()
187
+ sortingTargetsColumnsMap: new Map(),
165
188
  };
166
189
 
167
190
  (TFSServices.getItemContent as jest.Mock).mockResolvedValueOnce(mockQueryResult);
168
- jest.spyOn(ticketsDataProvider as any, 'parseDirectLinkedQueryResultForTableFormat')
191
+ jest
192
+ .spyOn(ticketsDataProvider as any, 'parseDirectLinkedQueryResultForTableFormat')
169
193
  .mockResolvedValueOnce(mockTableResult);
170
194
 
171
195
  // Act
172
- const result = await ticketsDataProvider.GetQueryResultsFromWiql(
173
- mockWiqlHref, true, mockTestCaseMap
174
- );
196
+ const result = await ticketsDataProvider.GetQueryResultsFromWiql(mockWiqlHref, true, mockTestCaseMap);
175
197
 
176
198
  // Assert
177
199
  expect(TFSServices.getItemContent).toHaveBeenCalledWith(mockWiqlHref, mockToken);
@@ -196,13 +218,13 @@ describe('TicketsDataProvider', () => {
196
218
  {
197
219
  name: 'Query 1',
198
220
  _links: { wiql: 'http://example.com/wiql1' },
199
- id: 'q1'
221
+ id: 'q1',
200
222
  },
201
223
  {
202
224
  name: 'Query 2',
203
225
  _links: { wiql: null },
204
- id: 'q2'
205
- }
226
+ id: 'q2',
227
+ },
206
228
  ];
207
229
 
208
230
  // Act
@@ -211,7 +233,7 @@ describe('TicketsDataProvider', () => {
211
233
  // Assert
212
234
  expect(result).toEqual([
213
235
  { queryName: 'Query 1', wiql: 'http://example.com/wiql1', id: 'q1' },
214
- { queryName: 'Query 2', wiql: null, id: 'q2' }
236
+ { queryName: 'Query 2', wiql: null, id: 'q2' },
215
237
  ]);
216
238
  });
217
239
  });
@@ -220,8 +242,8 @@ describe('TicketsDataProvider', () => {
220
242
  it('should fetch work items in batches of 200', async () => {
221
243
  // Arrange
222
244
  const mockIds = Array.from({ length: 250 }, (_, i) => i + 1);
223
- const mockResponse1 = { value: mockIds.slice(0, 200).map(id => ({ id })) };
224
- const mockResponse2 = { value: mockIds.slice(200).map(id => ({ id })) };
245
+ const mockResponse1 = { value: mockIds.slice(0, 200).map((id) => ({ id })) };
246
+ const mockResponse2 = { value: mockIds.slice(200).map((id) => ({ id })) };
225
247
 
226
248
  (TFSServices.getItemContent as jest.Mock)
227
249
  .mockResolvedValueOnce(mockResponse1)
@@ -303,7 +325,10 @@ describe('TicketsDataProvider', () => {
303
325
 
304
326
  // Act
305
327
  const result = await ticketsDataProvider.CreateNewWorkItem(
306
- mockProject, mockWiBody, mockWiType, mockByPass
328
+ mockProject,
329
+ mockWiBody,
330
+ mockWiType,
331
+ mockByPass
307
332
  );
308
333
 
309
334
  // Assert
@@ -313,7 +338,7 @@ describe('TicketsDataProvider', () => {
313
338
  'POST',
314
339
  mockWiBody,
315
340
  {
316
- 'Content-Type': 'application/json-patch+json'
341
+ 'Content-Type': 'application/json-patch+json',
317
342
  }
318
343
  );
319
344
  expect(result).toEqual(mockResponse);
@@ -332,7 +357,10 @@ describe('TicketsDataProvider', () => {
332
357
 
333
358
  // Act
334
359
  const result = await ticketsDataProvider.UpdateWorkItem(
335
- mockProject, mockWiBody, mockWorkItemId, mockByPass
360
+ mockProject,
361
+ mockWiBody,
362
+ mockWorkItemId,
363
+ mockByPass
336
364
  );
337
365
 
338
366
  // Assert
@@ -342,7 +370,7 @@ describe('TicketsDataProvider', () => {
342
370
  'patch',
343
371
  mockWiBody,
344
372
  {
345
- 'Content-Type': 'application/json-patch+json'
373
+ 'Content-Type': 'application/json-patch+json',
346
374
  }
347
375
  );
348
376
  expect(result).toEqual(mockResponse);
@@ -358,9 +386,9 @@ describe('TicketsDataProvider', () => {
358
386
  {
359
387
  rel: 'AttachedFile',
360
388
  url: 'https://example.com/attachment/1',
361
- attributes: { name: 'file.txt' }
362
- }
363
- ]
389
+ attributes: { name: 'file.txt' },
390
+ },
391
+ ],
364
392
  };
365
393
 
366
394
  // Mock the TFSServices.getItemContent directly to return our mock data
@@ -404,14 +432,14 @@ describe('TicketsDataProvider', () => {
404
432
  {
405
433
  rel: 'Parent',
406
434
  url: 'https://example.com/parent/1',
407
- attributes: { name: 'parent' }
435
+ attributes: { name: 'parent' },
408
436
  },
409
437
  {
410
438
  rel: 'AttachedFile',
411
439
  url: 'https://example.com/attachment/1',
412
- attributes: { name: 'file.txt' }
413
- }
414
- ]
440
+ attributes: { name: 'file.txt' },
441
+ },
442
+ ],
415
443
  };
416
444
 
417
445
  // Mock TFSServices.getItemContent directly instead of GetWorkItem
@@ -428,7 +456,7 @@ describe('TicketsDataProvider', () => {
428
456
  expect(result.length).toBe(1);
429
457
  expect(result[0].rel).toBe('AttachedFile');
430
458
  // Only the AttachedFile relation should be in the result
431
- expect(result.some(item => item.rel === 'Parent')).toBe(false);
459
+ expect(result.some((item) => item.rel === 'Parent')).toBe(false);
432
460
  });
433
461
  });
434
- });
462
+ });