tauri-test-cli 0.7.1 → 0.7.2
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/cli.js +75 -22
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -120910,6 +120910,11 @@ async function waitForInteractive(selector, timeout = 5000) {
|
|
|
120910
120910
|
// src/commands/utils.ts
|
|
120911
120911
|
var xvfbDisplay = null;
|
|
120912
120912
|
function getXvfbDisplay() {
|
|
120913
|
+
const envVal = process.env.TAURI_TEST_XVFB_DISPLAY;
|
|
120914
|
+
if (envVal !== undefined) {
|
|
120915
|
+
const n = Number(envVal);
|
|
120916
|
+
return Number.isFinite(n) ? n : null;
|
|
120917
|
+
}
|
|
120913
120918
|
return xvfbDisplay;
|
|
120914
120919
|
}
|
|
120915
120920
|
|
|
@@ -120988,10 +120993,11 @@ async function captureWithHtml2Canvas(browser3) {
|
|
|
120988
120993
|
throw new Error("Failed to load html2canvas from CDN");
|
|
120989
120994
|
}
|
|
120990
120995
|
await new Promise((r) => setTimeout(r, 50));
|
|
120991
|
-
|
|
120996
|
+
await browser3.execute(() => {
|
|
120997
|
+
window.__h2cResult = undefined;
|
|
120992
120998
|
const h2c = window.html2canvas;
|
|
120993
120999
|
if (!h2c) {
|
|
120994
|
-
|
|
121000
|
+
window.__h2cResult = "";
|
|
120995
121001
|
return;
|
|
120996
121002
|
}
|
|
120997
121003
|
h2c(document.body, {
|
|
@@ -121001,17 +121007,25 @@ async function captureWithHtml2Canvas(browser3) {
|
|
|
121001
121007
|
backgroundColor: "#ffffff"
|
|
121002
121008
|
}).then((canvas) => {
|
|
121003
121009
|
const dataUrl = canvas.toDataURL("image/png");
|
|
121004
|
-
|
|
121005
|
-
}).catch(() =>
|
|
121006
|
-
|
|
121010
|
+
window.__h2cResult = dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
121011
|
+
}).catch(() => {
|
|
121012
|
+
window.__h2cResult = "";
|
|
121013
|
+
});
|
|
121014
|
+
setTimeout(() => {
|
|
121015
|
+
if (window.__h2cResult === undefined) {
|
|
121016
|
+
window.__h2cResult = "";
|
|
121017
|
+
}
|
|
121018
|
+
}, 4000);
|
|
121007
121019
|
});
|
|
121020
|
+
const base64 = await pollForResult(browser3, "__h2cResult");
|
|
121008
121021
|
if (!base64) {
|
|
121009
121022
|
throw new Error("html2canvas capture returned empty");
|
|
121010
121023
|
}
|
|
121011
121024
|
return base64;
|
|
121012
121025
|
}
|
|
121013
121026
|
async function captureWithCanvas(browser3) {
|
|
121014
|
-
|
|
121027
|
+
await browser3.execute(() => {
|
|
121028
|
+
window.__canvasResult = undefined;
|
|
121015
121029
|
try {
|
|
121016
121030
|
const w2 = window.innerWidth || 800;
|
|
121017
121031
|
const h = window.innerHeight || 600;
|
|
@@ -121036,7 +121050,7 @@ async function captureWithCanvas(browser3) {
|
|
|
121036
121050
|
ctx.drawImage(img, 0, 0);
|
|
121037
121051
|
URL.revokeObjectURL(url2);
|
|
121038
121052
|
const dataUrl = canvas.toDataURL("image/png");
|
|
121039
|
-
|
|
121053
|
+
window.__canvasResult = dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
121040
121054
|
};
|
|
121041
121055
|
img.onerror = () => {
|
|
121042
121056
|
URL.revokeObjectURL(url2);
|
|
@@ -121049,22 +121063,36 @@ async function captureWithCanvas(browser3) {
|
|
|
121049
121063
|
ctx.fillText(lines[i], 10, 20 + i * 20);
|
|
121050
121064
|
}
|
|
121051
121065
|
const dataUrl = canvas.toDataURL("image/png");
|
|
121052
|
-
|
|
121066
|
+
window.__canvasResult = dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
121053
121067
|
};
|
|
121054
121068
|
img.src = url2;
|
|
121055
121069
|
setTimeout(() => {
|
|
121056
|
-
|
|
121057
|
-
|
|
121070
|
+
if (window.__canvasResult === undefined) {
|
|
121071
|
+
const dataUrl = canvas.toDataURL("image/png");
|
|
121072
|
+
window.__canvasResult = dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
121073
|
+
}
|
|
121058
121074
|
}, 4000);
|
|
121059
121075
|
} catch (e) {
|
|
121060
|
-
|
|
121076
|
+
window.__canvasResult = "";
|
|
121061
121077
|
}
|
|
121062
121078
|
});
|
|
121079
|
+
const base64 = await pollForResult(browser3, "__canvasResult");
|
|
121063
121080
|
if (!base64) {
|
|
121064
121081
|
throw new Error("Canvas screenshot capture returned empty");
|
|
121065
121082
|
}
|
|
121066
121083
|
return base64;
|
|
121067
121084
|
}
|
|
121085
|
+
async function pollForResult(browser3, key, intervalMs = 100, maxMs = 5000) {
|
|
121086
|
+
const start = Date.now();
|
|
121087
|
+
while (Date.now() - start < maxMs) {
|
|
121088
|
+
const val3 = await browser3.execute((k) => window[k], key);
|
|
121089
|
+
if (val3 !== undefined)
|
|
121090
|
+
return val3;
|
|
121091
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
121092
|
+
}
|
|
121093
|
+
const val2 = await browser3.execute((k) => window[k], key);
|
|
121094
|
+
return val2 ?? "";
|
|
121095
|
+
}
|
|
121068
121096
|
|
|
121069
121097
|
// src/commands/snapshot.ts
|
|
121070
121098
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
@@ -121416,10 +121444,11 @@ async function captureWithHtml2Canvas2(browser3) {
|
|
|
121416
121444
|
throw new Error("Failed to load html2canvas from CDN");
|
|
121417
121445
|
}
|
|
121418
121446
|
await new Promise((r) => setTimeout(r, 50));
|
|
121419
|
-
|
|
121447
|
+
await browser3.execute(() => {
|
|
121448
|
+
window.__h2cResult = undefined;
|
|
121420
121449
|
const h2c = window.html2canvas;
|
|
121421
121450
|
if (!h2c) {
|
|
121422
|
-
|
|
121451
|
+
window.__h2cResult = "";
|
|
121423
121452
|
return;
|
|
121424
121453
|
}
|
|
121425
121454
|
h2c(document.body, {
|
|
@@ -121429,17 +121458,25 @@ async function captureWithHtml2Canvas2(browser3) {
|
|
|
121429
121458
|
backgroundColor: "#ffffff"
|
|
121430
121459
|
}).then((canvas) => {
|
|
121431
121460
|
const dataUrl = canvas.toDataURL("image/png");
|
|
121432
|
-
|
|
121433
|
-
}).catch(() =>
|
|
121434
|
-
|
|
121461
|
+
window.__h2cResult = dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
121462
|
+
}).catch(() => {
|
|
121463
|
+
window.__h2cResult = "";
|
|
121464
|
+
});
|
|
121465
|
+
setTimeout(() => {
|
|
121466
|
+
if (window.__h2cResult === undefined) {
|
|
121467
|
+
window.__h2cResult = "";
|
|
121468
|
+
}
|
|
121469
|
+
}, 4000);
|
|
121435
121470
|
});
|
|
121471
|
+
const base64 = await pollForResult2(browser3, "__h2cResult");
|
|
121436
121472
|
if (!base64) {
|
|
121437
121473
|
throw new Error("html2canvas capture returned empty");
|
|
121438
121474
|
}
|
|
121439
121475
|
return base64;
|
|
121440
121476
|
}
|
|
121441
121477
|
async function captureWithCanvas2(browser3) {
|
|
121442
|
-
|
|
121478
|
+
await browser3.execute(() => {
|
|
121479
|
+
window.__canvasResult = undefined;
|
|
121443
121480
|
try {
|
|
121444
121481
|
const w2 = window.innerWidth || 800;
|
|
121445
121482
|
const h = window.innerHeight || 600;
|
|
@@ -121464,7 +121501,7 @@ async function captureWithCanvas2(browser3) {
|
|
|
121464
121501
|
ctx.drawImage(img, 0, 0);
|
|
121465
121502
|
URL.revokeObjectURL(url2);
|
|
121466
121503
|
const dataUrl = canvas.toDataURL("image/png");
|
|
121467
|
-
|
|
121504
|
+
window.__canvasResult = dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
121468
121505
|
};
|
|
121469
121506
|
img.onerror = () => {
|
|
121470
121507
|
URL.revokeObjectURL(url2);
|
|
@@ -121477,22 +121514,36 @@ async function captureWithCanvas2(browser3) {
|
|
|
121477
121514
|
ctx.fillText(lines[i], 10, 20 + i * 20);
|
|
121478
121515
|
}
|
|
121479
121516
|
const dataUrl = canvas.toDataURL("image/png");
|
|
121480
|
-
|
|
121517
|
+
window.__canvasResult = dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
121481
121518
|
};
|
|
121482
121519
|
img.src = url2;
|
|
121483
121520
|
setTimeout(() => {
|
|
121484
|
-
|
|
121485
|
-
|
|
121521
|
+
if (window.__canvasResult === undefined) {
|
|
121522
|
+
const dataUrl = canvas.toDataURL("image/png");
|
|
121523
|
+
window.__canvasResult = dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
121524
|
+
}
|
|
121486
121525
|
}, 4000);
|
|
121487
121526
|
} catch (e) {
|
|
121488
|
-
|
|
121527
|
+
window.__canvasResult = "";
|
|
121489
121528
|
}
|
|
121490
121529
|
});
|
|
121530
|
+
const base64 = await pollForResult2(browser3, "__canvasResult");
|
|
121491
121531
|
if (!base64) {
|
|
121492
121532
|
throw new Error("Canvas screenshot capture returned empty");
|
|
121493
121533
|
}
|
|
121494
121534
|
return base64;
|
|
121495
121535
|
}
|
|
121536
|
+
async function pollForResult2(browser3, key, intervalMs = 100, maxMs = 5000) {
|
|
121537
|
+
const start = Date.now();
|
|
121538
|
+
while (Date.now() - start < maxMs) {
|
|
121539
|
+
const val3 = await browser3.execute((k) => window[k], key);
|
|
121540
|
+
if (val3 !== undefined)
|
|
121541
|
+
return val3;
|
|
121542
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
121543
|
+
}
|
|
121544
|
+
const val2 = await browser3.execute((k) => window[k], key);
|
|
121545
|
+
return val2 ?? "";
|
|
121546
|
+
}
|
|
121496
121547
|
|
|
121497
121548
|
// src/commands/snapshot.ts
|
|
121498
121549
|
import { writeFile as writeFile4 } from "fs/promises";
|
|
@@ -122294,6 +122345,7 @@ async function startXvfb() {
|
|
|
122294
122345
|
}
|
|
122295
122346
|
console.error(`Xvfb ready on display ${displayStr}`);
|
|
122296
122347
|
xvfbDisplay2 = display;
|
|
122348
|
+
process.env.TAURI_TEST_XVFB_DISPLAY = String(display);
|
|
122297
122349
|
process.env.DISPLAY = displayStr;
|
|
122298
122350
|
delete process.env.WAYLAND_DISPLAY;
|
|
122299
122351
|
process.env.GDK_BACKEND = "x11";
|
|
@@ -122305,6 +122357,7 @@ function stopXvfb() {
|
|
|
122305
122357
|
xvfbProcess.kill("SIGTERM");
|
|
122306
122358
|
xvfbProcess = null;
|
|
122307
122359
|
xvfbDisplay2 = null;
|
|
122360
|
+
delete process.env.TAURI_TEST_XVFB_DISPLAY;
|
|
122308
122361
|
}
|
|
122309
122362
|
}
|
|
122310
122363
|
|