@elisra-devops/docgen-data-provider 1.63.13 → 1.67.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/.github/workflows/ci.yml +26 -9
- package/.github/workflows/release.yml +9 -10
- package/bin/helpers/tfs.d.ts +3 -0
- package/bin/helpers/tfs.js +44 -7
- package/bin/helpers/tfs.js.map +1 -1
- package/bin/modules/GitDataProvider.d.ts +10 -0
- package/bin/modules/GitDataProvider.js +10 -0
- package/bin/modules/GitDataProvider.js.map +1 -1
- package/bin/modules/TestDataProvider.js +0 -1
- package/bin/modules/TestDataProvider.js.map +1 -1
- package/bin/modules/TicketsDataProvider.d.ts +63 -24
- package/bin/modules/TicketsDataProvider.js +216 -114
- package/bin/modules/TicketsDataProvider.js.map +1 -1
- package/bin/tests/helpers/helper.test.js +279 -0
- package/bin/tests/helpers/helper.test.js.map +1 -0
- package/bin/{helpers/test → tests/helpers}/tfs.test.js +312 -49
- package/bin/tests/helpers/tfs.test.js.map +1 -0
- package/bin/tests/index.test.js +25 -0
- package/bin/tests/index.test.js.map +1 -0
- package/bin/tests/models/tfs-data.test.js +160 -0
- package/bin/tests/models/tfs-data.test.js.map +1 -0
- package/bin/{modules/test → tests/modules}/JfrogDataProvider.test.js +9 -9
- package/bin/tests/modules/JfrogDataProvider.test.js.map +1 -0
- package/bin/tests/modules/ResultDataProvider.test.js +1942 -0
- package/bin/tests/modules/ResultDataProvider.test.js.map +1 -0
- package/bin/tests/modules/gitDataProvider.test.js +1888 -0
- package/bin/tests/modules/gitDataProvider.test.js.map +1 -0
- package/bin/{modules/test → tests/modules}/managmentDataProvider.test.js +13 -1
- package/bin/tests/modules/managmentDataProvider.test.js.map +1 -0
- package/bin/tests/modules/pipelineDataProvider.test.d.ts +1 -0
- package/bin/tests/modules/pipelineDataProvider.test.js +783 -0
- package/bin/tests/modules/pipelineDataProvider.test.js.map +1 -0
- package/bin/tests/modules/testDataProvider.test.d.ts +1 -0
- package/bin/tests/modules/testDataProvider.test.js +717 -0
- package/bin/tests/modules/testDataProvider.test.js.map +1 -0
- package/bin/tests/modules/ticketsDataProvider.test.d.ts +1 -0
- package/bin/tests/modules/ticketsDataProvider.test.js +1681 -0
- package/bin/tests/modules/ticketsDataProvider.test.js.map +1 -0
- package/bin/tests/utils/DataProviderUtils.test.d.ts +1 -0
- package/bin/tests/utils/DataProviderUtils.test.js +61 -0
- package/bin/tests/utils/DataProviderUtils.test.js.map +1 -0
- package/bin/tests/utils/testStepParserHelper.test.d.ts +1 -0
- package/bin/tests/utils/testStepParserHelper.test.js +359 -0
- package/bin/tests/utils/testStepParserHelper.test.js.map +1 -0
- package/package.json +9 -1
- package/src/helpers/tfs.ts +51 -7
- package/src/modules/GitDataProvider.ts +10 -0
- package/src/modules/TestDataProvider.ts +0 -1
- package/src/modules/TicketsDataProvider.ts +298 -141
- package/src/tests/helpers/helper.test.ts +337 -0
- package/src/tests/helpers/tfs.test.ts +1092 -0
- package/src/tests/index.test.ts +28 -0
- package/src/tests/models/tfs-data.test.ts +203 -0
- package/src/tests/modules/JfrogDataProvider.test.ts +167 -0
- package/src/tests/modules/ResultDataProvider.test.ts +2571 -0
- package/src/tests/modules/gitDataProvider.test.ts +2628 -0
- package/src/{modules/test → tests/modules}/managmentDataProvider.test.ts +33 -1
- package/src/tests/modules/pipelineDataProvider.test.ts +1038 -0
- package/src/tests/modules/testDataProvider.test.ts +1046 -0
- package/src/tests/modules/ticketsDataProvider.test.ts +2204 -0
- package/src/tests/utils/DataProviderUtils.test.ts +76 -0
- package/src/tests/utils/testStepParserHelper.test.ts +437 -0
- package/tsconfig.json +1 -0
- package/bin/helpers/test/tfs.test.js.map +0 -1
- package/bin/modules/test/JfrogDataProvider.test.js.map +0 -1
- package/bin/modules/test/ResultDataProvider.test.js +0 -444
- package/bin/modules/test/ResultDataProvider.test.js.map +0 -1
- package/bin/modules/test/gitDataProvider.test.js +0 -428
- package/bin/modules/test/gitDataProvider.test.js.map +0 -1
- package/bin/modules/test/managmentDataProvider.test.js.map +0 -1
- package/bin/modules/test/pipelineDataProvider.test.js +0 -237
- package/bin/modules/test/pipelineDataProvider.test.js.map +0 -1
- package/bin/modules/test/testDataProvider.test.js +0 -234
- package/bin/modules/test/testDataProvider.test.js.map +0 -1
- package/bin/modules/test/ticketsDataProvider.test.js +0 -348
- package/bin/modules/test/ticketsDataProvider.test.js.map +0 -1
- package/src/helpers/test/tfs.test.ts +0 -748
- package/src/modules/test/JfrogDataProvider.test.ts +0 -171
- package/src/modules/test/ResultDataProvider.test.ts +0 -542
- package/src/modules/test/gitDataProvider.test.ts +0 -645
- package/src/modules/test/pipelineDataProvider.test.ts +0 -292
- package/src/modules/test/testDataProvider.test.ts +0 -318
- package/src/modules/test/ticketsDataProvider.test.ts +0 -462
- /package/bin/{helpers/test/tfs.test.d.ts → tests/helpers/helper.test.d.ts} +0 -0
- /package/bin/{modules/test/JfrogDataProvider.test.d.ts → tests/helpers/tfs.test.d.ts} +0 -0
- /package/bin/{modules/test/ResultDataProvider.test.d.ts → tests/index.test.d.ts} +0 -0
- /package/bin/{modules/test/gitDataProvider.test.d.ts → tests/models/tfs-data.test.d.ts} +0 -0
- /package/bin/{modules/test/managmentDataProvider.test.d.ts → tests/modules/JfrogDataProvider.test.d.ts} +0 -0
- /package/bin/{modules/test/pipelineDataProvider.test.d.ts → tests/modules/ResultDataProvider.test.d.ts} +0 -0
- /package/bin/{modules/test/testDataProvider.test.d.ts → tests/modules/gitDataProvider.test.d.ts} +0 -0
- /package/bin/{modules/test/ticketsDataProvider.test.d.ts → tests/modules/managmentDataProvider.test.d.ts} +0 -0
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { TFSServices } from '../../helpers/tfs';
|
|
2
|
-
import logger from '../../utils/logger';
|
|
3
|
-
import JfrogDataProvider from '../JfrogDataProvider';
|
|
4
|
-
|
|
5
|
-
jest.mock('../../helpers/tfs');
|
|
6
|
-
jest.mock('../../utils/logger');
|
|
7
|
-
|
|
8
|
-
describe('JfrogDataProvider', () => {
|
|
9
|
-
let jfrogDataProvider: JfrogDataProvider;
|
|
10
|
-
const mockOrgUrl = 'https://dev.azure.com/organization/';
|
|
11
|
-
const mockTfsToken = 'mock-tfs-token';
|
|
12
|
-
const mockJfrogToken = 'mock-jfrog-token';
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
jest.clearAllMocks();
|
|
16
|
-
jfrogDataProvider = new JfrogDataProvider(mockOrgUrl, mockTfsToken, mockJfrogToken);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('getServiceConnectionUrlByConnectionId', () => {
|
|
20
|
-
it('should fetch service connection URL with correct parameters', async () => {
|
|
21
|
-
// Arrange
|
|
22
|
-
const mockTeamProject = 'test-project';
|
|
23
|
-
const mockConnectionId = 'connection-123';
|
|
24
|
-
const mockResponse = { url: 'https://jfrog.example.com' };
|
|
25
|
-
|
|
26
|
-
(TFSServices.getItemContent as jest.Mock).mockResolvedValueOnce(mockResponse);
|
|
27
|
-
|
|
28
|
-
// Act
|
|
29
|
-
const result = await jfrogDataProvider.getServiceConnectionUrlByConnectionId(
|
|
30
|
-
mockTeamProject,
|
|
31
|
-
mockConnectionId
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
// Assert
|
|
35
|
-
expect(TFSServices.getItemContent).toHaveBeenCalledWith(
|
|
36
|
-
`${mockOrgUrl}${mockTeamProject}/_apis/serviceendpoint/endpoints/${mockConnectionId}?api-version=6`,
|
|
37
|
-
mockTfsToken
|
|
38
|
-
);
|
|
39
|
-
expect(logger.debug).toHaveBeenCalledWith(
|
|
40
|
-
`service connection url "${mockResponse.url}"`
|
|
41
|
-
);
|
|
42
|
-
expect(result).toBe(mockResponse.url);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should propagate errors when API call fails', async () => {
|
|
46
|
-
// Arrange
|
|
47
|
-
const mockTeamProject = 'test-project';
|
|
48
|
-
const mockConnectionId = 'connection-123';
|
|
49
|
-
const mockError = new Error('API error');
|
|
50
|
-
|
|
51
|
-
(TFSServices.getItemContent as jest.Mock).mockRejectedValueOnce(mockError);
|
|
52
|
-
|
|
53
|
-
// Act & Assert
|
|
54
|
-
await expect(
|
|
55
|
-
jfrogDataProvider.getServiceConnectionUrlByConnectionId(mockTeamProject, mockConnectionId)
|
|
56
|
-
).rejects.toThrow('API error');
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe('getCiDataFromJfrog', () => {
|
|
61
|
-
it('should fetch JFrog data with token and format URLs correctly', async () => {
|
|
62
|
-
// Arrange
|
|
63
|
-
const mockJfrogUrl = 'https://jfrog.example.com';
|
|
64
|
-
const mockBuildName = 'build-name';
|
|
65
|
-
const mockBuildVersion = 'version-1.0';
|
|
66
|
-
const mockResponse = {
|
|
67
|
-
buildInfo: {
|
|
68
|
-
url: 'https://ci.example.com/build/123'
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
(TFSServices.getJfrogRequest as jest.Mock).mockResolvedValueOnce(mockResponse);
|
|
73
|
-
|
|
74
|
-
// Act
|
|
75
|
-
const result = await jfrogDataProvider.getCiDataFromJfrog(
|
|
76
|
-
mockJfrogUrl,
|
|
77
|
-
mockBuildName,
|
|
78
|
-
mockBuildVersion
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
// Assert
|
|
82
|
-
expect(TFSServices.getJfrogRequest).toHaveBeenCalledWith(
|
|
83
|
-
`${mockJfrogUrl}/api/build/${mockBuildName}/${mockBuildVersion}`,
|
|
84
|
-
{ 'Authorization': `Bearer ${mockJfrogToken}` }
|
|
85
|
-
);
|
|
86
|
-
expect(logger.info).toHaveBeenCalledWith(
|
|
87
|
-
`Querying Jfrog using url ${mockJfrogUrl}/api/build/${mockBuildName}/${mockBuildVersion}`
|
|
88
|
-
);
|
|
89
|
-
expect(logger.debug).toHaveBeenCalledWith(
|
|
90
|
-
`CI Url from JFROG: ${mockResponse.buildInfo.url}`
|
|
91
|
-
);
|
|
92
|
-
expect(result).toBe(mockResponse.buildInfo.url);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should handle build names and versions that already start with /', async () => {
|
|
96
|
-
// Arrange
|
|
97
|
-
const mockJfrogUrl = 'https://jfrog.example.com';
|
|
98
|
-
const mockBuildName = '/build-name';
|
|
99
|
-
const mockBuildVersion = '/version-1.0';
|
|
100
|
-
const mockResponse = {
|
|
101
|
-
buildInfo: {
|
|
102
|
-
url: 'https://ci.example.com/build/123'
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
(TFSServices.getJfrogRequest as jest.Mock).mockResolvedValueOnce(mockResponse);
|
|
107
|
-
|
|
108
|
-
// Act
|
|
109
|
-
const result = await jfrogDataProvider.getCiDataFromJfrog(
|
|
110
|
-
mockJfrogUrl,
|
|
111
|
-
mockBuildName,
|
|
112
|
-
mockBuildVersion
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
// Assert
|
|
116
|
-
expect(TFSServices.getJfrogRequest).toHaveBeenCalledWith(
|
|
117
|
-
`${mockJfrogUrl}/api/build${mockBuildName}${mockBuildVersion}`,
|
|
118
|
-
{ 'Authorization': `Bearer ${mockJfrogToken}` }
|
|
119
|
-
);
|
|
120
|
-
expect(result).toBe(mockResponse.buildInfo.url);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('should make request without token when jfrogToken is empty', async () => {
|
|
124
|
-
// Arrange
|
|
125
|
-
const mockJfrogUrl = 'https://jfrog.example.com';
|
|
126
|
-
const mockBuildName = 'build-name';
|
|
127
|
-
const mockBuildVersion = 'version-1.0';
|
|
128
|
-
const mockResponse = {
|
|
129
|
-
buildInfo: {
|
|
130
|
-
url: 'https://ci.example.com/build/123'
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
// Create provider with empty jfrog token
|
|
135
|
-
const jfrogDataProviderNoToken = new JfrogDataProvider(mockOrgUrl, mockTfsToken, '');
|
|
136
|
-
(TFSServices.getJfrogRequest as jest.Mock).mockResolvedValueOnce(mockResponse);
|
|
137
|
-
|
|
138
|
-
// Act
|
|
139
|
-
const result = await jfrogDataProviderNoToken.getCiDataFromJfrog(
|
|
140
|
-
mockJfrogUrl,
|
|
141
|
-
mockBuildName,
|
|
142
|
-
mockBuildVersion
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
// Assert
|
|
146
|
-
expect(TFSServices.getJfrogRequest).toHaveBeenCalledWith(
|
|
147
|
-
`${mockJfrogUrl}/api/build/${mockBuildName}/${mockBuildVersion}`
|
|
148
|
-
);
|
|
149
|
-
expect(result).toBe(mockResponse.buildInfo.url);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('should log and rethrow errors from JFrog API', async () => {
|
|
153
|
-
// Arrange
|
|
154
|
-
const mockJfrogUrl = 'https://jfrog.example.com';
|
|
155
|
-
const mockBuildName = 'build-name';
|
|
156
|
-
const mockBuildVersion = 'version-1.0';
|
|
157
|
-
const mockError = new Error('JFrog API error');
|
|
158
|
-
|
|
159
|
-
(TFSServices.getJfrogRequest as jest.Mock).mockRejectedValueOnce(mockError);
|
|
160
|
-
|
|
161
|
-
// Act & Assert
|
|
162
|
-
await expect(
|
|
163
|
-
jfrogDataProvider.getCiDataFromJfrog(mockJfrogUrl, mockBuildName, mockBuildVersion)
|
|
164
|
-
).rejects.toThrow('JFrog API error');
|
|
165
|
-
|
|
166
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
167
|
-
`Error occurred during querying JFrog using: JFrog API error`
|
|
168
|
-
);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
});
|