Skip to content

Commit fc8e49a

Browse files
test: use real data
1 parent ac0290e commit fc8e49a

File tree

1 file changed

+333
-24
lines changed

1 file changed

+333
-24
lines changed

packages/sdk/tests/e2e/dataProtectorCore/getProtectedData.test.ts

Lines changed: 333 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -104,33 +104,342 @@ describe('dataProtectorCore.getProtectedData()', () => {
104104
},
105105
timeouts.protectData + timeouts.getProtectedData
106106
);
107-
});
108107

109-
describe('When calling getProtectedData for a ProtectedData that contains nested empty JSON objects', () => {
110-
it('should return the protectedData without the field corresponding to the nested empty JSON objects', async () => {
111-
// --- GIVEN
112-
const createdProtectedData = await dataProtectorCore.protectData({
113-
data: {
114-
115-
tag: { size: 10, emptyObject: {} },
116-
},
117-
name: 'test getProtectedData',
118-
});
119-
await waitForSubgraphIndexing();
108+
describe('When calling getProtectedData for a ProtectedData that contains nested JSON objects possibly empty', () => {
109+
it('should return the protectedData without the field corresponding to the nested empty JSON objects', async () => {
110+
// --- GIVEN
111+
const data = {
112+
n8nWorkflow: {
113+
credentials: {
114+
'0': {
115+
createdAt: 'string',
116+
updatedAt: 'string',
117+
id: 'string',
118+
name: 'string',
119+
data: {
120+
accessToken: 'string',
121+
},
122+
type: 'string',
123+
isManaged: false,
124+
},
125+
},
126+
workflows: {
127+
'0': {
128+
createdAt: 'string',
129+
updatedAt: 'string',
130+
id: 'string',
131+
name: 'string',
132+
active: false,
133+
isArchived: false,
134+
nodes: {
135+
'0': {
136+
parameters: {
137+
select: 'string',
138+
channelId: {
139+
__rl: false,
140+
value: 'string',
141+
mode: 'string',
142+
},
143+
text: 'string',
144+
otherOptions: {
145+
includeLinkToWorkflow: false,
146+
},
147+
},
148+
type: 'string',
149+
typeVersion: 1,
150+
position: {
151+
'0': 1,
152+
'1': 1,
153+
},
154+
id: 'string',
155+
name: 'string',
156+
webhookId: 'string',
157+
credentials: {
158+
slackApi: {
159+
id: 'string',
160+
name: 'string',
161+
},
162+
},
163+
},
164+
'1': {
165+
parameters: {
166+
operation: 'string',
167+
date: 'string',
168+
format: 'string',
169+
customFormat: 'string',
170+
options: {},
171+
},
172+
type: 'string',
173+
typeVersion: 1,
174+
position: {
175+
'0': 1,
176+
'1': 1,
177+
},
178+
id: 'string',
179+
name: 'string',
180+
},
181+
'2': {
182+
parameters: {
183+
rule: {
184+
interval: {
185+
'0': {
186+
field: 'string',
187+
minutesInterval: 1,
188+
},
189+
},
190+
},
191+
},
192+
type: 'string',
193+
typeVersion: 1,
194+
position: {
195+
'0': 1,
196+
'1': 1,
197+
},
198+
id: 'string',
199+
name: 'string',
200+
},
201+
'3': {
202+
parameters: {},
203+
type: 'string',
204+
typeVersion: 1,
205+
position: {
206+
'0': 1,
207+
'1': 1,
208+
},
209+
id: 'string',
210+
name: 'string',
211+
},
212+
},
213+
connections: {
214+
Date___Time: {
215+
main: {
216+
'0': {
217+
'0': {
218+
node: 'string',
219+
type: 'string',
220+
index: 1,
221+
},
222+
},
223+
},
224+
},
225+
Schedule_Trigger: {
226+
main: {
227+
'0': {
228+
'0': {
229+
node: 'string',
230+
type: 'string',
231+
index: 1,
232+
},
233+
},
234+
},
235+
},
236+
When_clicking__Execute_workflow_: {
237+
main: {
238+
'0': {
239+
'0': {
240+
node: 'string',
241+
type: 'string',
242+
index: 1,
243+
},
244+
},
245+
},
246+
},
247+
},
248+
settings: {
249+
executionOrder: 'string',
250+
timezone: 'string',
251+
callerPolicy: 'string',
252+
},
253+
staticData: {
254+
node_Schedule_Trigger: {
255+
recurrenceRules: {},
256+
},
257+
},
258+
meta: {
259+
templateCredsSetupCompleted: false,
260+
},
261+
pinData: {},
262+
versionId: 'string',
263+
triggerCount: 1,
264+
tags: {},
265+
},
266+
},
267+
},
268+
};
269+
const expectedSchema = {
270+
n8nWorkflow: {
271+
credentials: {
272+
'0': {
273+
createdAt: 'string',
274+
updatedAt: 'string',
275+
id: 'string',
276+
name: 'string',
277+
data: {
278+
accessToken: 'string',
279+
},
280+
type: 'string',
281+
isManaged: 'bool',
282+
},
283+
},
284+
workflows: {
285+
'0': {
286+
createdAt: 'string',
287+
updatedAt: 'string',
288+
id: 'string',
289+
name: 'string',
290+
active: 'bool',
291+
isArchived: 'bool',
292+
nodes: {
293+
'0': {
294+
parameters: {
295+
select: 'string',
296+
channelId: {
297+
__rl: 'bool',
298+
value: 'string',
299+
mode: 'string',
300+
},
301+
text: 'string',
302+
otherOptions: {
303+
includeLinkToWorkflow: 'bool',
304+
},
305+
},
306+
type: 'string',
307+
typeVersion: 'f64',
308+
position: {
309+
'0': 'f64',
310+
'1': 'f64',
311+
},
312+
id: 'string',
313+
name: 'string',
314+
webhookId: 'string',
315+
credentials: {
316+
slackApi: {
317+
id: 'string',
318+
name: 'string',
319+
},
320+
},
321+
},
322+
'1': {
323+
parameters: {
324+
operation: 'string',
325+
date: 'string',
326+
format: 'string',
327+
customFormat: 'string',
328+
// options: {}, // should be stripped
329+
},
330+
type: 'string',
331+
typeVersion: 'f64',
332+
position: {
333+
'0': 'f64',
334+
'1': 'f64',
335+
},
336+
id: 'string',
337+
name: 'string',
338+
},
339+
'2': {
340+
parameters: {
341+
rule: {
342+
interval: {
343+
'0': {
344+
field: 'string',
345+
minutesInterval: 'f64',
346+
},
347+
},
348+
},
349+
},
350+
type: 'string',
351+
typeVersion: 'f64',
352+
position: {
353+
'0': 'f64',
354+
'1': 'f64',
355+
},
356+
id: 'string',
357+
name: 'string',
358+
},
359+
'3': {
360+
// parameters: {}, // should be stripped
361+
type: 'string',
362+
typeVersion: 'f64',
363+
position: {
364+
'0': 'f64',
365+
'1': 'f64',
366+
},
367+
id: 'string',
368+
name: 'string',
369+
},
370+
},
371+
connections: {
372+
Date___Time: {
373+
main: {
374+
'0': {
375+
'0': {
376+
node: 'string',
377+
type: 'string',
378+
index: 'f64',
379+
},
380+
},
381+
},
382+
},
383+
Schedule_Trigger: {
384+
main: {
385+
'0': {
386+
'0': {
387+
node: 'string',
388+
type: 'string',
389+
index: 'f64',
390+
},
391+
},
392+
},
393+
},
394+
When_clicking__Execute_workflow_: {
395+
main: {
396+
'0': {
397+
'0': {
398+
node: 'string',
399+
type: 'string',
400+
index: 'f64',
401+
},
402+
},
403+
},
404+
},
405+
},
406+
settings: {
407+
executionOrder: 'string',
408+
timezone: 'string',
409+
callerPolicy: 'string',
410+
},
411+
// staticData: {
412+
// node_Schedule_Trigger: {
413+
// recurrenceRules: {}, // should be stripped
414+
// },
415+
// },
416+
meta: {
417+
templateCredsSetupCompleted: 'bool',
418+
},
419+
// pinData: {}, // should be stripped
420+
versionId: 'string',
421+
triggerCount: 'f64',
422+
// tags: {}, // should be stripped
423+
},
424+
},
425+
},
426+
};
120427

121-
// --- WHEN
122-
const result = await dataProtectorCore.getProtectedData({
123-
protectedDataAddress: createdProtectedData.address,
124-
});
428+
const createdProtectedData = await dataProtectorCore.protectData({
429+
data,
430+
name: 'test getProtectedData',
431+
});
432+
await waitForSubgraphIndexing();
125433

126-
// --- THEN
127-
expect(result.length).toEqual(1);
128-
expect(result[0].name).toEqual('test getProtectedData');
129-
expect(result[0].schema).toEqual({
130-
email: 'string',
131-
tag: {
132-
size: 'f64',
133-
},
434+
// --- WHEN
435+
const result = await dataProtectorCore.getProtectedData({
436+
protectedDataAddress: createdProtectedData.address,
437+
});
438+
439+
// --- THEN
440+
expect(result.length).toEqual(1);
441+
expect(result[0].name).toEqual('test getProtectedData');
442+
expect(result[0].schema).toStrictEqual(expectedSchema);
134443
});
135444
});
136445
});

0 commit comments

Comments
 (0)