@elisra-devops/docgen-data-provider 1.103.0 → 1.105.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/helper.d.ts +2 -1
- package/bin/helpers/helper.js +5 -4
- package/bin/helpers/helper.js.map +1 -1
- package/bin/models/tfs-data.d.ts +1 -0
- package/bin/models/tfs-data.js.map +1 -1
- package/bin/modules/ResultDataProvider.d.ts +1 -0
- package/bin/modules/ResultDataProvider.js +63 -1
- package/bin/modules/ResultDataProvider.js.map +1 -1
- package/bin/modules/TestDataProvider.d.ts +4 -0
- package/bin/modules/TestDataProvider.js +99 -14
- package/bin/modules/TestDataProvider.js.map +1 -1
- package/bin/modules/TicketsDataProvider.js +14 -3
- package/bin/modules/TicketsDataProvider.js.map +1 -1
- package/bin/tests/helpers/helper.test.js +2 -1
- package/bin/tests/helpers/helper.test.js.map +1 -1
- package/bin/tests/modules/ResultDataProvider.test.js +75 -0
- package/bin/tests/modules/ResultDataProvider.test.js.map +1 -1
- package/bin/tests/modules/testDataProvider.test.js +162 -9
- package/bin/tests/modules/testDataProvider.test.js.map +1 -1
- package/bin/tests/modules/ticketsDataProvider.test.js +66 -0
- package/bin/tests/modules/ticketsDataProvider.test.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/helper.ts +19 -4
- package/src/models/tfs-data.ts +1 -0
- package/src/modules/ResultDataProvider.ts +87 -1
- package/src/modules/TestDataProvider.ts +130 -22
- package/src/modules/TicketsDataProvider.ts +18 -5
- package/src/tests/helpers/helper.test.ts +2 -1
- package/src/tests/modules/ResultDataProvider.test.ts +94 -0
- package/src/tests/modules/testDataProvider.test.ts +225 -9
- package/src/tests/modules/ticketsDataProvider.test.ts +75 -0
|
@@ -1848,6 +1848,81 @@ describe('TicketsDataProvider', () => {
|
|
|
1848
1848
|
});
|
|
1849
1849
|
|
|
1850
1850
|
describe('GetSharedQueries - docType branches', () => {
|
|
1851
|
+
it('should handle STP docType', async () => {
|
|
1852
|
+
// Arrange
|
|
1853
|
+
const mockQueries = {
|
|
1854
|
+
children: [{ name: 'STP', isFolder: true, children: [] }],
|
|
1855
|
+
};
|
|
1856
|
+
(TFSServices.getItemContent as jest.Mock).mockResolvedValue(mockQueries);
|
|
1857
|
+
|
|
1858
|
+
// Act
|
|
1859
|
+
const result = await ticketsDataProvider.GetSharedQueries(mockProject, '', 'stp');
|
|
1860
|
+
|
|
1861
|
+
// Assert
|
|
1862
|
+
expect(result).toBeDefined();
|
|
1863
|
+
});
|
|
1864
|
+
|
|
1865
|
+
it('should fallback to STD root when STP root is missing', async () => {
|
|
1866
|
+
const rootQueries = { id: 'root', children: [] };
|
|
1867
|
+
const stdRoot = { id: 'std-root', children: [] };
|
|
1868
|
+
(TFSServices.getItemContent as jest.Mock).mockResolvedValue(rootQueries);
|
|
1869
|
+
|
|
1870
|
+
const getDocTypeRootSpy = jest
|
|
1871
|
+
.spyOn(ticketsDataProvider as any, 'getDocTypeRoot')
|
|
1872
|
+
.mockImplementation(async (...args: any[]) => {
|
|
1873
|
+
const docTypeName = String(args[1] || '');
|
|
1874
|
+
if (docTypeName === 'stp') return { root: rootQueries, found: false };
|
|
1875
|
+
if (docTypeName === 'std') return { root: stdRoot, found: true };
|
|
1876
|
+
return { root: rootQueries, found: false };
|
|
1877
|
+
});
|
|
1878
|
+
|
|
1879
|
+
const fetchDocTypeBranchesSpy = jest
|
|
1880
|
+
.spyOn(ticketsDataProvider as any, 'fetchDocTypeBranches')
|
|
1881
|
+
.mockResolvedValue({
|
|
1882
|
+
reqToTest: { result: { reqTestTree: { id: 'req-tree' }, testReqTree: { id: 'fallback-tree' } } },
|
|
1883
|
+
testToReq: { result: { testReqTree: { id: 'test-tree' } } },
|
|
1884
|
+
mom: { result: { linkedMomTree: { id: 'mom-tree' } } },
|
|
1885
|
+
});
|
|
1886
|
+
|
|
1887
|
+
const result = await ticketsDataProvider.GetSharedQueries(mockProject, '', 'stp');
|
|
1888
|
+
|
|
1889
|
+
expect(getDocTypeRootSpy).toHaveBeenNthCalledWith(1, rootQueries, 'stp');
|
|
1890
|
+
expect(getDocTypeRootSpy).toHaveBeenNthCalledWith(2, rootQueries, 'std');
|
|
1891
|
+
expect(fetchDocTypeBranchesSpy).toHaveBeenCalledWith(rootQueries, stdRoot, expect.any(Array));
|
|
1892
|
+
expect(result.reqTestQueries.reqTestTree).toEqual({ id: 'req-tree' });
|
|
1893
|
+
expect(result.reqTestQueries.testReqTree).toEqual({ id: 'test-tree' });
|
|
1894
|
+
expect(result.linkedMomQueries.linkedMomTree).toEqual({ id: 'mom-tree' });
|
|
1895
|
+
});
|
|
1896
|
+
|
|
1897
|
+
it('should prefer STP root over STD when both exist', async () => {
|
|
1898
|
+
const rootQueries = { id: 'root', children: [] };
|
|
1899
|
+
const stpRoot = { id: 'stp-root', children: [] };
|
|
1900
|
+
(TFSServices.getItemContent as jest.Mock).mockResolvedValue(rootQueries);
|
|
1901
|
+
|
|
1902
|
+
const getDocTypeRootSpy = jest
|
|
1903
|
+
.spyOn(ticketsDataProvider as any, 'getDocTypeRoot')
|
|
1904
|
+
.mockImplementation(async (...args: any[]) => {
|
|
1905
|
+
const docTypeName = String(args[1] || '');
|
|
1906
|
+
if (docTypeName === 'stp') return { root: stpRoot, found: true };
|
|
1907
|
+
if (docTypeName === 'std') return { root: { id: 'std-root', children: [] }, found: true };
|
|
1908
|
+
return { root: rootQueries, found: false };
|
|
1909
|
+
});
|
|
1910
|
+
|
|
1911
|
+
const fetchDocTypeBranchesSpy = jest
|
|
1912
|
+
.spyOn(ticketsDataProvider as any, 'fetchDocTypeBranches')
|
|
1913
|
+
.mockResolvedValue({
|
|
1914
|
+
reqToTest: { result: { reqTestTree: { id: 'req-tree' }, testReqTree: null } },
|
|
1915
|
+
testToReq: { result: { testReqTree: { id: 'test-tree' } } },
|
|
1916
|
+
mom: { result: { linkedMomTree: null } },
|
|
1917
|
+
});
|
|
1918
|
+
|
|
1919
|
+
await ticketsDataProvider.GetSharedQueries(mockProject, '', 'stp');
|
|
1920
|
+
|
|
1921
|
+
expect(getDocTypeRootSpy).toHaveBeenCalledTimes(1);
|
|
1922
|
+
expect(getDocTypeRootSpy).toHaveBeenCalledWith(rootQueries, 'stp');
|
|
1923
|
+
expect(fetchDocTypeBranchesSpy).toHaveBeenCalledWith(rootQueries, stpRoot, expect.any(Array));
|
|
1924
|
+
});
|
|
1925
|
+
|
|
1851
1926
|
it('should handle STR docType', async () => {
|
|
1852
1927
|
// Arrange
|
|
1853
1928
|
const mockQueries = {
|