e2e-box 1.0.1 → 1.0.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/README.md +7 -0
- package/dist/cli.js +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
14
|
+
<a href="https://www.npmjs.com/package/e2e-box"><img src="https://img.shields.io/npm/v/e2e-box?style=flat-square&color=a78bfa" alt="npm version"></a>
|
|
14
15
|
<img src="https://img.shields.io/badge/Android-adb-4ade80?style=flat-square" alt="Android over adb">
|
|
15
16
|
<img src="https://img.shields.io/badge/flows-YAML%20(Maestro)-a78bfa?style=flat-square" alt="Maestro-style YAML flows">
|
|
16
17
|
<img src="https://img.shields.io/badge/Next.js-15-1b1631?style=flat-square" alt="Next.js 15">
|
|
@@ -198,6 +199,12 @@ Not supported yet (skipped with a warning): `evalScript`, `runScript`, `setLocat
|
|
|
198
199
|
Security: the API only accepts calls from its own page (local Host, the app's Origin and JSON); workspaces must live inside
|
|
199
200
|
the folder that contains e2e-box, and subflows inside their workspace.
|
|
200
201
|
|
|
202
|
+
## Contributing
|
|
203
|
+
|
|
204
|
+
Issues and pull requests are welcome: see [CONTRIBUTING.md](CONTRIBUTING.md) for setup and conventions, and
|
|
205
|
+
[CHANGELOG.md](CHANGELOG.md) for what changed in each version. Please report security issues privately, as described
|
|
206
|
+
in [SECURITY.md](SECURITY.md). This project follows a [code of conduct](CODE_OF_CONDUCT.md).
|
|
207
|
+
|
|
201
208
|
## License
|
|
202
209
|
|
|
203
210
|
[MIT](LICENSE)
|
package/dist/cli.js
CHANGED
|
@@ -7690,6 +7690,27 @@ var Adb = class _Adb {
|
|
|
7690
7690
|
return { serial, state, model: kv.model?.replace(/_/g, " "), transport: kv.usb ? "usb" : serial.includes(":") ? "wifi" : void 0 };
|
|
7691
7691
|
});
|
|
7692
7692
|
}
|
|
7693
|
+
/**
|
|
7694
|
+
* Acende a tela e impede que ela apague (e o celular bloqueie) durante a execução:
|
|
7695
|
+
* liga o "manter tela ativa" do carregador e estica o tempo de tela, que cobre o adb por Wi-Fi na bateria.
|
|
7696
|
+
* Devolve a função que restaura o que o aparelho tinha antes.
|
|
7697
|
+
*/
|
|
7698
|
+
async keepAwake() {
|
|
7699
|
+
const read = async (ns, key) => {
|
|
7700
|
+
const v = (await this.shell(`settings get ${ns} ${key}`, { quiet: true }).catch(() => "")).trim();
|
|
7701
|
+
return /^\d+$/.test(v) ? v : void 0;
|
|
7702
|
+
};
|
|
7703
|
+
const stayOn = await read("global", "stay_on_while_plugged_in");
|
|
7704
|
+
const timeout = await read("system", "screen_off_timeout");
|
|
7705
|
+
await this.shell("svc power stayon true; settings put system screen_off_timeout 1800000; input keyevent 224", { quiet: true }).catch(() => void 0);
|
|
7706
|
+
return async () => {
|
|
7707
|
+
const cmds = [
|
|
7708
|
+
stayOn != null ? `settings put global stay_on_while_plugged_in ${stayOn}` : "svc power stayon false",
|
|
7709
|
+
timeout != null && `settings put system screen_off_timeout ${timeout}`
|
|
7710
|
+
].filter(Boolean);
|
|
7711
|
+
await this.shell(cmds.join("; "), { quiet: true }).catch(() => void 0);
|
|
7712
|
+
};
|
|
7713
|
+
}
|
|
7693
7714
|
/** Tamanho da tela como está agora (girada, a largura e a altura trocam). */
|
|
7694
7715
|
async screenSize() {
|
|
7695
7716
|
const out = await this.shell("dumpsys window displays 2>/dev/null | grep cur=; true", { quiet: true });
|
|
@@ -13013,7 +13034,9 @@ async function runFlow(opts) {
|
|
|
13013
13034
|
let status = "passed";
|
|
13014
13035
|
let error;
|
|
13015
13036
|
let gone = false;
|
|
13037
|
+
let restoreScreen;
|
|
13016
13038
|
try {
|
|
13039
|
+
restoreScreen = await opts.adb.keepAwake();
|
|
13017
13040
|
ctx.natural = await opts.adb.naturalSize();
|
|
13018
13041
|
ctx.screen = await opts.adb.screenSize();
|
|
13019
13042
|
log(ctx, "info", `tela ${ctx.screen.w}x${ctx.screen.h} \xB7 app ${ctx.appId ?? "(sem appId)"}`);
|
|
@@ -13037,6 +13060,7 @@ async function runFlow(opts) {
|
|
|
13037
13060
|
if (h.onFlowComplete?.length && status !== "stopped" && !gone && !partial) {
|
|
13038
13061
|
await runCommands(ctx, h.onFlowComplete, 1, "complete").catch(() => void 0);
|
|
13039
13062
|
}
|
|
13063
|
+
if (!gone) await restoreScreen?.();
|
|
13040
13064
|
}
|
|
13041
13065
|
if (status === "failed") {
|
|
13042
13066
|
log(ctx, "error", `falhou: ${error}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "e2e-box",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "End-to-end testing for native Android apps over adb, with Maestro-style YAML flows, a local dashboard with live device mirroring, a flow recorder and a CLI for CI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"android",
|