@silasfmartins/testhub 1.0.2 → 1.0.4
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.
|
@@ -172,9 +172,8 @@ export declare class WebActions {
|
|
|
172
172
|
}>;
|
|
173
173
|
/** Timestamp do último refreshDOM (debounce para evitar múltiplas chamadas consecutivas) */
|
|
174
174
|
private static _lastDOMRefreshTime;
|
|
175
|
-
/**
|
|
176
|
-
private static
|
|
177
|
-
private static readonly _maxRecoveryDepth;
|
|
175
|
+
/** Lock global: quando true, withRecovery executa fn direto sem entrar em recovery */
|
|
176
|
+
private static _inRecovery;
|
|
178
177
|
/**
|
|
179
178
|
* 🔄 Força atualização/estabilização do DOM antes de localizar/interagir com elementos.
|
|
180
179
|
* Essencial para SPAs (ex.: Salesforce Lightning/Vlocity) que recriam Shadow DOM a cada interação.
|
|
@@ -873,9 +873,8 @@ export class WebActions {
|
|
|
873
873
|
}
|
|
874
874
|
/** Timestamp do último refreshDOM (debounce para evitar múltiplas chamadas consecutivas) */
|
|
875
875
|
static _lastDOMRefreshTime = 0;
|
|
876
|
-
/**
|
|
877
|
-
static
|
|
878
|
-
static _maxRecoveryDepth = 1;
|
|
876
|
+
/** Lock global: quando true, withRecovery executa fn direto sem entrar em recovery */
|
|
877
|
+
static _inRecovery = false;
|
|
879
878
|
/**
|
|
880
879
|
* 🔄 Força atualização/estabilização do DOM antes de localizar/interagir com elementos.
|
|
881
880
|
* Essencial para SPAs (ex.: Salesforce Lightning/Vlocity) que recriam Shadow DOM a cada interação.
|
|
@@ -978,21 +977,15 @@ export class WebActions {
|
|
|
978
977
|
}
|
|
979
978
|
}
|
|
980
979
|
static async withRecovery(originalElement, actionName, fn, valueForContext) {
|
|
981
|
-
// 🛡️ Guard
|
|
982
|
-
//
|
|
983
|
-
|
|
984
|
-
if (WebActions._recoveryDepth >= WebActions._maxRecoveryDepth) {
|
|
980
|
+
// 🛡️ Guard: se já estiver em recovery, executar fn direto sem novo ciclo.
|
|
981
|
+
// Impede a cadeia click→recovery→click_other→click→recovery→click_other→... (stack overflow)
|
|
982
|
+
if (WebActions._inRecovery) {
|
|
985
983
|
const initialCandidate = await WebActions.resolveCandidateForRecovery(originalElement);
|
|
986
984
|
return await fn(initialCandidate);
|
|
987
985
|
}
|
|
988
986
|
// 🔄 Refresh DOM antes da primeira tentativa — garantir DOM fresco para SPAs/Shadow DOM
|
|
989
|
-
|
|
990
|
-
if (WebActions._recoveryDepth <= 0) {
|
|
991
|
-
await WebActions.refreshDOM(150).catch(() => { });
|
|
992
|
-
}
|
|
987
|
+
await WebActions.refreshDOM(150).catch(() => { });
|
|
993
988
|
// 🎯 Catalog pre-resolve + lazy auto-refresh (Item 18/20 v2.7.44)
|
|
994
|
-
// Se o target for texto/label (não XPath explícito), tentar resolver via catálogo local.
|
|
995
|
-
// Na primeira ação de cada URL, popular o catálogo automaticamente.
|
|
996
989
|
if (typeof originalElement === "string") {
|
|
997
990
|
try {
|
|
998
991
|
WebActions.ensureCatalogExtractor();
|
|
@@ -1011,20 +1004,16 @@ export class WebActions {
|
|
|
1011
1004
|
}
|
|
1012
1005
|
catch { }
|
|
1013
1006
|
}
|
|
1014
|
-
// 🛡️ Flag para rastrear se entramos no bloco de recovery (catch).
|
|
1015
|
-
// Sem essa flag, o finally decrementa _recoveryDepth mesmo em chamadas bem-sucedidas,
|
|
1016
|
-
// fazendo depth ficar negativo e desabilitando o guard de recursão em falhas futuras.
|
|
1017
|
-
let enteredRecovery = false;
|
|
1018
1007
|
try {
|
|
1019
1008
|
const initialCandidate = await WebActions.resolveCandidateForRecovery(originalElement);
|
|
1020
1009
|
return await fn(initialCandidate);
|
|
1021
1010
|
}
|
|
1022
1011
|
catch (error) {
|
|
1023
|
-
|
|
1024
|
-
// 🔄 Refresh DOM imediato após falha — capturar estado mais recente do Shadow DOM
|
|
1012
|
+
// 🔄 Refresh DOM imediato após falha
|
|
1025
1013
|
await WebActions.refreshDOM(200).catch(() => { });
|
|
1026
|
-
// 🛡️
|
|
1027
|
-
|
|
1014
|
+
// 🛡️ Ativar lock global — tudo que rodar a partir daqui (click_other, navigateTo, etc.)
|
|
1015
|
+
// vai cair no guard acima e executar fn direto, sem nova recovery.
|
|
1016
|
+
WebActions._inRecovery = true;
|
|
1028
1017
|
try {
|
|
1029
1018
|
const MIN_CONF = Number(process.env.AUTOCORE_RECOVERY_MIN_CONFIDENCE || "0.7");
|
|
1030
1019
|
const maxRetries = Number(process.env.AUTOCORE_RECOVERY_MAX_RETRIES || "8");
|
|
@@ -1353,12 +1342,8 @@ export class WebActions {
|
|
|
1353
1342
|
throw error;
|
|
1354
1343
|
}
|
|
1355
1344
|
finally {
|
|
1356
|
-
// 🛡️
|
|
1357
|
-
|
|
1358
|
-
// fazendo _recoveryDepth ficar negativo e desabilitando o guard de recursão.
|
|
1359
|
-
if (enteredRecovery) {
|
|
1360
|
-
WebActions._recoveryDepth--;
|
|
1361
|
-
}
|
|
1345
|
+
// 🛡️ Liberar lock — só quem ativou o lock pode desativar.
|
|
1346
|
+
WebActions._inRecovery = false;
|
|
1362
1347
|
}
|
|
1363
1348
|
}
|
|
1364
1349
|
// Helper genérico para tentar heurísticas de preenchimento/atribuição de valor
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silasfmartins/testhub",
|
|
3
3
|
"description": "Biblioteca de utilitários para automação de testes",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"author": "Silas Martins Feliciano da Silva <silas.martins2041@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|