@elisra-devops/docgen-data-provider 1.108.0 → 1.109.1

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.
@@ -93,6 +93,66 @@ describe('TicketsDataProvider', () => {
93
93
  });
94
94
  });
95
95
 
96
+ describe('fetchFlatUpstreamQueries', () => {
97
+ it('should allow only Requirement flat queries and exclude oneHop/tree query types', async () => {
98
+ const structureSpy = jest
99
+ .spyOn(ticketsDataProvider as any, 'structureFetchedQueries')
100
+ .mockResolvedValue({ tree1: { id: 't1' }, tree2: null });
101
+
102
+ await (ticketsDataProvider as any).fetchFlatUpstreamQueries({ hasChildren: false }, []);
103
+
104
+ expect(structureSpy.mock.calls[0][3]).toEqual(['requirement']);
105
+ expect(structureSpy.mock.calls[0][7]).toBe(false);
106
+ expect(structureSpy.mock.calls[0][9]).toBe(true);
107
+ expect(structureSpy.mock.calls[0][10]).toBe(false);
108
+ });
109
+
110
+ it('should allow Requirement flat queries for fallback discovery', async () => {
111
+ const structureSpy = jest
112
+ .spyOn(ticketsDataProvider as any, 'structureFetchedQueries')
113
+ .mockResolvedValue({ tree1: { id: 't1' }, tree2: null });
114
+
115
+ await (ticketsDataProvider as any).fetchFlatUpstreamQueries(
116
+ { hasChildren: false },
117
+ ['system to subsystem', 'system-to-subsystem', 'system subsystem'],
118
+ ['requirement'],
119
+ );
120
+
121
+ expect(structureSpy.mock.calls[0][3]).toEqual(['requirement']);
122
+ expect(structureSpy.mock.calls[0][8]).toEqual([
123
+ 'system to subsystem',
124
+ 'system-to-subsystem',
125
+ 'system subsystem',
126
+ ]);
127
+ expect(structureSpy.mock.calls[0][9]).toBe(true);
128
+ expect(structureSpy.mock.calls[0][10]).toBe(false);
129
+ });
130
+
131
+ it('should let structureFetchedQueries exclude oneHop leaves only for flat-only callers', async () => {
132
+ const result = await (ticketsDataProvider as any).structureFetchedQueries(
133
+ {
134
+ id: 'one-hop',
135
+ hasChildren: false,
136
+ isFolder: false,
137
+ queryType: 'oneHop',
138
+ wiql: "[Source].[System.WorkItemType] = 'Requirement'",
139
+ },
140
+ false,
141
+ null,
142
+ ['requirement'],
143
+ [],
144
+ undefined,
145
+ undefined,
146
+ false,
147
+ [],
148
+ true,
149
+ false,
150
+ );
151
+
152
+ expect(result).toEqual({ tree1: null, tree2: null });
153
+ });
154
+ });
155
+
96
156
  describe('fetchSysRsQueries', () => {
97
157
  it('should use sysrs root, exclude trace folders from system requirements and resolve both trace directions', async () => {
98
158
  const rootQueries = { id: 'root' };
@@ -106,6 +166,9 @@ describe('TicketsDataProvider', () => {
106
166
  const fetchSystemRequirementQueriesSpy = jest
107
167
  .spyOn(ticketsDataProvider as any, 'fetchSystemRequirementQueries')
108
168
  .mockResolvedValue({ systemRequirementsQueryTree: { id: 'system-tree' } });
169
+ const fetchFlatUpstreamQueriesSpy = jest
170
+ .spyOn(ticketsDataProvider as any, 'fetchFlatUpstreamQueries')
171
+ .mockResolvedValue({ systemRequirementsQueryTree: { id: 'customer-tree' } });
109
172
  const findChildFolderByPossibleNamesSpy = jest
110
173
  .spyOn(ticketsDataProvider as any, 'findChildFolderByPossibleNames')
111
174
  .mockResolvedValueOnce(subsystemToSystemFolder)
@@ -119,8 +182,14 @@ describe('TicketsDataProvider', () => {
119
182
 
120
183
  expect(getDocTypeRootSpy).toHaveBeenCalledWith(rootQueries, 'sysrs');
121
184
  expect(fetchSystemRequirementQueriesSpy).toHaveBeenCalledWith(sysRsRoot, [
122
- 'System To Customer',
123
- 'System To Subsystem',
185
+ 'system to customer',
186
+ 'system-to-customer',
187
+ 'system customer',
188
+ 'subsystem to system',
189
+ 'customer to system',
190
+ 'system to subsystem',
191
+ 'system-to-subsystem',
192
+ 'system subsystem',
124
193
  ]);
125
194
 
126
195
  expect(findChildFolderByPossibleNamesSpy).toHaveBeenNthCalledWith(
@@ -136,15 +205,17 @@ describe('TicketsDataProvider', () => {
136
205
 
137
206
  expect(fetchRequirementsTraceQueriesForFolderSpy).toHaveBeenNthCalledWith(1, subsystemToSystemFolder);
138
207
  expect(fetchRequirementsTraceQueriesForFolderSpy).toHaveBeenNthCalledWith(2, systemToSubsystemFolder);
208
+ expect(fetchFlatUpstreamQueriesSpy).toHaveBeenCalledWith(subsystemToSystemFolder, [], ['requirement']);
139
209
 
140
210
  expect(result).toEqual({
141
211
  systemRequirementsQueries: { systemRequirementsQueryTree: { id: 'system-tree' } },
212
+ customerRequirementsQueries: { systemRequirementsQueryTree: { id: 'customer-tree' } },
142
213
  subsystemToSystemRequirementsQueries: { id: 'fwd-trace-tree' },
143
214
  systemToSubsystemRequirementsQueries: { id: 'rev-trace-tree' },
144
215
  });
145
216
  });
146
217
 
147
- it('should fall back to root queries and return null trace trees when trace folders are missing', async () => {
218
+ it('should return null customer/trace trees when trace folders are missing (no sysRsRoot fallback scan)', async () => {
148
219
  const rootQueries = { id: 'root' };
149
220
 
150
221
  jest
@@ -153,6 +224,9 @@ describe('TicketsDataProvider', () => {
153
224
  const fetchSystemRequirementQueriesSpy = jest
154
225
  .spyOn(ticketsDataProvider as any, 'fetchSystemRequirementQueries')
155
226
  .mockResolvedValue({ systemRequirementsQueryTree: { id: 'system-tree' } });
227
+ const fetchFlatUpstreamQueriesSpy = jest
228
+ .spyOn(ticketsDataProvider as any, 'fetchFlatUpstreamQueries')
229
+ .mockResolvedValue({ systemRequirementsQueryTree: { id: 'should-not-be-used' } });
156
230
  jest
157
231
  .spyOn(ticketsDataProvider as any, 'findChildFolderByPossibleNames')
158
232
  .mockResolvedValueOnce(null)
@@ -165,13 +239,22 @@ describe('TicketsDataProvider', () => {
165
239
  const result = await (ticketsDataProvider as any).fetchSysRsQueries(rootQueries);
166
240
 
167
241
  expect(fetchSystemRequirementQueriesSpy).toHaveBeenCalledWith(rootQueries, [
168
- 'System To Customer',
169
- 'System To Subsystem',
242
+ 'system to customer',
243
+ 'system-to-customer',
244
+ 'system customer',
245
+ 'subsystem to system',
246
+ 'customer to system',
247
+ 'system to subsystem',
248
+ 'system-to-subsystem',
249
+ 'system subsystem',
170
250
  ]);
171
251
  expect(fetchRequirementsTraceQueriesForFolderSpy).toHaveBeenNthCalledWith(1, null);
172
252
  expect(fetchRequirementsTraceQueriesForFolderSpy).toHaveBeenNthCalledWith(2, null);
253
+ // No fallback scan of sysRsRoot when the System-to-Customer folder is absent.
254
+ expect(fetchFlatUpstreamQueriesSpy).not.toHaveBeenCalled();
173
255
  expect(result).toEqual({
174
256
  systemRequirementsQueries: { systemRequirementsQueryTree: { id: 'system-tree' } },
257
+ customerRequirementsQueries: null,
175
258
  subsystemToSystemRequirementsQueries: null,
176
259
  systemToSubsystemRequirementsQueries: null,
177
260
  });