testeranto.tiposkripto 0.2.16 → 0.2.18

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.
@@ -75,9 +75,15 @@ var BaseSetup = class {
75
75
  try {
76
76
  for (const [actionNdx, actionStep] of (this.actions || []).entries()) {
77
77
  try {
78
+ const actionArtifactory = this.createArtifactoryForAction(
79
+ key,
80
+ actionNdx,
81
+ suiteNdx
82
+ );
78
83
  this.store = await actionStep.test(
79
84
  this.store,
80
- testResourceConfiguration
85
+ testResourceConfiguration,
86
+ actionArtifactory
81
87
  );
82
88
  } catch (e) {
83
89
  this.failed = true;
@@ -88,10 +94,16 @@ var BaseSetup = class {
88
94
  for (const [checkNdx, checkStep] of this.checks.entries()) {
89
95
  try {
90
96
  const filepath = suiteNdx !== void 0 ? `suite-${suiteNdx}/setup-${key}/check-${checkNdx}` : `setup-${key}/check-${checkNdx}`;
97
+ const checkArtifactory = this.createArtifactoryForCheck(
98
+ key,
99
+ checkNdx,
100
+ suiteNdx
101
+ );
91
102
  const t = await checkStep.test(
92
103
  this.store,
93
104
  testResourceConfiguration,
94
- filepath
105
+ filepath,
106
+ checkArtifactory
95
107
  );
96
108
  tester(t);
97
109
  } catch (e) {
@@ -115,6 +127,56 @@ var BaseSetup = class {
115
127
  }
116
128
  return this.store;
117
129
  }
130
+ createArtifactoryForAction(key, actionIndex, suiteNdx) {
131
+ const self = this;
132
+ if (self._parent && self._parent.createArtifactory) {
133
+ return self._parent.createArtifactory({
134
+ givenKey: key,
135
+ whenIndex: actionIndex,
136
+ suiteIndex: suiteNdx
137
+ });
138
+ }
139
+ return {
140
+ writeFileSync: (filename, payload) => {
141
+ let path2 = "";
142
+ if (suiteNdx !== void 0) {
143
+ path2 += `suite-${suiteNdx}/`;
144
+ }
145
+ path2 += `setup-${key}/`;
146
+ path2 += `action-${actionIndex} ${filename}`;
147
+ console.log(`[Artifactory] Would write to: ${path2}`);
148
+ console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
149
+ },
150
+ screenshot: (filename, payload) => {
151
+ console.log(`[Artifactory] Would take screenshot: ${filename}`);
152
+ }
153
+ };
154
+ }
155
+ createArtifactoryForCheck(key, checkIndex, suiteNdx) {
156
+ const self = this;
157
+ if (self._parent && self._parent.createArtifactory) {
158
+ return self._parent.createArtifactory({
159
+ givenKey: key,
160
+ thenIndex: checkIndex,
161
+ suiteIndex: suiteNdx
162
+ });
163
+ }
164
+ return {
165
+ writeFileSync: (filename, payload) => {
166
+ let path2 = "";
167
+ if (suiteNdx !== void 0) {
168
+ path2 += `suite-${suiteNdx}/`;
169
+ }
170
+ path2 += `setup-${key}/`;
171
+ path2 += `check-${checkIndex} ${filename}`;
172
+ console.log(`[Artifactory] Would write to: ${path2}`);
173
+ console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
174
+ },
175
+ screenshot: (filename, payload) => {
176
+ console.log(`[Artifactory] Would take screenshot: ${filename}`);
177
+ }
178
+ };
179
+ }
118
180
  };
119
181
 
120
182
  // src/BaseAction.ts
@@ -146,12 +208,13 @@ ${this.error.stack}` : null,
146
208
  };
147
209
  return obj;
148
210
  }
149
- async test(store, testResourceConfiguration) {
211
+ async test(store, testResourceConfiguration, artifactory) {
150
212
  try {
151
213
  const result = await this.performAction(
152
214
  store,
153
215
  this.actionCB,
154
- testResourceConfiguration
216
+ testResourceConfiguration,
217
+ artifactory
155
218
  );
156
219
  this.status = true;
157
220
  return result;
@@ -192,7 +255,7 @@ var BaseCheck = class {
192
255
  };
193
256
  return obj;
194
257
  }
195
- async test(store, testResourceConfiguration, filepath) {
258
+ async test(store, testResourceConfiguration, filepath, artifactory) {
196
259
  const addArtifact = this.addArtifact.bind(this);
197
260
  try {
198
261
  const x = await this.verifyCheck(
@@ -210,7 +273,8 @@ var BaseCheck = class {
210
273
  throw e;
211
274
  }
212
275
  },
213
- testResourceConfiguration
276
+ testResourceConfiguration,
277
+ artifactory
214
278
  );
215
279
  this.status = true;
216
280
  return x;
@@ -229,6 +293,7 @@ var BaseGiven = class extends BaseSetup {
229
293
  this.artifacts = [];
230
294
  this.fails = 0;
231
295
  this._parent = null;
296
+ console.log(`[BaseGiven.constructor] _parent initialized to null`);
232
297
  }
233
298
  addArtifact(path2) {
234
299
  if (typeof path2 !== "string") {
@@ -241,6 +306,16 @@ var BaseGiven = class extends BaseSetup {
241
306
  const normalizedPath = path2.replace(/\\/g, "/");
242
307
  this.artifacts.push(normalizedPath);
243
308
  }
309
+ // Set the parent explicitly
310
+ setParent(parent) {
311
+ this._parent = parent;
312
+ console.log(`[BaseGiven.setParent] _parent set to:`, parent);
313
+ }
314
+ // Set the parent explicitly
315
+ setParent(parent) {
316
+ this._parent = parent;
317
+ console.log(`[BaseGiven.setParent] _parent set to:`, parent);
318
+ }
244
319
  beforeAll(store) {
245
320
  return store;
246
321
  }
@@ -352,11 +427,22 @@ var BaseGiven = class extends BaseSetup {
352
427
  }
353
428
  createDefaultArtifactory(givenKey, suiteNdx) {
354
429
  const self = this;
430
+ console.log(`[BaseGiven.createDefaultArtifactory] self._parent:`, self._parent);
431
+ console.log(`[BaseGiven.createDefaultArtifactory] self._parent.createArtifactory:`, self._parent?.createArtifactory);
355
432
  if (self._parent && self._parent.createArtifactory) {
356
- return self._parent.createArtifactory({
433
+ const artifactory = self._parent.createArtifactory({
357
434
  givenKey,
358
435
  suiteIndex: suiteNdx
359
436
  });
437
+ console.log(`[BaseGiven.createDefaultArtifactory] Created artifactory from parent:`, artifactory);
438
+ return artifactory;
439
+ }
440
+ let basePath = "testeranto";
441
+ if (self._parent && self._parent.testResourceConfiguration?.fs) {
442
+ basePath = self._parent.testResourceConfiguration.fs;
443
+ console.log(`[BaseGiven.createDefaultArtifactory] Using base path from parent: ${basePath}`);
444
+ } else {
445
+ console.log(`[BaseGiven.createDefaultArtifactory] Using default base path: ${basePath}`);
360
446
  }
361
447
  return {
362
448
  writeFileSync: (filename, payload) => {
@@ -366,23 +452,50 @@ var BaseGiven = class extends BaseSetup {
366
452
  }
367
453
  path2 += `given-${givenKey}/`;
368
454
  path2 += filename;
369
- console.log(`[Artifactory] Would write to: ${path2}`);
370
- console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
455
+ if (!path2.match(/\.[a-zA-Z0-9]+$/)) {
456
+ path2 += ".txt";
457
+ }
458
+ const fullPath = `${basePath}/${path2}`;
459
+ console.log(`[Artifactory] Writing to: ${fullPath}`);
460
+ if (self._parent && typeof self._parent.writeFileSync === "function") {
461
+ self._parent.writeFileSync(fullPath, payload);
462
+ } else {
463
+ console.log(`[Artifactory] Would write to: ${fullPath}`);
464
+ console.log(`[Artifactory] Content: ${payload.substring(0, 100)}...`);
465
+ }
371
466
  },
372
467
  screenshot: (filename, payload) => {
373
- console.log(`[Artifactory] Would take screenshot: ${filename}`);
468
+ let path2 = "";
469
+ if (suiteNdx !== void 0) {
470
+ path2 += `suite-${suiteNdx}/`;
471
+ }
472
+ path2 += `given-${givenKey}/`;
473
+ path2 += filename;
474
+ if (!path2.match(/\.[a-zA-Z0-9]+$/)) {
475
+ path2 += ".png";
476
+ }
477
+ const fullPath = `${basePath}/${path2}`;
478
+ console.log(`[Artifactory] Would take screenshot: ${fullPath}`);
479
+ if (self._parent && typeof self._parent.screenshot === "function") {
480
+ self._parent.screenshot(fullPath, payload || "");
481
+ }
374
482
  }
375
483
  };
376
484
  }
377
485
  createArtifactoryForWhen(givenKey, whenIndex, suiteNdx) {
378
486
  const self = this;
487
+ console.log(`[BaseGiven.createArtifactoryForWhen] self._parent:`, self._parent);
488
+ console.log(`[BaseGiven.createArtifactoryForWhen] self._parent.createArtifactory:`, self._parent?.createArtifactory);
379
489
  if (self._parent && self._parent.createArtifactory) {
380
- return self._parent.createArtifactory({
490
+ const artifactory = self._parent.createArtifactory({
381
491
  givenKey,
382
492
  whenIndex,
383
493
  suiteIndex: suiteNdx
384
494
  });
495
+ console.log(`[BaseGiven.createArtifactoryForWhen] Created artifactory:`, artifactory);
496
+ return artifactory;
385
497
  }
498
+ console.log(`[BaseGiven.createArtifactoryForWhen] Using fallback artifactory`);
386
499
  return {
387
500
  writeFileSync: (filename, payload) => {
388
501
  let path2 = "";
@@ -401,13 +514,18 @@ var BaseGiven = class extends BaseSetup {
401
514
  }
402
515
  createArtifactoryForThen(givenKey, thenIndex, suiteNdx) {
403
516
  const self = this;
517
+ console.log(`[BaseGiven.createArtifactoryForThen] self._parent:`, self._parent);
518
+ console.log(`[BaseGiven.createArtifactoryForThen] self._parent.createArtifactory:`, self._parent?.createArtifactory);
404
519
  if (self._parent && self._parent.createArtifactory) {
405
- return self._parent.createArtifactory({
520
+ const artifactory = self._parent.createArtifactory({
406
521
  givenKey,
407
522
  thenIndex,
408
523
  suiteIndex: suiteNdx
409
524
  });
525
+ console.log(`[BaseGiven.createArtifactoryForThen] Created artifactory:`, artifactory);
526
+ return artifactory;
410
527
  }
528
+ console.log(`[BaseGiven.createArtifactoryForThen] Using fallback artifactory`);
411
529
  return {
412
530
  writeFileSync: (filename, payload) => {
413
531
  let path2 = "";
@@ -677,17 +795,53 @@ var BaseSuite = class {
677
795
  async run(input, testResourceConfiguration) {
678
796
  this.testResourceConfiguration = testResourceConfiguration;
679
797
  const sNdx = this.index;
680
- const subject = await this.setup(input, null, testResourceConfiguration);
798
+ let suiteArtifactory;
799
+ if (this.parent && this.parent.createArtifactory) {
800
+ suiteArtifactory = this.parent.createArtifactory({
801
+ suiteIndex: sNdx
802
+ });
803
+ } else {
804
+ const basePath = this.testResourceConfiguration?.fs || "testeranto";
805
+ suiteArtifactory = {
806
+ writeFileSync: (filename, payload) => {
807
+ console.log(
808
+ `[BaseSuite] Would write to ${basePath}/suite-${sNdx}/${filename}: ${payload.substring(0, 100)}...`
809
+ );
810
+ },
811
+ screenshot: (filename, payload) => {
812
+ console.log(`[BaseSuite] Would take screenshot: ${filename}`);
813
+ }
814
+ };
815
+ }
816
+ const subject = await this.setup(input, suiteArtifactory, testResourceConfiguration);
681
817
  for (const [gKey, g] of Object.entries(this.givens)) {
682
818
  const giver = this.givens[gKey];
683
819
  try {
820
+ let givenArtifactory;
821
+ if (this.parent && this.parent.createArtifactory) {
822
+ givenArtifactory = this.parent.createArtifactory({
823
+ givenKey: gKey,
824
+ suiteIndex: sNdx
825
+ });
826
+ } else {
827
+ const basePath = this.testResourceConfiguration?.fs || "testeranto";
828
+ givenArtifactory = {
829
+ writeFileSync: (filename, payload) => {
830
+ const path2 = `suite-${sNdx}/given-${gKey}/${filename}`;
831
+ const fullPath = `${basePath}/${path2}`;
832
+ console.log(`[BaseSuite] Would write to ${fullPath}: ${payload.substring(0, 100)}...`);
833
+ },
834
+ screenshot: (filename, payload) => {
835
+ console.log(`[BaseSuite] Would take screenshot: ${filename}`);
836
+ }
837
+ };
838
+ }
684
839
  this.store = await giver.give(
685
840
  subject,
686
841
  gKey,
687
842
  testResourceConfiguration,
688
843
  this.assertThat,
689
- void 0,
690
- // artifactory
844
+ givenArtifactory,
691
845
  sNdx
692
846
  );
693
847
  this.fails += giver.fails || 0;
@@ -704,24 +858,6 @@ var BaseSuite = class {
704
858
  this.failed = true;
705
859
  }
706
860
  try {
707
- let suiteArtifactory;
708
- if (this.parent && this.parent.createArtifactory) {
709
- suiteArtifactory = this.parent.createArtifactory({
710
- suiteIndex: this.index
711
- });
712
- } else {
713
- const basePath = this.testResourceConfiguration?.fs || "testeranto";
714
- suiteArtifactory = {
715
- writeFileSync: (filename, payload) => {
716
- console.log(
717
- `[BaseSuite] Would write to ${basePath}/suite-${this.index}/${filename}: ${payload.substring(0, 100)}...`
718
- );
719
- },
720
- screenshot: (filename, payload) => {
721
- console.log(`[BaseSuite] Would take screenshot: ${filename}`);
722
- }
723
- };
724
- }
725
861
  this.afterAll(this.store, suiteArtifactory);
726
862
  } catch (e) {
727
863
  console.error(JSON.stringify(e));
@@ -818,6 +954,10 @@ var BaseTiposkripto = class {
818
954
  initialValues
819
955
  );
820
956
  givenInstance._parent = instance;
957
+ if (givenInstance.setParent) {
958
+ givenInstance.setParent(instance);
959
+ }
960
+ console.log(`[BaseTiposkripto] Set _parent for given instance`, givenInstance);
821
961
  return givenInstance;
822
962
  };
823
963
  return a;
@@ -944,6 +1084,8 @@ var BaseTiposkripto = class {
944
1084
  writeFileSync: (filename, payload) => {
945
1085
  let path2 = "";
946
1086
  const basePath = this.testResourceConfiguration?.fs || "testeranto";
1087
+ console.log("[Artifactory] Base path:", basePath);
1088
+ console.log("[Artifactory] Context:", context);
947
1089
  if (context.suiteIndex !== void 0) {
948
1090
  path2 += `suite-${context.suiteIndex}/`;
949
1091
  }
@@ -962,11 +1104,14 @@ var BaseTiposkripto = class {
962
1104
  const basePathClean = basePath.replace(/\/$/, "");
963
1105
  const pathClean = path2.replace(/^\//, "");
964
1106
  const fullPath = `${basePathClean}/${pathClean}`;
1107
+ console.log("[Artifactory] Full path:", fullPath);
965
1108
  this.writeFileSync(fullPath, payload);
966
1109
  },
967
1110
  screenshot: (filename, payload) => {
968
1111
  let path2 = "";
969
1112
  const basePath = this.testResourceConfiguration?.fs || "testeranto";
1113
+ console.log("[Artifactory Screenshot] Base path:", basePath);
1114
+ console.log("[Artifactory Screenshot] Context:", context);
970
1115
  if (context.suiteIndex !== void 0) {
971
1116
  path2 += `suite-${context.suiteIndex}/`;
972
1117
  }
@@ -985,6 +1130,7 @@ var BaseTiposkripto = class {
985
1130
  const basePathClean = basePath.replace(/\/$/, "");
986
1131
  const pathClean = path2.replace(/^\//, "");
987
1132
  const fullPath = `${basePathClean}/${pathClean}`;
1133
+ console.log("[Artifactory Screenshot] Full path:", fullPath);
988
1134
  if (typeof this.screenshot === "function") {
989
1135
  this.screenshot(fullPath, payload || "");
990
1136
  } else {