@flowspec-qa/runner-core 0.5.5 → 0.6.1
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/discovery-report.d.ts.map +1 -1
- package/dist/discovery-report.js +9 -2
- package/dist/discovery-report.js.map +1 -1
- package/dist/evidence-types.d.ts +39 -0
- package/dist/evidence-types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/recorder-android.d.ts +61 -0
- package/dist/recorder-android.d.ts.map +1 -0
- package/dist/recorder-android.js +147 -0
- package/dist/recorder-android.js.map +1 -0
- package/dist/recorder-model.d.ts +128 -0
- package/dist/recorder-model.d.ts.map +1 -0
- package/dist/recorder-model.js +302 -0
- package/dist/recorder-model.js.map +1 -0
- package/dist/recorder-server.d.ts +36 -0
- package/dist/recorder-server.d.ts.map +1 -0
- package/dist/recorder-server.js +196 -0
- package/dist/recorder-server.js.map +1 -0
- package/dist/recorder-session.d.ts +133 -0
- package/dist/recorder-session.d.ts.map +1 -0
- package/dist/recorder-session.js +446 -0
- package/dist/recorder-session.js.map +1 -0
- package/dist/recorder-ui.d.ts +7 -0
- package/dist/recorder-ui.d.ts.map +1 -0
- package/dist/recorder-ui.js +427 -0
- package/dist/recorder-ui.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowSpec QA Studio — recorder GUI (single self-contained page, no CDN).
|
|
3
|
+
* Layout: device toolbar | device screen with object overlay | object spy,
|
|
4
|
+
* recorded steps and the Maestro script. Served by recorder-server.ts.
|
|
5
|
+
*/
|
|
6
|
+
export const STUDIO_HTML = String.raw `<!doctype html>
|
|
7
|
+
<html lang="es">
|
|
8
|
+
<head>
|
|
9
|
+
<meta charset="utf-8">
|
|
10
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
11
|
+
<title>FlowSpec QA Studio</title>
|
|
12
|
+
<style>
|
|
13
|
+
:root{--bg:#0f1420;--panel:#171e2e;--panel2:#1e2739;--line:#2a3550;--text:#e6ebf5;--muted:#8a96b0;--accent:#6c8cff;--ok:#36c08a;--warn:#f0b443;--err:#ef5e6b;--rec:#ff4d5e}
|
|
14
|
+
*{box-sizing:border-box}
|
|
15
|
+
html,body{margin:0;height:100%;background:var(--bg);color:var(--text);font:13px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif}
|
|
16
|
+
button{font:inherit;color:inherit;background:var(--panel2);border:1px solid var(--line);border-radius:7px;padding:7px 10px;cursor:pointer}
|
|
17
|
+
button:hover:not(:disabled){border-color:var(--accent)}
|
|
18
|
+
button:disabled{opacity:.45;cursor:default}
|
|
19
|
+
button.primary{background:var(--accent);border-color:var(--accent);color:#fff}
|
|
20
|
+
button.danger{border-color:var(--err);color:var(--err)}
|
|
21
|
+
input,select,textarea{font:inherit;color:var(--text);background:var(--bg);border:1px solid var(--line);border-radius:6px;padding:6px 8px;width:100%}
|
|
22
|
+
header{height:52px;display:flex;align-items:center;gap:14px;padding:0 16px;border-bottom:1px solid var(--line);background:var(--panel)}
|
|
23
|
+
header h1{font-size:15px;margin:0;font-weight:650;letter-spacing:.2px}
|
|
24
|
+
header .meta{color:var(--muted);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
25
|
+
header .spacer{flex:1}
|
|
26
|
+
.rec{display:inline-flex;align-items:center;gap:6px;color:var(--rec);font-weight:600}
|
|
27
|
+
.rec i{width:9px;height:9px;border-radius:50%;background:var(--rec);animation:blink 1.2s infinite}
|
|
28
|
+
.rec.off{color:var(--muted)}.rec.off i{background:var(--muted);animation:none}
|
|
29
|
+
@keyframes blink{50%{opacity:.25}}
|
|
30
|
+
main{display:grid;grid-template-columns:76px minmax(300px,1fr) 400px;height:calc(100% - 52px - 30px)}
|
|
31
|
+
.toolbar{border-right:1px solid var(--line);background:var(--panel);display:flex;flex-direction:column;align-items:center;gap:6px;padding:10px 6px;overflow:auto}
|
|
32
|
+
.toolbar .sep{width:70%;height:1px;background:var(--line);margin:6px 0}
|
|
33
|
+
.tool{width:62px;padding:7px 2px;display:flex;flex-direction:column;align-items:center;gap:2px;font-size:10.5px;color:var(--muted)}
|
|
34
|
+
.tool b{font-size:17px;color:var(--text);font-weight:400}
|
|
35
|
+
.tool.active{border-color:var(--accent);background:#25305a;color:var(--text)}
|
|
36
|
+
.live{width:62px;border:1px solid var(--line);border-radius:6px;margin-top:4px}
|
|
37
|
+
.live-label{font-size:10px;color:var(--muted);text-align:center}
|
|
38
|
+
.stage{display:flex;flex-direction:column;align-items:center;justify-content:flex-start;padding:14px;overflow:auto;position:relative}
|
|
39
|
+
.screenname{display:flex;gap:8px;align-items:center;margin-bottom:8px;max-width:420px;width:100%}
|
|
40
|
+
.screenname input{font-weight:600}
|
|
41
|
+
.device{position:relative;border:10px solid #05070c;border-radius:26px;box-shadow:0 10px 40px #0008;background:#000;line-height:0;user-select:none}
|
|
42
|
+
.device img{display:block;max-height:calc(100vh - 210px);max-width:100%;border-radius:14px;cursor:crosshair}
|
|
43
|
+
.overlay{position:absolute;inset:0;pointer-events:none}
|
|
44
|
+
.box{position:absolute;border:1.5px solid var(--accent);background:#6c8cff22;border-radius:3px}
|
|
45
|
+
.box.sel{border-color:var(--warn);background:#f0b44322}
|
|
46
|
+
.box.pending{border-color:var(--rec);background:#ff4d5e22}
|
|
47
|
+
.status{margin-top:10px;font-size:12px;color:var(--muted);min-height:18px;text-align:center}
|
|
48
|
+
.status.busy{color:var(--warn)}.status.ok{color:var(--ok)}.status.err{color:var(--err)}
|
|
49
|
+
.mask{position:absolute;inset:0;background:#0008;display:none;align-items:center;justify-content:center;border-radius:14px;color:#fff;font-size:14px;line-height:1.4}
|
|
50
|
+
.mask.on{display:flex}
|
|
51
|
+
aside{border-left:1px solid var(--line);background:var(--panel);display:flex;flex-direction:column;min-height:0}
|
|
52
|
+
section{border-bottom:1px solid var(--line);padding:12px 14px}
|
|
53
|
+
section h2{font-size:11px;text-transform:uppercase;letter-spacing:.8px;color:var(--muted);margin:0 0 8px;font-weight:650}
|
|
54
|
+
.props{display:grid;grid-template-columns:78px 1fr;gap:3px 8px;font-size:12px}
|
|
55
|
+
.props dt{color:var(--muted)}.props dd{margin:0;word-break:break-all;font-family:ui-monospace,Menlo,monospace;font-size:11.5px}
|
|
56
|
+
.actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
|
|
57
|
+
.warn{color:var(--warn);font-size:12px;margin-top:6px}
|
|
58
|
+
.typebox{margin-top:10px;display:none;gap:6px;flex-direction:column}
|
|
59
|
+
.typebox.on{display:flex}
|
|
60
|
+
.row{display:flex;gap:6px}
|
|
61
|
+
.steps{flex:1;overflow:auto;padding:6px 8px;min-height:200px}
|
|
62
|
+
.step{display:grid;grid-template-columns:22px 38px 1fr;gap:8px;align-items:center;padding:6px;border-radius:7px}
|
|
63
|
+
.step:hover{background:var(--panel2)}
|
|
64
|
+
.step .n{color:var(--muted);text-align:right;font-variant-numeric:tabular-nums}
|
|
65
|
+
.step img{width:38px;height:70px;object-fit:cover;border-radius:4px;border:1px solid var(--line);background:#000}
|
|
66
|
+
.step .noimg{width:38px;height:70px;border:1px dashed var(--line);border-radius:4px}
|
|
67
|
+
.step .t{font-size:12.5px}.step .s{font-size:11px;color:var(--muted)}
|
|
68
|
+
.step{grid-template-columns:22px 38px 1fr auto}
|
|
69
|
+
.step .x{font-size:11px;padding:3px 7px;opacity:.45;transition:opacity .15s}
|
|
70
|
+
.step:hover .x,.step.excluded .x{opacity:1}
|
|
71
|
+
.step.excluded .t,.step.excluded .s{text-decoration:line-through;color:var(--muted)}
|
|
72
|
+
.step.excluded img{opacity:.35}
|
|
73
|
+
.step .xnote{font-size:11px;color:var(--muted);margin-top:3px}
|
|
74
|
+
.badge{display:inline-block;font-size:10px;padding:1px 6px;border-radius:9px;background:var(--panel2);border:1px solid var(--line);margin-left:4px}
|
|
75
|
+
.b-new_screen{color:var(--ok)}.b-validation_state{color:var(--warn)}.b-no_observable_change{color:var(--muted)}.b-known_screen,.b-navigation_return{color:var(--accent)}
|
|
76
|
+
details{border-top:1px solid var(--line)}
|
|
77
|
+
summary{padding:9px 14px;cursor:pointer;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.8px}
|
|
78
|
+
pre{margin:0;padding:0 14px 12px;max-height:170px;overflow:auto;font:11.5px/1.5 ui-monospace,Menlo,monospace;color:#c9d4ee;white-space:pre}
|
|
79
|
+
footer{height:30px;display:flex;align-items:center;gap:16px;padding:0 14px;border-top:1px solid var(--line);background:var(--panel);font-size:11.5px;color:var(--muted)}
|
|
80
|
+
.modal{position:fixed;inset:0;background:#000a;display:none;align-items:center;justify-content:center;z-index:10}
|
|
81
|
+
.modal.on{display:flex}
|
|
82
|
+
.card{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:20px;width:min(560px,92vw);max-height:88vh;overflow:auto}
|
|
83
|
+
.card h3{margin:0 0 10px;font-size:16px}
|
|
84
|
+
.card p{color:var(--muted);margin:6px 0}
|
|
85
|
+
.card code{font-family:ui-monospace,Menlo,monospace;font-size:11.5px;color:var(--text);word-break:break-all}
|
|
86
|
+
.card .out{background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:8px;max-height:200px;overflow:auto;white-space:pre-wrap;font:11px/1.45 ui-monospace,Menlo,monospace}
|
|
87
|
+
label.chk{display:flex;gap:8px;align-items:center;margin:10px 0}
|
|
88
|
+
label.chk input{width:auto}
|
|
89
|
+
.help{font-size:12px;color:var(--muted)}
|
|
90
|
+
</style>
|
|
91
|
+
</head>
|
|
92
|
+
<body>
|
|
93
|
+
<header>
|
|
94
|
+
<h1>FlowSpec QA Studio</h1>
|
|
95
|
+
<span class="meta" id="meta"></span>
|
|
96
|
+
<span class="spacer"></span>
|
|
97
|
+
<span class="rec" id="rec"><i></i><span>Grabando</span></span>
|
|
98
|
+
<button class="primary" id="finishBtn">Finalizar grabación</button>
|
|
99
|
+
</header>
|
|
100
|
+
<main>
|
|
101
|
+
<div class="toolbar">
|
|
102
|
+
<button class="tool active" data-mode="record" title="Clic en la pantalla = tocar en el teléfono. Clic sobre un campo = escribir. Arrastrar = deslizar."><b>●</b>Grabar</button>
|
|
103
|
+
<button class="tool" data-mode="spy" title="Inspeccionar elementos sin tocar el teléfono"><b>⌖</b>Inspector</button>
|
|
104
|
+
<button class="tool" data-mode="check" title="Clic sobre un elemento para verificar su texto"><b>✓</b>Verificar</button>
|
|
105
|
+
<div class="sep"></div>
|
|
106
|
+
<button class="tool" id="backBtn" title="Botón Atrás de Android"><b>◁</b>Atrás</button>
|
|
107
|
+
<button class="tool" id="refreshBtn" title="Vuelve a leer la pantalla del teléfono"><b>⟳</b>Releer</button>
|
|
108
|
+
<button class="tool" id="manualBtn" title="Registra un paso que haces tú en el teléfono (OTP, huella)"><b>✋</b>Paso manual</button>
|
|
109
|
+
<div class="sep"></div>
|
|
110
|
+
<img class="live" id="live" alt="">
|
|
111
|
+
<div class="live-label">En vivo</div>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="stage">
|
|
114
|
+
<div class="screenname">
|
|
115
|
+
<input id="screenName" title="Nombre de la pantalla actual (puedes cambiarlo)">
|
|
116
|
+
<button id="renameBtn">Renombrar</button>
|
|
117
|
+
</div>
|
|
118
|
+
<div class="device" id="device">
|
|
119
|
+
<img id="frame" alt="Pantalla del dispositivo" draggable="false">
|
|
120
|
+
<div class="overlay" id="overlay"></div>
|
|
121
|
+
<div class="mask" id="mask">Guardando paso…</div>
|
|
122
|
+
</div>
|
|
123
|
+
<div class="status" id="status">Conectando…</div>
|
|
124
|
+
</div>
|
|
125
|
+
<aside>
|
|
126
|
+
<section>
|
|
127
|
+
<h2>Objeto seleccionado</h2>
|
|
128
|
+
<div id="spyEmpty" class="help">Pasa el mouse sobre la pantalla para ver los elementos. En modo Inspector, un clic muestra sus propiedades sin tocar el teléfono.</div>
|
|
129
|
+
<dl class="props" id="props" style="display:none"></dl>
|
|
130
|
+
<div class="warn" id="selWarn"></div>
|
|
131
|
+
<div class="actions" id="selActions" style="display:none">
|
|
132
|
+
<button id="aTap">Tocar</button>
|
|
133
|
+
<button id="aType">Escribir…</button>
|
|
134
|
+
<button id="aCheckText">Verificar texto</button>
|
|
135
|
+
<button id="aCheckVis">Verificar visible</button>
|
|
136
|
+
</div>
|
|
137
|
+
<div class="typebox" id="typebox">
|
|
138
|
+
<input id="typeValue" placeholder="Valor a escribir">
|
|
139
|
+
<div class="row">
|
|
140
|
+
<select id="typeKind">
|
|
141
|
+
<option value="">Dato de prueba (queda en el caso)</option>
|
|
142
|
+
<option value="APP_USERNAME">Usuario (variable APP_USERNAME)</option>
|
|
143
|
+
<option value="APP_PASSWORD">Contraseña (variable APP_PASSWORD)</option>
|
|
144
|
+
</select>
|
|
145
|
+
<button class="primary" id="typeGo">Escribir</button>
|
|
146
|
+
</div>
|
|
147
|
+
<div class="help">La contraseña se escribe en el teléfono pero se guarda como ***. Las credenciales quedan como variables, nunca como valor.</div>
|
|
148
|
+
</div>
|
|
149
|
+
</section>
|
|
150
|
+
<section style="padding-bottom:4px"><h2>Pasos grabados <span id="stepCount"></span></h2></section>
|
|
151
|
+
<div class="steps" id="steps"></div>
|
|
152
|
+
<details><summary>Script Maestro generado</summary><pre id="yaml"></pre></details>
|
|
153
|
+
</aside>
|
|
154
|
+
</main>
|
|
155
|
+
<footer><span id="footDevice"></span><span id="footScreen"></span><span id="footVars"></span></footer>
|
|
156
|
+
|
|
157
|
+
<div class="modal" id="finishModal"><div class="card" id="finishCard"></div></div>
|
|
158
|
+
|
|
159
|
+
<script>
|
|
160
|
+
(() => {
|
|
161
|
+
const K = new URLSearchParams(location.search).get('k') || '';
|
|
162
|
+
const $ = (id) => document.getElementById(id);
|
|
163
|
+
const api = async (path, body) => {
|
|
164
|
+
const res = await fetch(path, body === undefined ? { headers: { 'x-studio-token': K } } : {
|
|
165
|
+
method: 'POST', headers: { 'content-type': 'application/json', 'x-studio-token': K }, body: JSON.stringify(body),
|
|
166
|
+
});
|
|
167
|
+
const data = await res.json().catch(() => ({}));
|
|
168
|
+
if (!res.ok) throw new Error(data.error || ('HTTP ' + res.status));
|
|
169
|
+
return data;
|
|
170
|
+
};
|
|
171
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
172
|
+
|
|
173
|
+
let S = null; // last state
|
|
174
|
+
let mode = 'record';
|
|
175
|
+
let selected = null; // { selector, x, y }
|
|
176
|
+
let busy = false;
|
|
177
|
+
let frameVer = 0;
|
|
178
|
+
|
|
179
|
+
const frame = $('frame'), overlay = $('overlay');
|
|
180
|
+
|
|
181
|
+
function setStatus(text, cls) { const el = $('status'); el.textContent = text; el.className = 'status ' + (cls || ''); }
|
|
182
|
+
function setBusy(on, text) {
|
|
183
|
+
busy = on; $('mask').classList.toggle('on', on); $('mask').textContent = text || 'Guardando paso…';
|
|
184
|
+
document.querySelectorAll('#backBtn,#refreshBtn,#manualBtn,#finishBtn,#selActions button,#typeGo').forEach(b => b.disabled = on);
|
|
185
|
+
if (on) setStatus(text || 'Guardando paso…', 'busy');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// device pixels ↔ image pixels
|
|
189
|
+
const scale = () => frame.naturalWidth ? frame.clientWidth / frame.naturalWidth : 1;
|
|
190
|
+
function toDevice(ev) {
|
|
191
|
+
const r = frame.getBoundingClientRect(); const s = scale();
|
|
192
|
+
return { x: Math.round((ev.clientX - r.left) / s), y: Math.round((ev.clientY - r.top) / s) };
|
|
193
|
+
}
|
|
194
|
+
function boxAt(p) {
|
|
195
|
+
if (!S || !S.current) return null;
|
|
196
|
+
let best = null;
|
|
197
|
+
for (const b of S.current.boxes) {
|
|
198
|
+
const B = b.bounds;
|
|
199
|
+
if (p.x >= B.x1 && p.x < B.x2 && p.y >= B.y1 && p.y < B.y2) {
|
|
200
|
+
const a = (B.x2 - B.x1) * (B.y2 - B.y1);
|
|
201
|
+
if (!best || a <= best.a) best = { b, a };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return best && best.b;
|
|
205
|
+
}
|
|
206
|
+
function drawBox(bounds, cls) {
|
|
207
|
+
const s = scale(); const d = document.createElement('div');
|
|
208
|
+
d.className = 'box ' + (cls || '');
|
|
209
|
+
// the img sits inside the device border; overlay is aligned to the img box
|
|
210
|
+
d.style.left = (bounds.x1 * s) + 'px'; d.style.top = (bounds.y1 * s) + 'px';
|
|
211
|
+
d.style.width = ((bounds.x2 - bounds.x1) * s) + 'px'; d.style.height = ((bounds.y2 - bounds.y1) * s) + 'px';
|
|
212
|
+
overlay.appendChild(d);
|
|
213
|
+
}
|
|
214
|
+
let hoverBox = null;
|
|
215
|
+
function redraw() {
|
|
216
|
+
overlay.innerHTML = '';
|
|
217
|
+
overlay.style.width = frame.clientWidth + 'px'; overlay.style.height = frame.clientHeight + 'px';
|
|
218
|
+
if (selected) drawBox(selected.selector.bounds, 'sel');
|
|
219
|
+
if (hoverBox && (!selected || hoverBox.bounds !== selected.selector.bounds)) drawBox(hoverBox.bounds);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function showSelector(sel, p) {
|
|
223
|
+
selected = sel ? { selector: sel, x: p.x, y: p.y } : null;
|
|
224
|
+
$('typebox').classList.remove('on');
|
|
225
|
+
if (!sel) { $('props').style.display = 'none'; $('selActions').style.display = 'none'; $('spyEmpty').style.display = ''; $('selWarn').textContent = ''; redraw(); return; }
|
|
226
|
+
$('spyEmpty').style.display = 'none';
|
|
227
|
+
const B = sel.bounds;
|
|
228
|
+
const maestro = sel.kind === 'id' ? 'id: "' + sel.elementId + '"' : sel.kind === 'text' ? 'text: "' + sel.elementId.slice(5) + '"' : 'point: "' + sel.elementId.slice(6) + '"';
|
|
229
|
+
$('props').innerHTML = [
|
|
230
|
+
['Selector', maestro + (sel.index > 0 ? ' · index ' + sel.index : '')],
|
|
231
|
+
['Texto', sel.label === sel.elementId ? '—' : sel.label], ['Clase', sel.className || '—'],
|
|
232
|
+
['Tipo', sel.isPassword ? 'Contraseña' : sel.isEditable ? 'Campo editable' : 'Elemento'],
|
|
233
|
+
['Bounds', '[' + B.x1 + ',' + B.y1 + '][' + B.x2 + ',' + B.y2 + ']'],
|
|
234
|
+
].map(([k, v]) => '<dt>' + k + '</dt><dd>' + esc(v) + '</dd>').join('');
|
|
235
|
+
$('props').style.display = '';
|
|
236
|
+
$('selWarn').textContent = sel.warning || '';
|
|
237
|
+
$('selActions').style.display = 'flex';
|
|
238
|
+
$('aType').style.display = sel.isEditable ? '' : 'none';
|
|
239
|
+
if (sel.isEditable && mode === 'record') openType();
|
|
240
|
+
redraw();
|
|
241
|
+
}
|
|
242
|
+
function openType() {
|
|
243
|
+
if (!selected) return;
|
|
244
|
+
$('typebox').classList.add('on');
|
|
245
|
+
const pw = selected.selector.isPassword;
|
|
246
|
+
$('typeValue').type = pw ? 'password' : 'text'; $('typeValue').value = '';
|
|
247
|
+
$('typeKind').value = pw ? 'APP_PASSWORD' : '';
|
|
248
|
+
$('typeValue').focus();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function render() {
|
|
252
|
+
if (!S) return;
|
|
253
|
+
const m = S.meta;
|
|
254
|
+
$('meta').textContent = m.appId + (m.entityId ? ' · ' + m.entityId : '') + ' · ' + m.platform + ' ' + m.deviceId;
|
|
255
|
+
$('footDevice').textContent = 'Dispositivo: ' + m.deviceId;
|
|
256
|
+
$('footScreen').textContent = S.current ? 'Pantalla: ' + S.current.screenName + ' (' + S.current.boxes.length + ' objetos)' : '';
|
|
257
|
+
$('footVars').textContent = S.variables.length ? 'Variables: ' + S.variables.join(', ') : '';
|
|
258
|
+
if (S.current && document.activeElement !== $('screenName')) $('screenName').value = S.current.screenName;
|
|
259
|
+
$('stepCount').textContent = '(' + S.steps.length + ')';
|
|
260
|
+
$('steps').innerHTML = S.steps.slice().reverse().map(st => {
|
|
261
|
+
const img = st.evidenceId && st.kind !== 'checkpoint'
|
|
262
|
+
? '<img loading="lazy" src="/api/evidence/' + st.evidenceId + '/after.png?k=' + encodeURIComponent(K) + '">' : '<div class="noimg"></div>';
|
|
263
|
+
const badge = st.result ? '<span class="badge b-' + esc(st.result) + '">' + esc(st.result) + '</span>' : '';
|
|
264
|
+
const canEdit = !S.finished && st.kind !== 'launch';
|
|
265
|
+
const btn = canEdit ? '<button class="x" data-n="' + st.n + '" data-ex="' + (st.excluded ? '0' : '1') + '" title="' +
|
|
266
|
+
(st.excluded ? 'Volver a incluir este paso en el flujo' : 'Sacar este paso del flujo (la evidencia se conserva)') + '">' +
|
|
267
|
+
(st.excluded ? 'Restaurar' : 'Excluir') + '</button>' : '<span></span>';
|
|
268
|
+
return '<div class="step' + (st.excluded ? ' excluded' : '') + '"><span class="n">' + st.n + '</span>' + img + '<div><div class="t">' + esc(st.label) + badge + '</div>' +
|
|
269
|
+
'<div class="s">' + esc(st.evidenceId || 'sin evidencia') + (st.screen ? ' → ' + esc(st.screen) : '') + '</div>' +
|
|
270
|
+
(st.excluded ? '<div class="xnote">Excluido del flujo · evidencia conservada</div>' : st.warning ? '<div class="warn">⚠ ' + esc(st.warning) + '</div>' : '') + '</div>' + btn + '</div>';
|
|
271
|
+
}).join('');
|
|
272
|
+
$('yaml').textContent = S.yaml;
|
|
273
|
+
$('rec').classList.toggle('off', !!S.finished);
|
|
274
|
+
$('rec').lastElementChild.textContent = S.finished ? 'Grabación terminada' : 'Grabando';
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
$('steps').addEventListener('click', async (ev) => {
|
|
278
|
+
const b = ev.target.closest('button.x');
|
|
279
|
+
if (!b || busy) return;
|
|
280
|
+
const n = Number(b.dataset.n), excluded = b.dataset.ex === '1';
|
|
281
|
+
try {
|
|
282
|
+
let r = await api('/api/exclude', { n, excluded });
|
|
283
|
+
if (r.needsConfirm) {
|
|
284
|
+
if (!confirm(r.message + '\n\n¿Excluirlo de todos modos?')) return;
|
|
285
|
+
r = await api('/api/exclude', { n, excluded, confirm: true });
|
|
286
|
+
}
|
|
287
|
+
await refreshState(false);
|
|
288
|
+
setStatus(excluded ? '✓ Paso ' + n + ' excluido del flujo (su evidencia se conserva)' : '✓ Paso ' + n + ' vuelve al flujo', 'ok');
|
|
289
|
+
} catch (e) { setStatus('✗ ' + e.message, 'err'); }
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
async function refreshState(newFrame) {
|
|
293
|
+
S = await api('/api/state');
|
|
294
|
+
if (newFrame) { frameVer++; frame.src = '/api/frame.png?k=' + encodeURIComponent(K) + '&v=' + frameVer; }
|
|
295
|
+
render();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async function act(path, body, text) {
|
|
299
|
+
if (busy) return;
|
|
300
|
+
setBusy(true, text);
|
|
301
|
+
try {
|
|
302
|
+
const r = await api(path, body);
|
|
303
|
+
showSelector(null);
|
|
304
|
+
await refreshState(true);
|
|
305
|
+
const st = r.step;
|
|
306
|
+
setStatus(st ? '✓ ' + st.label + (st.result ? ' · ' + st.result : '') + ' — listo para el siguiente paso' : '✓ Listo', 'ok');
|
|
307
|
+
} catch (e) { setStatus('✗ ' + e.message, 'err'); await refreshState(true).catch(() => {}); }
|
|
308
|
+
finally { setBusy(false); }
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// ── Mouse on the device ──
|
|
312
|
+
let down = null;
|
|
313
|
+
frame.addEventListener('mousedown', (ev) => { if (ev.button === 0) down = toDevice(ev); });
|
|
314
|
+
frame.addEventListener('mousemove', (ev) => {
|
|
315
|
+
if (busy) return;
|
|
316
|
+
const p = toDevice(ev); hoverBox = boxAt(p); redraw();
|
|
317
|
+
});
|
|
318
|
+
frame.addEventListener('mouseleave', () => { hoverBox = null; redraw(); });
|
|
319
|
+
frame.addEventListener('mouseup', async (ev) => {
|
|
320
|
+
if (busy || !down) return;
|
|
321
|
+
const up = toDevice(ev); const from = down; down = null;
|
|
322
|
+
const dist = Math.hypot(up.x - from.x, up.y - from.y);
|
|
323
|
+
if (mode === 'record' && dist > 40) return act('/api/swipe', { from, to: up }, 'Deslizando…');
|
|
324
|
+
let r;
|
|
325
|
+
try { r = await api('/api/inspect', up); } catch (e) { return setStatus('✗ ' + e.message, 'err'); }
|
|
326
|
+
if (!r.selector) { showSelector(null); return setStatus('No hay un elemento en ese punto.', 'err'); }
|
|
327
|
+
if (mode === 'spy') { showSelector(r.selector, up); return setStatus('Inspector: propiedades del objeto (no se tocó el teléfono).'); }
|
|
328
|
+
if (mode === 'check') {
|
|
329
|
+
showSelector(r.selector, up);
|
|
330
|
+
const withText = r.selector.kind !== 'point' && r.selector.label && r.selector.label !== r.selector.elementId;
|
|
331
|
+
return act('/api/checkpoint', { x: up.x, y: up.y, withText }, 'Guardando verificación…');
|
|
332
|
+
}
|
|
333
|
+
if (r.selector.isEditable) { showSelector(r.selector, up); return setStatus('Escribe el valor para "' + r.selector.label + '" y presiona Enter.'); }
|
|
334
|
+
act('/api/tap', up, 'Tocando "' + r.selector.label + '"…');
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// ── Panel actions ──
|
|
338
|
+
document.querySelectorAll('[data-mode]').forEach(b => b.addEventListener('click', () => {
|
|
339
|
+
mode = b.dataset.mode;
|
|
340
|
+
document.querySelectorAll('[data-mode]').forEach(x => x.classList.toggle('active', x === b));
|
|
341
|
+
setStatus(mode === 'record' ? 'Grabar: clic = tocar · clic en un campo = escribir · arrastrar = deslizar'
|
|
342
|
+
: mode === 'spy' ? 'Inspector: clic para ver las propiedades de un objeto' : 'Verificar: clic sobre el texto que debe comprobar el caso');
|
|
343
|
+
}));
|
|
344
|
+
$('aTap').onclick = () => selected && act('/api/tap', { x: selected.x, y: selected.y }, 'Tocando…');
|
|
345
|
+
$('aType').onclick = openType;
|
|
346
|
+
$('aCheckText').onclick = () => selected && act('/api/checkpoint', { x: selected.x, y: selected.y, withText: true }, 'Guardando verificación…');
|
|
347
|
+
$('aCheckVis').onclick = () => selected && act('/api/checkpoint', { x: selected.x, y: selected.y, withText: false }, 'Guardando verificación…');
|
|
348
|
+
const doType = () => {
|
|
349
|
+
if (!selected) return;
|
|
350
|
+
const value = $('typeValue').value; if (!value) return;
|
|
351
|
+
const variable = $('typeKind').value || undefined;
|
|
352
|
+
$('typeValue').value = '';
|
|
353
|
+
act('/api/input', { x: selected.x, y: selected.y, value, variable }, 'Escribiendo…');
|
|
354
|
+
};
|
|
355
|
+
$('typeGo').onclick = doType;
|
|
356
|
+
$('typeValue').addEventListener('keydown', (e) => { if (e.key === 'Enter') doType(); });
|
|
357
|
+
$('backBtn').onclick = () => act('/api/back', {}, 'Volviendo…');
|
|
358
|
+
$('refreshBtn').onclick = () => act('/api/refresh', {}, 'Leyendo la pantalla…');
|
|
359
|
+
$('manualBtn').onclick = () => {
|
|
360
|
+
const note = prompt('Describe el paso que harás en el teléfono (ej.: "Ingresar OTP"). Hazlo y luego acepta.');
|
|
361
|
+
if (note !== null) act('/api/refresh', { note: note || 'Paso manual en el teléfono' }, 'Leyendo la pantalla…');
|
|
362
|
+
};
|
|
363
|
+
$('renameBtn').onclick = async () => { await api('/api/rename', { name: $('screenName').value }); await refreshState(false); setStatus('Pantalla renombrada.', 'ok'); };
|
|
364
|
+
|
|
365
|
+
// ── Finish / replay ──
|
|
366
|
+
const card = $('finishCard');
|
|
367
|
+
function finishForm() {
|
|
368
|
+
const canSync = !!(S.meta.projectId && S.meta.entityId);
|
|
369
|
+
card.innerHTML = '<h3>Finalizar grabación</h3><p>' + S.steps.length + ' pasos grabados. Se guardan la evidencia, el reporte HTML y el flujo Maestro en la carpeta de trabajo.</p>' +
|
|
370
|
+
(canSync ? '<label class="chk"><input type="checkbox" id="doSync" checked> Sincronizar con FlowSpec QA (proyecto y entidad indicados)</label>'
|
|
371
|
+
: '<p class="help">Sin --project y --entity: queda solo en local.</p>') +
|
|
372
|
+
'<div class="row" style="justify-content:flex-end;margin-top:14px"><button id="fCancel">Seguir grabando</button><button class="primary" id="fGo">Finalizar</button></div>';
|
|
373
|
+
$('fCancel').onclick = () => $('finishModal').classList.remove('on');
|
|
374
|
+
$('fGo').onclick = async () => {
|
|
375
|
+
$('fGo').disabled = true; $('fGo').textContent = 'Generando…';
|
|
376
|
+
try {
|
|
377
|
+
const sync = canSync && $('doSync').checked;
|
|
378
|
+
const r = await api('/api/finish', { sync });
|
|
379
|
+
await refreshState(false); doneView(r);
|
|
380
|
+
} catch (e) { card.insertAdjacentHTML('beforeend', '<p class="warn">✗ ' + esc(e.message) + '</p>'); $('fGo').disabled = false; $('fGo').textContent = 'Finalizar'; }
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function doneView(r) {
|
|
384
|
+
const line = (k, v) => v ? '<p>' + k + ': <code>' + esc(v) + '</code></p>' : '';
|
|
385
|
+
const vars = S.variables;
|
|
386
|
+
card.innerHTML = '<h3>✓ Grabación guardada</h3>' + line('Carpeta', r.outputDir) + line('Reporte', r.reportPath) + line('Flujo Maestro', r.flowPath) + line('Variables', r.envExamplePath) +
|
|
387
|
+
(r.synced ? '<p style="color:var(--ok)">Sincronizado con FlowSpec QA.</p>' : r.syncError ? '<p class="warn">No sincronizado: ' + esc(r.syncError) + '</p>' : '') +
|
|
388
|
+
'<h3 style="margin-top:16px">Reproducir el flujo</h3><p class="help">Ejecuta el flujo grabado con Maestro en el mismo teléfono para comprobar que es automatizable. ' +
|
|
389
|
+
(vars.length ? 'Las credenciales se usan solo para esta ejecución y no se guardan.' : '') + '</p>' +
|
|
390
|
+
vars.map(v => '<label class="help" style="display:block;margin-top:8px">' + (v === 'APP_PASSWORD' ? 'Contraseña de prueba' : 'Usuario de prueba') + ' (' + v + ', obligatoria)</label>' +
|
|
391
|
+
'<input id="env_' + v + '" type="' + (v === 'APP_PASSWORD' ? 'password' : 'text') + '" placeholder="' + v + '" autocomplete="off">').join('') +
|
|
392
|
+
'<div class="out" id="replayOut" style="display:none;margin-top:8px"></div>' +
|
|
393
|
+
'<div class="row" style="justify-content:flex-end;margin-top:14px"><button id="rClose">Cerrar</button><button id="rQuit" class="danger">Cerrar Studio</button><button class="primary" id="rGo">Reproducir</button></div>';
|
|
394
|
+
$('rClose').onclick = () => $('finishModal').classList.remove('on');
|
|
395
|
+
$('rQuit').onclick = async () => { await api('/api/quit', {}).catch(() => {}); document.body.innerHTML = '<p style="padding:40px">Studio cerrado. Puedes cerrar esta pestaña.</p>'; };
|
|
396
|
+
$('rGo').onclick = async () => {
|
|
397
|
+
const env = {}; vars.forEach(v => { env[v] = $('env_' + v).value; });
|
|
398
|
+
const out = $('replayOut');
|
|
399
|
+
const missing = vars.filter(v => !env[v]);
|
|
400
|
+
if (missing.length) {
|
|
401
|
+
out.style.display = ''; out.textContent = '✗ Falta ' + missing.join(' y ') + '. El flujo la usa: escríbela antes de reproducir (no se guarda).';
|
|
402
|
+
$('env_' + missing[0]).focus();
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
$('rGo').disabled = true; $('rGo').textContent = 'Reproduciendo…';
|
|
406
|
+
out.style.display = ''; out.textContent = 'Ejecutando Maestro…';
|
|
407
|
+
try { const rr = await api('/api/replay', { env }); out.textContent = (rr.ok ? '✓ PASÓ\n\n' : '✗ FALLÓ\n\n') + rr.output; }
|
|
408
|
+
catch (e) { out.textContent = '✗ ' + e.message; }
|
|
409
|
+
vars.forEach(v => { $('env_' + v).value = ''; });
|
|
410
|
+
$('rGo').disabled = false; $('rGo').textContent = 'Reproducir';
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
$('finishBtn').onclick = () => { if (S.finished) doneView(S.finished); else finishForm(); $('finishModal').classList.add('on'); };
|
|
414
|
+
|
|
415
|
+
// ── Live mirror (small) ──
|
|
416
|
+
let liveVer = 0;
|
|
417
|
+
setInterval(() => { if (!busy && !document.hidden) $('live').src = '/api/live.png?k=' + encodeURIComponent(K) + '&v=' + (++liveVer); }, 2000);
|
|
418
|
+
|
|
419
|
+
frame.addEventListener('load', redraw);
|
|
420
|
+
window.addEventListener('resize', redraw);
|
|
421
|
+
refreshState(true).then(() => setStatus('✓ Listo. Haz clic en la pantalla para grabar el primer paso.', 'ok'))
|
|
422
|
+
.catch(e => setStatus('✗ ' + e.message, 'err'));
|
|
423
|
+
})();
|
|
424
|
+
</script>
|
|
425
|
+
</body>
|
|
426
|
+
</html>`;
|
|
427
|
+
//# sourceMappingURL=recorder-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recorder-ui.js","sourceRoot":"","sources":["../src/recorder-ui.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAoa7B,CAAC"}
|