testeranto 0.82.0 → 0.84.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/dist/common/package.json +3 -0
- package/dist/common/src/Node.js +2 -0
- package/dist/common/src/PM/main.js +182 -79
- package/dist/common/src/PM/node.js +32 -6
- package/dist/common/src/PM/web.js +28 -54
- package/dist/common/src/Project.js +0 -3
- package/dist/common/src/Puppeteer.js +9 -51
- package/dist/common/src/SubPackages/react-dom/jsx/web.js +11 -11
- package/dist/common/src/Web.js +2 -0
- package/dist/common/src/esbuildConfigs/featuresPlugin.js +39 -0
- package/dist/common/src/esbuildConfigs/inputFilesPlugin.js +62 -41
- package/dist/common/src/esbuildConfigs/node.js +10 -3
- package/dist/common/src/esbuildConfigs/web.js +6 -2
- package/dist/common/src/lib/abstractBase.js +343 -335
- package/dist/common/src/lib/basebuilder.js +7 -3
- package/dist/common/src/lib/core.js +1 -1
- package/dist/common/tsconfig.common.tsbuildinfo +1 -1
- package/dist/module/package.json +3 -0
- package/dist/module/src/Node.js +1 -1
- package/dist/module/src/PM/main.js +182 -79
- package/dist/module/src/PM/node.js +32 -6
- package/dist/module/src/PM/web.js +28 -51
- package/dist/module/src/Project.js +0 -3
- package/dist/module/src/Puppeteer.js +9 -51
- package/dist/module/src/SubPackages/react-dom/jsx/web.js +10 -10
- package/dist/module/src/Web.js +1 -1
- package/dist/module/src/esbuildConfigs/featuresPlugin.js +34 -0
- package/dist/module/src/esbuildConfigs/inputFilesPlugin.js +62 -41
- package/dist/module/src/esbuildConfigs/node.js +10 -3
- package/dist/module/src/esbuildConfigs/web.js +6 -2
- package/dist/module/src/lib/abstractBase.js +343 -335
- package/dist/module/src/lib/basebuilder.js +7 -3
- package/dist/module/src/lib/core.js +1 -1
- package/dist/module/tsconfig.module.tsbuildinfo +1 -1
- package/dist/prebuild/Puppeteer.mjs +82033 -0
- package/dist/types/src/Node.d.ts +5 -1
- package/dist/types/src/PM/index.d.ts +10 -4
- package/dist/types/src/PM/main.d.ts +21 -9
- package/dist/types/src/PM/node.d.ts +11 -3
- package/dist/types/src/PM/web.d.ts +11 -2
- package/dist/types/src/SubPackages/react-dom/jsx/index.d.ts +1 -0
- package/dist/types/src/SubPackages/react-test-renderer/jsx/index.d.ts +1 -0
- package/dist/types/src/SubPackages/react-test-renderer/jsx-promised/index.d.ts +1 -0
- package/dist/types/src/Types.d.ts +2 -2
- package/dist/types/src/Web.d.ts +5 -1
- package/dist/types/src/esbuildConfigs/featuresPlugin.d.ts +5 -0
- package/dist/types/src/esbuildConfigs/inputFilesPlugin.d.ts +4 -2
- package/dist/types/src/lib/abstractBase.d.ts +5 -5
- package/dist/types/src/lib/types.d.ts +7 -5
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +18 -41
- package/pupBuild.js +18 -0
- package/src/Node.ts +1 -3
- package/src/PM/index.ts +12 -3
- package/src/PM/main.ts +300 -164
- package/src/PM/node.ts +40 -6
- package/src/PM/web.ts +108 -58
- package/src/Project.ts +0 -8
- package/src/Puppeteer.ts +11 -57
- package/src/SubPackages/react-dom/jsx/web.ts +15 -10
- package/src/Types.ts +5 -2
- package/src/Web.ts +1 -1
- package/src/esbuildConfigs/featuresPlugin.ts +43 -0
- package/src/esbuildConfigs/inputFilesPlugin.ts +98 -66
- package/src/esbuildConfigs/node.ts +18 -3
- package/src/esbuildConfigs/web.ts +14 -2
- package/src/lib/abstractBase.ts +381 -364
- package/src/lib/basebuilder.ts +7 -7
- package/src/lib/core.ts +1 -1
- package/src/lib/types.ts +13 -5
package/dist/common/src/Node.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NodeTesteranto = void 0;
|
|
6
7
|
const core_js_1 = __importDefault(require("./lib/core.js"));
|
|
7
8
|
const index_js_1 = require("./lib/index.js");
|
|
8
9
|
const node_js_1 = require("./PM/node.js");
|
|
@@ -18,6 +19,7 @@ class NodeTesteranto extends core_js_1.default {
|
|
|
18
19
|
return features;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
22
|
+
exports.NodeTesteranto = NodeTesteranto;
|
|
21
23
|
exports.default = async (input, testSpecification, testImplementation, testInterface, testResourceRequirement = index_js_1.defaultTestResourceRequirement) => {
|
|
22
24
|
return new NodeTesteranto(input, testSpecification, testImplementation, testResourceRequirement, testInterface);
|
|
23
25
|
};
|
|
@@ -30,11 +30,12 @@ exports.PM_Main = void 0;
|
|
|
30
30
|
const fs_1 = __importDefault(require("fs"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
|
|
33
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
33
34
|
const index_js_1 = require("./index.js");
|
|
34
35
|
const utils_js_1 = require("../utils.js");
|
|
35
36
|
const fPaths = [];
|
|
36
37
|
const fileStreams3 = [];
|
|
37
|
-
const files = {};
|
|
38
|
+
const files = {};
|
|
38
39
|
const screenshots = {};
|
|
39
40
|
class PM_Main extends index_js_1.PM {
|
|
40
41
|
constructor(configs) {
|
|
@@ -52,11 +53,9 @@ class PM_Main extends index_js_1.PM {
|
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
55
|
this.register = (src) => {
|
|
55
|
-
// console.log("register", src);
|
|
56
56
|
this.registry[src] = false;
|
|
57
57
|
};
|
|
58
58
|
this.deregister = (src) => {
|
|
59
|
-
// console.log("deregister", src, this.shutdownMode);
|
|
60
59
|
this.registry[src] = true;
|
|
61
60
|
if (this.shutdownMode) {
|
|
62
61
|
this.checkForShutdown();
|
|
@@ -124,16 +123,7 @@ class PM_Main extends index_js_1.PM {
|
|
|
124
123
|
defaultModule
|
|
125
124
|
.receiveTestResourceConfig(argz)
|
|
126
125
|
.then(async (features) => {
|
|
127
|
-
|
|
128
|
-
.reduce(async (mm, lm) => {
|
|
129
|
-
const accum = await mm;
|
|
130
|
-
const x = await this.configs.featureIngestor(features[lm]);
|
|
131
|
-
accum[lm] = x;
|
|
132
|
-
return accum;
|
|
133
|
-
}, Promise.resolve({}))
|
|
134
|
-
.then((x) => {
|
|
135
|
-
fs_1.default.writeFileSync(`${destFolder}/features.json`, JSON.stringify(x, null, 2));
|
|
136
|
-
});
|
|
126
|
+
this.receiveFeatures(features, destFolder);
|
|
137
127
|
})
|
|
138
128
|
.catch((e) => {
|
|
139
129
|
console.log("catch", e);
|
|
@@ -160,22 +150,22 @@ class PM_Main extends index_js_1.PM {
|
|
|
160
150
|
fs: destFolder,
|
|
161
151
|
browserWSEndpoint: this.browser.wsEndpoint(),
|
|
162
152
|
});
|
|
163
|
-
const evaluation = `
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
153
|
+
// const evaluation = `
|
|
154
|
+
// console.log("importing ${dest}.mjs");
|
|
155
|
+
// import('${dest}.mjs').then(async (x) => {
|
|
156
|
+
// console.log("imported", x.default);
|
|
157
|
+
// })`;
|
|
168
158
|
const fileStreams2 = [];
|
|
169
159
|
const doneFileStream2 = [];
|
|
170
160
|
return new Promise((res, rej) => {
|
|
171
161
|
this.browser
|
|
172
162
|
.newPage()
|
|
173
163
|
.then((page) => {
|
|
174
|
-
page.on("console", (msg) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
164
|
+
// page.on("console", (msg) => {
|
|
165
|
+
// console.log("web > ", msg.args(), msg.text());
|
|
166
|
+
// // for (let i = 0; i < msg._args.length; ++i)
|
|
167
|
+
// // console.log(`${i}: ${msg._args[i]}`);
|
|
168
|
+
// });
|
|
179
169
|
page.exposeFunction("custom-screenshot", async (ssOpts, testName) => {
|
|
180
170
|
// console.log("main.ts browser custom-screenshot", testName);
|
|
181
171
|
const p = ssOpts.path;
|
|
@@ -250,35 +240,12 @@ class PM_Main extends index_js_1.PM {
|
|
|
250
240
|
delete screenshots[testName];
|
|
251
241
|
// page.close();
|
|
252
242
|
});
|
|
253
|
-
// globalThis["writeFileSync"](
|
|
254
|
-
// p + "/manifest.json",
|
|
255
|
-
// // files.entries()
|
|
256
|
-
// JSON.stringify(Array.from(files[testName]))
|
|
257
|
-
// );
|
|
258
|
-
// console.log("closing doneFileStream2", doneFileStream2);
|
|
259
|
-
// console.log("closing doneFileStream2", doneFileStream2);
|
|
260
|
-
// Promise.all([...doneFileStream2, ...screenshots2]).then(() => {
|
|
261
|
-
// page.close();
|
|
262
|
-
// });
|
|
263
|
-
// Promise.all(screenshots).then(() => {
|
|
264
|
-
// page.close();
|
|
265
|
-
// });
|
|
266
|
-
// setTimeout(() => {
|
|
267
|
-
// console.log("Delayed for 1 second.");
|
|
268
|
-
// page.close();
|
|
269
|
-
// }, 5000);
|
|
270
|
-
// return page.close();
|
|
271
243
|
});
|
|
272
244
|
return page;
|
|
273
245
|
})
|
|
274
246
|
.then(async (page) => {
|
|
275
|
-
page.on("console", (log) => console.debug(`Log from client: [${log.text()}] `));
|
|
276
247
|
await page.goto(`file://${`${dest}.html`}`, {});
|
|
277
248
|
res(page);
|
|
278
|
-
// page.evaluate(evaluation).finally(() => {
|
|
279
|
-
// console.log("evaluation failed.", dest);
|
|
280
|
-
// });
|
|
281
|
-
// return page;
|
|
282
249
|
});
|
|
283
250
|
});
|
|
284
251
|
};
|
|
@@ -287,13 +254,6 @@ class PM_Main extends index_js_1.PM {
|
|
|
287
254
|
console.log("launchNodeSideCar", src, dest, d);
|
|
288
255
|
const destFolder = dest.replace(".mjs", "");
|
|
289
256
|
let argz = "";
|
|
290
|
-
// const testConfig = this.configs.tests.find((t) => {
|
|
291
|
-
// return t[0] === src;
|
|
292
|
-
// });
|
|
293
|
-
// if (!testConfig) {
|
|
294
|
-
// console.error("missing test config");
|
|
295
|
-
// process.exit(-1);
|
|
296
|
-
// }
|
|
297
257
|
const testConfigResource = testConfig[2];
|
|
298
258
|
let portsToUse = [];
|
|
299
259
|
if (testConfigResource.ports === 0) {
|
|
@@ -378,7 +338,7 @@ class PM_Main extends index_js_1.PM {
|
|
|
378
338
|
const evaluation = `
|
|
379
339
|
console.log("importing ${dest}.mjs");
|
|
380
340
|
import('${dest}.mjs').then(async (x) => {
|
|
381
|
-
console.log("imported", x.default);
|
|
341
|
+
console.log("imported", (await x.default));
|
|
382
342
|
try {
|
|
383
343
|
return await (await x.default).receiveTestResourceConfig(${webArgz})
|
|
384
344
|
} catch (e) {
|
|
@@ -390,13 +350,30 @@ class PM_Main extends index_js_1.PM {
|
|
|
390
350
|
this.browser
|
|
391
351
|
.newPage()
|
|
392
352
|
.then((page) => {
|
|
393
|
-
page.on("console", (msg) => {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
353
|
+
// page.on("console", (msg) => {
|
|
354
|
+
// // console.log("web > ", msg.args(), msg.text());
|
|
355
|
+
// });
|
|
356
|
+
page.exposeFunction("screencast", async (ssOpts, testName) => {
|
|
357
|
+
const p = ssOpts.path;
|
|
358
|
+
const dir = path_1.default.dirname(p);
|
|
359
|
+
fs_1.default.mkdirSync(dir, {
|
|
360
|
+
recursive: true,
|
|
361
|
+
});
|
|
362
|
+
if (!files[testName]) {
|
|
363
|
+
files[testName] = new Set();
|
|
364
|
+
}
|
|
365
|
+
files[testName].add(ssOpts.path);
|
|
366
|
+
const sPromise = page.screenshot(Object.assign(Object.assign({}, ssOpts), { path: p }));
|
|
367
|
+
if (!screenshots[testName]) {
|
|
368
|
+
screenshots[testName] = [];
|
|
369
|
+
}
|
|
370
|
+
screenshots[testName].push(sPromise);
|
|
371
|
+
// sPromise.then(())
|
|
372
|
+
await sPromise;
|
|
373
|
+
return sPromise;
|
|
374
|
+
// page.evaluate(`window["screenshot done"]`);
|
|
397
375
|
});
|
|
398
376
|
page.exposeFunction("customScreenShot", async (ssOpts, testName) => {
|
|
399
|
-
// console.log("main.ts browser custom-screenshot", testName);
|
|
400
377
|
const p = ssOpts.path;
|
|
401
378
|
const dir = path_1.default.dirname(p);
|
|
402
379
|
fs_1.default.mkdirSync(dir, {
|
|
@@ -495,24 +472,45 @@ class PM_Main extends index_js_1.PM {
|
|
|
495
472
|
// }, 5000);
|
|
496
473
|
// return page.close();
|
|
497
474
|
});
|
|
475
|
+
page.exposeFunction("page", () => {
|
|
476
|
+
return page.mainFrame()._id;
|
|
477
|
+
});
|
|
478
|
+
page.exposeFunction("click", (sel) => {
|
|
479
|
+
return page.click(sel);
|
|
480
|
+
});
|
|
481
|
+
page.exposeFunction("focusOn", (sel) => {
|
|
482
|
+
return page.focus(sel);
|
|
483
|
+
});
|
|
484
|
+
page.exposeFunction("typeInto", async (value) => await page.keyboard.type(value));
|
|
485
|
+
page.exposeFunction("getValue", (selector) => page.$eval(selector, (input) => input.getAttribute("value")));
|
|
486
|
+
page.exposeFunction("getAttribute", async (selector, attribute) => {
|
|
487
|
+
const attributeValue = await page.$eval(selector, (input) => {
|
|
488
|
+
return input.getAttribute(attribute);
|
|
489
|
+
});
|
|
490
|
+
return attributeValue;
|
|
491
|
+
});
|
|
492
|
+
page.exposeFunction("isDisabled", async (selector) => {
|
|
493
|
+
const attributeValue = await page.$eval(selector, (input) => {
|
|
494
|
+
return input.disabled;
|
|
495
|
+
});
|
|
496
|
+
return attributeValue;
|
|
497
|
+
});
|
|
498
|
+
page.exposeFunction("$", async (selector) => {
|
|
499
|
+
const x = page.$(selector);
|
|
500
|
+
const y = await x;
|
|
501
|
+
return y;
|
|
502
|
+
});
|
|
498
503
|
return page;
|
|
499
504
|
})
|
|
500
505
|
.then(async (page) => {
|
|
501
|
-
page.on("console", (log) =>
|
|
506
|
+
// page.on("console", (log) =>
|
|
507
|
+
// console.debug(`Log from client: [${log.text()}] `)
|
|
508
|
+
// );
|
|
502
509
|
await page.goto(`file://${`${dest}.html`}`, {});
|
|
503
510
|
await page
|
|
504
511
|
.evaluate(evaluation)
|
|
505
512
|
.then(async (features) => {
|
|
506
|
-
|
|
507
|
-
.reduce(async (mm, lm) => {
|
|
508
|
-
const accum = await mm;
|
|
509
|
-
const x = await this.configs.featureIngestor(features[lm]);
|
|
510
|
-
accum[lm] = x;
|
|
511
|
-
return accum;
|
|
512
|
-
}, Promise.resolve({}))
|
|
513
|
-
.then((x) => {
|
|
514
|
-
fs_1.default.writeFileSync(`${destFolder}/features.json`, JSON.stringify(x, null, 2));
|
|
515
|
-
});
|
|
513
|
+
this.receiveFeatures(features, destFolder);
|
|
516
514
|
})
|
|
517
515
|
.catch((e) => {
|
|
518
516
|
console.log("evaluation failed.", dest);
|
|
@@ -522,11 +520,62 @@ class PM_Main extends index_js_1.PM {
|
|
|
522
520
|
console.log("evaluation complete.", dest);
|
|
523
521
|
// page.close();
|
|
524
522
|
this.deregister(t);
|
|
525
|
-
// whyIsNodeRunning();
|
|
526
523
|
});
|
|
527
524
|
return page;
|
|
528
525
|
});
|
|
529
526
|
};
|
|
527
|
+
this.receiveFeatures = (features, destFolder) => {
|
|
528
|
+
console.log("this.receiveFeatures", features);
|
|
529
|
+
features
|
|
530
|
+
.reduce(async (mm, featureStringKey) => {
|
|
531
|
+
const accum = await mm;
|
|
532
|
+
const isUrl = isValidUrl(featureStringKey);
|
|
533
|
+
if (isUrl) {
|
|
534
|
+
const u = new URL(featureStringKey);
|
|
535
|
+
if (u.protocol === "file:") {
|
|
536
|
+
const newPath = `${process.cwd()}/docs/features/internal/${path_1.default.relative(process.cwd(), u.pathname)}`;
|
|
537
|
+
await fs_1.default.promises.mkdir(path_1.default.dirname(newPath), { recursive: true });
|
|
538
|
+
try {
|
|
539
|
+
await fs_1.default.unlinkSync(newPath);
|
|
540
|
+
// console.log(`Removed existing link at ${newPath}`);
|
|
541
|
+
}
|
|
542
|
+
catch (error) {
|
|
543
|
+
if (error.code !== "ENOENT") {
|
|
544
|
+
// throw error;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
fs_1.default.symlink(u.pathname, newPath, (err) => {
|
|
548
|
+
if (err) {
|
|
549
|
+
// console.error("Error creating symlink:", err);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
// console.log("Symlink created successfully");
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
accum.push(newPath);
|
|
556
|
+
}
|
|
557
|
+
else if (u.protocol === "http:" || u.protocol === "https:") {
|
|
558
|
+
const newPath = `${process.cwd()}/docs/features/external${u.hostname}${u.pathname}`;
|
|
559
|
+
const body = await this.configs.featureIngestor(featureStringKey);
|
|
560
|
+
writeFileAndCreateDir(newPath, body);
|
|
561
|
+
accum.push(newPath);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
const newPath = `${process.cwd()}/docs/features/plain/${await sha256(featureStringKey)}`;
|
|
566
|
+
writeFileAndCreateDir(newPath, featureStringKey);
|
|
567
|
+
accum.push(newPath);
|
|
568
|
+
}
|
|
569
|
+
return accum;
|
|
570
|
+
}, Promise.resolve([]))
|
|
571
|
+
.then((features) => {
|
|
572
|
+
fs_1.default.writeFileSync(`${destFolder}/featurePrompt.txt`, features
|
|
573
|
+
.map((f) => {
|
|
574
|
+
return `/read ${f}`;
|
|
575
|
+
})
|
|
576
|
+
.join("\n"));
|
|
577
|
+
});
|
|
578
|
+
};
|
|
530
579
|
this.server = {};
|
|
531
580
|
this.configs = configs;
|
|
532
581
|
this.ports = {};
|
|
@@ -597,17 +646,14 @@ class PM_Main extends index_js_1.PM {
|
|
|
597
646
|
delete files[testName];
|
|
598
647
|
};
|
|
599
648
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
this.shutdownMode = true;
|
|
603
|
-
this.checkForShutdown();
|
|
649
|
+
$(selector) {
|
|
650
|
+
throw new Error("Method not implemented.");
|
|
604
651
|
}
|
|
605
|
-
|
|
652
|
+
screencast(opts) {
|
|
606
653
|
throw new Error("Method not implemented.");
|
|
607
654
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
return this.browser;
|
|
655
|
+
customScreenShot(opts) {
|
|
656
|
+
throw new Error("Method not implemented.");
|
|
611
657
|
}
|
|
612
658
|
end(accessObject) {
|
|
613
659
|
throw new Error("Method not implemented.");
|
|
@@ -670,5 +716,62 @@ class PM_Main extends index_js_1.PM {
|
|
|
670
716
|
write(accessObject, contents) {
|
|
671
717
|
throw new Error("Method not implemented.");
|
|
672
718
|
}
|
|
719
|
+
page() {
|
|
720
|
+
throw new Error("Method not implemented.");
|
|
721
|
+
}
|
|
722
|
+
click(selector) {
|
|
723
|
+
throw new Error("Method not implemented.");
|
|
724
|
+
}
|
|
725
|
+
focusOn(selector) {
|
|
726
|
+
throw new Error("Method not implemented.");
|
|
727
|
+
}
|
|
728
|
+
typeInto(value) {
|
|
729
|
+
throw new Error("Method not implemented.");
|
|
730
|
+
}
|
|
731
|
+
getValue(value) {
|
|
732
|
+
throw new Error("Method not implemented.");
|
|
733
|
+
}
|
|
734
|
+
getAttribute(selector, attribute) {
|
|
735
|
+
throw new Error("Method not implemented.");
|
|
736
|
+
}
|
|
737
|
+
isDisabled(selector) {
|
|
738
|
+
throw new Error("Method not implemented.");
|
|
739
|
+
}
|
|
740
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
741
|
+
async startPuppeteer(options, destfolder) {
|
|
742
|
+
this.browser = (await puppeteer_core_1.default.launch(options));
|
|
743
|
+
}
|
|
744
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
745
|
+
shutDown() {
|
|
746
|
+
console.log("shutting down...");
|
|
747
|
+
this.shutdownMode = true;
|
|
748
|
+
this.checkForShutdown();
|
|
749
|
+
}
|
|
673
750
|
}
|
|
674
751
|
exports.PM_Main = PM_Main;
|
|
752
|
+
async function writeFileAndCreateDir(filePath, data) {
|
|
753
|
+
const dirPath = path_1.default.dirname(filePath);
|
|
754
|
+
try {
|
|
755
|
+
await fs_1.default.promises.mkdir(dirPath, { recursive: true });
|
|
756
|
+
await fs_1.default.promises.writeFile(filePath, data);
|
|
757
|
+
}
|
|
758
|
+
catch (error) {
|
|
759
|
+
console.error(`Error writing file: ${error}`);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
async function sha256(rawData) {
|
|
763
|
+
const data = typeof rawData === "object" ? JSON.stringify(rawData) : String(rawData);
|
|
764
|
+
const msgBuffer = new TextEncoder().encode(data);
|
|
765
|
+
const hashBuffer = await crypto_1.default.subtle.digest("SHA-256", msgBuffer);
|
|
766
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
767
|
+
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
768
|
+
}
|
|
769
|
+
function isValidUrl(string) {
|
|
770
|
+
try {
|
|
771
|
+
new URL(string);
|
|
772
|
+
return true;
|
|
773
|
+
}
|
|
774
|
+
catch (err) {
|
|
775
|
+
return false;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.PM_Node = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
|
|
10
9
|
const index_js_1 = require("./index.js");
|
|
11
10
|
const fPaths = [];
|
|
12
11
|
class PM_Node extends index_js_1.PM {
|
|
@@ -15,8 +14,35 @@ class PM_Node extends index_js_1.PM {
|
|
|
15
14
|
this.server = {};
|
|
16
15
|
this.testResourceConfiguration = t;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
$(selector) {
|
|
18
|
+
throw new Error("Method not implemented.");
|
|
19
|
+
}
|
|
20
|
+
screencast(opts) {
|
|
21
|
+
throw new Error("Method not implemented.");
|
|
22
|
+
}
|
|
23
|
+
isDisabled(selector) {
|
|
24
|
+
throw new Error("Method not implemented.");
|
|
25
|
+
}
|
|
26
|
+
getAttribute(selector, attribute) {
|
|
27
|
+
throw new Error("Method not implemented.");
|
|
28
|
+
}
|
|
29
|
+
getValue(selector) {
|
|
30
|
+
throw new Error("Method not implemented.");
|
|
31
|
+
}
|
|
32
|
+
focusOn(selector) {
|
|
33
|
+
throw new Error("Method not implemented.");
|
|
34
|
+
}
|
|
35
|
+
typeInto(value) {
|
|
36
|
+
throw new Error("Method not implemented.");
|
|
37
|
+
}
|
|
38
|
+
page() {
|
|
39
|
+
return globalThis["page"]();
|
|
40
|
+
}
|
|
41
|
+
click(selector) {
|
|
42
|
+
return globalThis["click"](selector);
|
|
43
|
+
}
|
|
44
|
+
customScreenShot(opts) {
|
|
45
|
+
return globalThis["customScreenShot"](opts);
|
|
20
46
|
}
|
|
21
47
|
existsSync(destFolder) {
|
|
22
48
|
return globalThis["existsSync"](this.testResourceConfiguration.fs + "/" + destFolder);
|
|
@@ -79,9 +105,9 @@ class PM_Node extends index_js_1.PM {
|
|
|
79
105
|
}
|
|
80
106
|
// launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
|
|
81
107
|
startPuppeteer(options) {
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
});
|
|
108
|
+
// return puppeteer.connect(options).then((b) => {
|
|
109
|
+
// this.browser = b;
|
|
110
|
+
// });
|
|
85
111
|
}
|
|
86
112
|
}
|
|
87
113
|
exports.PM_Node = PM_Node;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.PM_Web = void 0;
|
|
7
|
-
const puppeteer_core_browser_js_1 = __importDefault(require("puppeteer-core/lib/esm/puppeteer/puppeteer-core-browser.js"));
|
|
8
4
|
const index_js_1 = require("./index.js");
|
|
9
5
|
class PM_Web extends index_js_1.PM {
|
|
10
6
|
constructor(t) {
|
|
@@ -12,8 +8,35 @@ class PM_Web extends index_js_1.PM {
|
|
|
12
8
|
this.server = {};
|
|
13
9
|
this.testResourceConfiguration = t;
|
|
14
10
|
}
|
|
11
|
+
$(selector) {
|
|
12
|
+
return window["$"](selector);
|
|
13
|
+
}
|
|
14
|
+
screencast(opts) {
|
|
15
|
+
throw new Error("Method not implemented.");
|
|
16
|
+
}
|
|
17
|
+
isDisabled(selector) {
|
|
18
|
+
return window["isDisabled"](selector);
|
|
19
|
+
}
|
|
20
|
+
getAttribute(selector, attribute) {
|
|
21
|
+
return window["getValue"](selector, attribute);
|
|
22
|
+
}
|
|
23
|
+
getValue(selector) {
|
|
24
|
+
return window["getValue"](selector);
|
|
25
|
+
}
|
|
26
|
+
focusOn(selector) {
|
|
27
|
+
return window["focusOn"](selector);
|
|
28
|
+
}
|
|
29
|
+
typeInto(value) {
|
|
30
|
+
return window["typeInto"](value);
|
|
31
|
+
}
|
|
32
|
+
page() {
|
|
33
|
+
return window["page"]();
|
|
34
|
+
}
|
|
35
|
+
click(selector) {
|
|
36
|
+
return window["click"](selector);
|
|
37
|
+
}
|
|
15
38
|
customScreenShot(opts) {
|
|
16
|
-
window["customScreenShot"](opts);
|
|
39
|
+
return window["customScreenShot"](Object.assign(Object.assign({}, opts), { path: this.testResourceConfiguration.fs + "/" + opts.path }), this.testResourceConfiguration.name);
|
|
17
40
|
}
|
|
18
41
|
existsSync(destFolder) {
|
|
19
42
|
return window["existsSync"](destFolder);
|
|
@@ -79,54 +102,5 @@ class PM_Web extends index_js_1.PM {
|
|
|
79
102
|
}));
|
|
80
103
|
};
|
|
81
104
|
}
|
|
82
|
-
startPuppeteer(options, destFolder) {
|
|
83
|
-
const name = this.testResourceConfiguration.name;
|
|
84
|
-
return fetch(`http://localhost:3234/json/version`)
|
|
85
|
-
.then((v) => {
|
|
86
|
-
return v.json();
|
|
87
|
-
})
|
|
88
|
-
.then((json) => {
|
|
89
|
-
return puppeteer_core_browser_js_1.default
|
|
90
|
-
.connect({
|
|
91
|
-
browserWSEndpoint: json.webSocketDebuggerUrl,
|
|
92
|
-
})
|
|
93
|
-
.then((b) => {
|
|
94
|
-
this.browser = b;
|
|
95
|
-
const handler2 = {
|
|
96
|
-
get(target, prop, receiver) {
|
|
97
|
-
if (prop === "screenshot") {
|
|
98
|
-
return async (x) => {
|
|
99
|
-
return await window["custom-screenshot"](Object.assign(Object.assign({}, x), {
|
|
100
|
-
// path: destFolder + "/" + x.path,
|
|
101
|
-
path: x.path }), name);
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
else if (prop === "mainFrame") {
|
|
105
|
-
return () => target[prop](...arguments);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
return Reflect.get(...arguments);
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
const handler1 = {
|
|
113
|
-
get(target, prop, receiver) {
|
|
114
|
-
if (prop === "pages") {
|
|
115
|
-
return async () => {
|
|
116
|
-
return target.pages().then((pages) => {
|
|
117
|
-
return pages.map((p) => {
|
|
118
|
-
return new Proxy(p, handler2);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
return Reflect.get(...arguments);
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
const proxy3 = new Proxy(this.browser, handler1);
|
|
127
|
-
this.browser = proxy3;
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
105
|
}
|
|
132
106
|
exports.PM_Web = PM_Web;
|
|
@@ -12,7 +12,6 @@ const glob_1 = require("glob");
|
|
|
12
12
|
const node_js_1 = __importDefault(require("./esbuildConfigs/node.js"));
|
|
13
13
|
const web_js_1 = __importDefault(require("./esbuildConfigs/web.js"));
|
|
14
14
|
const web_html_js_1 = __importDefault(require("./web.html.js"));
|
|
15
|
-
// var mode: "DEV" | "PROD" = process.argv[2] === "-dev" ? "DEV" : "PROD";
|
|
16
15
|
readline_1.default.emitKeypressEvents(process.stdin);
|
|
17
16
|
if (process.stdin.isTTY)
|
|
18
17
|
process.stdin.setRawMode(true);
|
|
@@ -74,7 +73,6 @@ class ITProject {
|
|
|
74
73
|
.then((x) => fs_1.default.writeFileSync(htmlFilePath, (0, web_html_js_1.default)(jsfilePath, htmlFilePath)));
|
|
75
74
|
})));
|
|
76
75
|
const [nodeEntryPoints, webEntryPoints] = getRunnables(this.config.tests);
|
|
77
|
-
console.log(`this.getSecondaryEndpointsPoints("web")`, this.getSecondaryEndpointsPoints("web"));
|
|
78
76
|
(0, glob_1.glob)(`./${this.config.outdir}/chunk-*.mjs`, {
|
|
79
77
|
ignore: "node_modules/**",
|
|
80
78
|
}).then((chunks) => {
|
|
@@ -118,7 +116,6 @@ class ITProject {
|
|
|
118
116
|
getSecondaryEndpointsPoints(runtime) {
|
|
119
117
|
const meta = (ts, st) => {
|
|
120
118
|
ts.forEach((t) => {
|
|
121
|
-
console.log("getSecondaryEndpointsPoints", t);
|
|
122
119
|
if (t[1] === runtime) {
|
|
123
120
|
st.add(t[0]);
|
|
124
121
|
}
|