@elisra-devops/docgen-data-provider 1.69.19 → 1.70.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.
- package/bin/helpers/tfs.d.ts +2 -0
- package/bin/helpers/tfs.js +19 -6
- package/bin/helpers/tfs.js.map +1 -1
- package/bin/modules/ResultDataProvider.d.ts +13 -0
- package/bin/modules/ResultDataProvider.js +79 -4
- package/bin/modules/ResultDataProvider.js.map +1 -1
- package/bin/modules/TestDataProvider.d.ts +2 -0
- package/bin/modules/TestDataProvider.js +28 -4
- package/bin/modules/TestDataProvider.js.map +1 -1
- package/bin/tests/modules/testDataProvider.test.js +34 -2
- package/bin/tests/modules/testDataProvider.test.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/tfs.ts +18 -7
- package/src/modules/ResultDataProvider.ts +108 -4
- package/src/modules/TestDataProvider.ts +33 -7
- package/src/tests/modules/testDataProvider.test.ts +48 -2
|
@@ -22,6 +22,7 @@ describe('TestDataProvider', () => {
|
|
|
22
22
|
let testDataProvider: TestDataProvider;
|
|
23
23
|
const mockOrgUrl = 'https://dev.azure.com/orgname/';
|
|
24
24
|
const mockToken = 'mock-token';
|
|
25
|
+
const mockBearerToken = 'bearer:abc.def.ghi';
|
|
25
26
|
const mockProject = 'project-123';
|
|
26
27
|
const mockPlanId = '456';
|
|
27
28
|
const mockSuiteId = '789';
|
|
@@ -215,10 +216,35 @@ describe('TestDataProvider', () => {
|
|
|
215
216
|
// Assert
|
|
216
217
|
expect(result).toEqual(mockData);
|
|
217
218
|
expect(TFSServices.getItemContent).toHaveBeenCalledWith(
|
|
218
|
-
`${mockOrgUrl}/${mockProject}/_api/_testManagement/GetTestSuitesForPlan?__v=5&planId=${mockPlanId}`,
|
|
219
|
+
`${mockOrgUrl.replace(/\/+$/, '')}/${mockProject}/_api/_testManagement/GetTestSuitesForPlan?__v=5&planId=${mockPlanId}`,
|
|
219
220
|
mockToken
|
|
220
221
|
);
|
|
221
222
|
});
|
|
223
|
+
|
|
224
|
+
it('should use testplan suites endpoint for bearer token and normalize response', async () => {
|
|
225
|
+
const bearerProvider = new TestDataProvider(mockOrgUrl, mockBearerToken);
|
|
226
|
+
const mockData = {
|
|
227
|
+
value: [
|
|
228
|
+
{ id: '123', name: 'Suite 1' },
|
|
229
|
+
{ id: '456', name: 'Suite 2', parentSuite: { id: '123' } },
|
|
230
|
+
],
|
|
231
|
+
count: 2,
|
|
232
|
+
};
|
|
233
|
+
(TFSServices.getItemContent as jest.Mock).mockResolvedValueOnce(mockData);
|
|
234
|
+
|
|
235
|
+
const result = await bearerProvider.GetTestSuitesForPlan(mockProject, mockPlanId);
|
|
236
|
+
|
|
237
|
+
expect(TFSServices.getItemContent).toHaveBeenCalledWith(
|
|
238
|
+
`${mockOrgUrl.replace(/\/+$/, '')}/${mockProject}/_apis/testplan/Plans/${mockPlanId}/suites?includeChildren=true&api-version=7.0`,
|
|
239
|
+
mockBearerToken
|
|
240
|
+
);
|
|
241
|
+
expect(result.testSuites).toEqual(
|
|
242
|
+
expect.arrayContaining([
|
|
243
|
+
expect.objectContaining({ id: '123', title: 'Suite 1', parentSuiteId: 0 }),
|
|
244
|
+
expect.objectContaining({ id: '456', title: 'Suite 2', parentSuiteId: '123' }),
|
|
245
|
+
])
|
|
246
|
+
);
|
|
247
|
+
});
|
|
222
248
|
});
|
|
223
249
|
|
|
224
250
|
describe('GetTestSuiteById', () => {
|
|
@@ -235,7 +261,7 @@ describe('TestDataProvider', () => {
|
|
|
235
261
|
|
|
236
262
|
// Assert
|
|
237
263
|
expect(TFSServices.getItemContent).toHaveBeenCalledWith(
|
|
238
|
-
`${mockOrgUrl}/${mockProject}/_api/_testManagement/GetTestSuitesForPlan?__v=5&planId=${mockPlanId}`,
|
|
264
|
+
`${mockOrgUrl.replace(/\/+$/, '')}/${mockProject}/_api/_testManagement/GetTestSuitesForPlan?__v=5&planId=${mockPlanId}`,
|
|
239
265
|
mockToken
|
|
240
266
|
);
|
|
241
267
|
expect(Helper.findSuitesRecursive).toHaveBeenCalledWith(
|
|
@@ -248,6 +274,26 @@ describe('TestDataProvider', () => {
|
|
|
248
274
|
);
|
|
249
275
|
expect(result).toEqual(mockSuiteData);
|
|
250
276
|
});
|
|
277
|
+
|
|
278
|
+
it('should use bearer suites payload when token is bearer', async () => {
|
|
279
|
+
const bearerProvider = new TestDataProvider(mockOrgUrl, mockBearerToken);
|
|
280
|
+
const mockTestSuites = {
|
|
281
|
+
value: [{ id: '123', name: 'Suite 1', parentSuite: { id: 0 } }],
|
|
282
|
+
};
|
|
283
|
+
const mockSuiteData = [new suiteData('Suite 1', '123', '456', 1)];
|
|
284
|
+
(TFSServices.getItemContent as jest.Mock).mockResolvedValueOnce(mockTestSuites);
|
|
285
|
+
(Helper.findSuitesRecursive as jest.Mock).mockReturnValueOnce(mockSuiteData);
|
|
286
|
+
|
|
287
|
+
const result = await bearerProvider.GetTestSuiteById(mockProject, mockPlanId, mockSuiteId, true);
|
|
288
|
+
|
|
289
|
+
expect(TFSServices.getItemContent).toHaveBeenCalledWith(
|
|
290
|
+
`${mockOrgUrl.replace(/\/+$/, '')}/${mockProject}/_apis/testplan/Plans/${mockPlanId}/suites?includeChildren=true&api-version=7.0`,
|
|
291
|
+
mockBearerToken
|
|
292
|
+
);
|
|
293
|
+
const suitesArg = (Helper.findSuitesRecursive as jest.Mock).mock.calls[0][3];
|
|
294
|
+
expect(suitesArg[0].title).toBe('Suite 1');
|
|
295
|
+
expect(result).toEqual(mockSuiteData);
|
|
296
|
+
});
|
|
251
297
|
});
|
|
252
298
|
|
|
253
299
|
describe('GetTestCases', () => {
|