@skyramp/skyramp 1.3.9 → 1.3.10
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/package.json +1 -1
- package/src/classes/SkyrampClient.d.ts +2 -0
- package/src/classes/SkyrampClient.js +4 -3
- package/src/classes/SmartPlaywright.js +41 -11
- package/src/utils.d.ts +2 -2
- package/src/utils.js +14 -3
package/package.json
CHANGED
|
@@ -126,6 +126,8 @@ interface GenerateRestTestOptions {
|
|
|
126
126
|
playwrightViewportSize?: string;
|
|
127
127
|
playwrightStoragePath?: string;
|
|
128
128
|
playwrightSaveStoragePath?: string;
|
|
129
|
+
browser?: string;
|
|
130
|
+
device?: string;
|
|
129
131
|
loadCount?: string;
|
|
130
132
|
loadDuration?: string;
|
|
131
133
|
loadNumThreads?: string;
|
|
@@ -51,7 +51,7 @@ const initTargetWrapper = lib.func('initTargetWrapper', 'string', ['string']);
|
|
|
51
51
|
const deployTargetWrapper = lib.func('deployTargetWrapper', 'string', ['string', 'string', 'string', 'string', 'string', 'string', 'bool']);
|
|
52
52
|
const deleteTargetWrapper = lib.func('deleteTargetWrapper', 'string', ['string', 'string', 'string', 'string', 'string']);
|
|
53
53
|
|
|
54
|
-
const generateRestTestWrapper = lib.func('generateRestTestWrapper', 'string', ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'bool', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'string', 'bool', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'string', 'string']);
|
|
54
|
+
const generateRestTestWrapper = lib.func('generateRestTestWrapper', 'string', ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'bool', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'string', 'bool', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'string', 'string']);
|
|
55
55
|
const generateRestMockWrapper = lib.func('generateRestMockWrapper', 'string', ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'bool', 'string', 'string', 'string', 'string', 'string', 'string']);
|
|
56
56
|
const traceCollectWrapper = lib.func('traceCollectWrapper', 'string', ['string', 'string', 'bool', 'string', 'string']);
|
|
57
57
|
const analyzeOpenapiWrapper = lib.func('analyzeOpenapiWrapper', 'string', ['string', 'string']);
|
|
@@ -98,8 +98,6 @@ class SkyrampClient {
|
|
|
98
98
|
this.local_image = false;
|
|
99
99
|
this.timestamp = Date.now();
|
|
100
100
|
|
|
101
|
-
checkForUpdate("npm")
|
|
102
|
-
|
|
103
101
|
if (typeof kubeconfigPathOrOptions === 'object') {
|
|
104
102
|
const options = kubeconfigPathOrOptions;
|
|
105
103
|
this.workerNamespaces = [];
|
|
@@ -827,6 +825,8 @@ class SkyrampClient {
|
|
|
827
825
|
options.playwrightViewportSize || "",
|
|
828
826
|
options.playwrightStoragePath || "",
|
|
829
827
|
options.playwrightSaveStoragePath || "",
|
|
828
|
+
options.browser || "",
|
|
829
|
+
options.device || "",
|
|
830
830
|
options.loadCount || "0",
|
|
831
831
|
options.loadDuration || "0",
|
|
832
832
|
options.loadNumThreads || "0",
|
|
@@ -1013,6 +1013,7 @@ class SkyrampClient {
|
|
|
1013
1013
|
* @returns {Promise<string>} A promise that resolves with the initialization output message.
|
|
1014
1014
|
*/
|
|
1015
1015
|
async initAgent(options) {
|
|
1016
|
+
await checkForUpdate("npm");
|
|
1016
1017
|
return new Promise((resolve, reject) => {
|
|
1017
1018
|
initAgentWrapper.async(
|
|
1018
1019
|
options.version || "",
|
|
@@ -290,13 +290,30 @@ class SkyrampPlaywrightLocator {
|
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
|
|
293
|
+
/**
|
|
294
|
+
* execute locator's actions
|
|
295
|
+
*
|
|
296
|
+
* @param {bool} reducedTimeout - it forces 3sec timeout when set to true
|
|
297
|
+
*/
|
|
298
|
+
async execute(reducedTimeout) {
|
|
294
299
|
debug(` execute ${ this._locator}.${this.execFname} ${this.execParam ?? ''} ${this.execArgs ?? ''}`)
|
|
300
|
+
var newArgs = this.execArgs
|
|
301
|
+
if (reducedTimeout !== undefined && reducedTimeout) {
|
|
302
|
+
if (this.execArgs !== null && this.execArgs !== undefined) {
|
|
303
|
+
// we can safetly assume option is the first element in the execArgs
|
|
304
|
+
newArgs = [ { ...this.execArgs[0], timeout: 3000}, ...this.execArgs.slice(1)];
|
|
305
|
+
debug(' reduce timeout', this.execArgs, newArgs)
|
|
306
|
+
} else {
|
|
307
|
+
newArgs = [{ timeout: 3000 }];
|
|
308
|
+
debug(' reduce timeout', newArgs)
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
295
312
|
const func = this._locator[this.execFname];
|
|
296
313
|
if (this.execParam !== null && this.execParam !== undefined) {
|
|
297
|
-
return func.call(this._locator, this.execParam, ...
|
|
314
|
+
return func.call(this._locator, this.execParam, ...newArgs);
|
|
298
315
|
} else {
|
|
299
|
-
return func.call(this._locator, ...
|
|
316
|
+
return func.call(this._locator, ...newArgs);
|
|
300
317
|
}
|
|
301
318
|
}
|
|
302
319
|
|
|
@@ -339,7 +356,7 @@ class SkyrampPlaywrightLocator {
|
|
|
339
356
|
|
|
340
357
|
newPrevHydrationErrorMsg() {
|
|
341
358
|
return `Cannot find locator ${this._locator} and likely a hydration issue on ${this._previousLocator._locator}.\n` +
|
|
342
|
-
`Please add enough waitForTimeout() on ${this.
|
|
359
|
+
`Please add enough waitForTimeout() on ${this._previousLocator._locator}`;
|
|
343
360
|
}
|
|
344
361
|
|
|
345
362
|
newMultiLocatorErrorMsg() {
|
|
@@ -392,16 +409,16 @@ class SkyrampPlaywrightLocator {
|
|
|
392
409
|
await this.wait(defaultWaitForTimeout);
|
|
393
410
|
|
|
394
411
|
// Is this really necessary?
|
|
395
|
-
await this.execute().then(result => {
|
|
412
|
+
await this.execute(true).then(result => {
|
|
396
413
|
return this._skyrampPage.checkNavigation(currentUrl, result);
|
|
397
414
|
}).catch(() => {
|
|
398
415
|
debug(` failed second time and execute previous locator ${this._previousLocator._locator} again`);
|
|
399
|
-
this._previousLocator.execute();
|
|
416
|
+
this._previousLocator.execute(true);
|
|
400
417
|
}).catch(() => {
|
|
401
418
|
debug(` failed to execute previous locator ${this._previousLocator._locator} again, continue`);
|
|
402
419
|
});
|
|
403
420
|
|
|
404
|
-
return this.execute().catch(newError => {
|
|
421
|
+
return this.execute(true).catch(newError => {
|
|
405
422
|
debug(` third attempt on ${this._locator} failed ${newError.name}`);
|
|
406
423
|
if (newError.name == "TimeoutError") {
|
|
407
424
|
// this hadn't happened yet. we need to validate if this is indeed hydration case
|
|
@@ -455,7 +472,7 @@ class SkyrampPlaywrightLocator {
|
|
|
455
472
|
const previousCount = await this._previousLocator.count();
|
|
456
473
|
debug(` re-execute the previous one ${this._previousLocator._locator}, new locator count = ${previousCount}, ${currentUrl}`);
|
|
457
474
|
// re-execute the previous locator
|
|
458
|
-
await this._previousLocator.execute().catch(() => {
|
|
475
|
+
await this._previousLocator.execute(true).catch(() => {
|
|
459
476
|
// log the failure but continues to the current one
|
|
460
477
|
debug(` failed to execute previous locator ${this._previousLocator._locator} again, continue`);
|
|
461
478
|
});
|
|
@@ -470,7 +487,7 @@ class SkyrampPlaywrightLocator {
|
|
|
470
487
|
debug(` ${this._locator} failed at first try. attempting again with some timeout`);
|
|
471
488
|
// wait for some time and re execute
|
|
472
489
|
await this.wait(defaultWaitForTimeout);
|
|
473
|
-
return this.execute().then(result => {
|
|
490
|
+
return this.execute(true).then(result => {
|
|
474
491
|
return this._skyrampPage.checkNavigation(currentUrl, result);
|
|
475
492
|
}).catch(newError => {
|
|
476
493
|
return this._retryWithLLM(newError, this.newPrevHydrationErrorMsg());
|
|
@@ -504,7 +521,7 @@ class SkyrampPlaywrightLocator {
|
|
|
504
521
|
if (error.name == "TimeoutError") {
|
|
505
522
|
debug(`${this._locator} failed at first try. attempting again with some timeout`);
|
|
506
523
|
await this.wait(defaultWaitForTimeout);
|
|
507
|
-
return this.execute().then(result=> {
|
|
524
|
+
return this.execute(true).then(result=> {
|
|
508
525
|
return this._skyrampPage.checkNavigation(currentUrl, result);
|
|
509
526
|
}).catch(newError => {
|
|
510
527
|
if (newError.name == "TimeoutError") {
|
|
@@ -717,7 +734,9 @@ class SkyrampPlaywrightLocator {
|
|
|
717
734
|
|
|
718
735
|
class SkyrampPlaywrightPage {
|
|
719
736
|
constructor(page, testInfo) {
|
|
720
|
-
checkForUpdate("npm")
|
|
737
|
+
checkForUpdate("npm").catch((error) => {
|
|
738
|
+
console.error('checkForUpdate("npm") failed:', error);
|
|
739
|
+
});
|
|
721
740
|
|
|
722
741
|
this._page = page;
|
|
723
742
|
this._testInfo = testInfo; // Store testInfo for screenshot auto-baseline
|
|
@@ -822,6 +841,17 @@ class SkyrampPlaywrightPage {
|
|
|
822
841
|
return this.newSkyrampPlaywrightLocator(originalLocator, alt, options);
|
|
823
842
|
}
|
|
824
843
|
|
|
844
|
+
async waitForResponse(arg, options) {
|
|
845
|
+
// we increase timeout for waitForResponse to 30 sec
|
|
846
|
+
// so that in case smart selector is required
|
|
847
|
+
var newOptions = { timeout: 60000 }
|
|
848
|
+
if (options !== null && options !== undefined) {
|
|
849
|
+
newOptions = { ...options, timeout: 60000 }
|
|
850
|
+
}
|
|
851
|
+
debug(` waitforresponse`, newOptions)
|
|
852
|
+
return this._page.waitForResponse(arg, newOptions)
|
|
853
|
+
}
|
|
854
|
+
|
|
825
855
|
async goto(url, options) {
|
|
826
856
|
const transformedUrl = transformUrlForDocker(url);
|
|
827
857
|
const result = await this._page.goto(transformedUrl, options);
|
package/src/utils.d.ts
CHANGED
|
@@ -93,12 +93,12 @@ export function iterate(jsonInput: object): object;
|
|
|
93
93
|
* @param {string} error - error message if it failed
|
|
94
94
|
* @param {Object} params - any parameters associated with the tool call. Disctionary
|
|
95
95
|
*/
|
|
96
|
-
export function pushToolEvent(entryPoint: string, toolName: string, err: string, params: object): void
|
|
96
|
+
export function pushToolEvent(entryPoint: string, toolName: string, err: string, params: object): Promise<void>;
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* check for update
|
|
100
100
|
*/
|
|
101
|
-
export function checkForUpdate(component: string): void
|
|
101
|
+
export function checkForUpdate(component: string): Promise<void>;
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* The Skyramp YAML version constant.
|
package/src/utils.js
CHANGED
|
@@ -234,16 +234,27 @@ function iterate(fuzz_body) {
|
|
|
234
234
|
function pushToolEvent(entryPoint, toolName, err, params) {
|
|
235
235
|
const paramsStr = JSON.stringify(params);
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
return new Promise((resolve, reject) => {
|
|
238
|
+
pushToolEventWrapper.async(entryPoint, toolName, err, paramsStr, (err) => {
|
|
239
|
+
if (err) reject(err);
|
|
240
|
+
else resolve();
|
|
241
|
+
});
|
|
242
|
+
});
|
|
238
243
|
}
|
|
239
244
|
|
|
240
245
|
/**
|
|
241
246
|
* check if new library is available
|
|
242
247
|
*
|
|
243
|
-
* @param {string} component -
|
|
248
|
+
* @param {string} component - Name of component
|
|
249
|
+
* @returns {Promise<void>}
|
|
244
250
|
*/
|
|
245
251
|
function checkForUpdate(component) {
|
|
246
|
-
|
|
252
|
+
return new Promise((resolve, reject) => {
|
|
253
|
+
checkForUpdateWrapper.async(component, (err) => {
|
|
254
|
+
if (err) reject(err);
|
|
255
|
+
else resolve();
|
|
256
|
+
});
|
|
257
|
+
});
|
|
247
258
|
}
|
|
248
259
|
|
|
249
260
|
module.exports = {
|