@testver/testver 1.3.0 → 1.3.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/index.js
CHANGED
|
@@ -25431,6 +25431,12 @@ function reEsc(s) {
|
|
|
25431
25431
|
function escFor(v, quote) {
|
|
25432
25432
|
return v.replace(/\\/g, "\\\\").split(quote).join("\\" + quote);
|
|
25433
25433
|
}
|
|
25434
|
+
function jsLiteral(v) {
|
|
25435
|
+
if (!v.includes("'")) return `'${escFor(v, "'")}'`;
|
|
25436
|
+
if (!v.includes('"')) return `"${escFor(v, '"')}"`;
|
|
25437
|
+
if (!v.includes("`") && !v.includes("${")) return `\`${escFor(v, "`")}\``;
|
|
25438
|
+
return `'${escFor(v, "'")}'`;
|
|
25439
|
+
}
|
|
25434
25440
|
function quotedForms(prefixes, value, label4, suffix = "", holds2) {
|
|
25435
25441
|
const out = [];
|
|
25436
25442
|
for (const q6 of QUOTES2) {
|
|
@@ -25768,8 +25774,12 @@ function renderSite(site, newValue) {
|
|
|
25768
25774
|
for (const e of edits) out = out.slice(0, e.start) + e.text + out.slice(e.end);
|
|
25769
25775
|
return out;
|
|
25770
25776
|
}
|
|
25777
|
+
const s = site.find;
|
|
25778
|
+
if (site.encode !== "xml" && site.quoted && site.quote === "'" && newValue.includes("'") && !newValue.includes('"') && s[site.valueStart - 1] === "'" && s[site.valueEnd] === "'") {
|
|
25779
|
+
return `${s.slice(0, site.valueStart - 1)}"${escFor(newValue, '"')}"${s.slice(site.valueEnd + 1)}`;
|
|
25780
|
+
}
|
|
25771
25781
|
const v = site.encode === "xml" ? xmlEsc(newValue) : site.quoted ? escFor(newValue, site.quote) : newValue;
|
|
25772
|
-
return
|
|
25782
|
+
return s.slice(0, site.valueStart) + v + s.slice(site.valueEnd);
|
|
25773
25783
|
}
|
|
25774
25784
|
function androidIdName(raw) {
|
|
25775
25785
|
return /^[\w.]+:id\/(.+)$/.exec(raw)?.[1];
|
|
@@ -25787,7 +25797,7 @@ function replacementFor(site, b, p2) {
|
|
|
25787
25797
|
const close = site.find.indexOf(")", site.valueEnd);
|
|
25788
25798
|
const callStart = site.find.lastIndexOf("getByTestId");
|
|
25789
25799
|
if (callStart >= 0 && close >= 0) {
|
|
25790
|
-
return site.find.slice(0, callStart) + `locator(
|
|
25800
|
+
return site.find.slice(0, callStart) + `locator(${jsLiteral(p2.value)})` + site.find.slice(close + 1);
|
|
25791
25801
|
}
|
|
25792
25802
|
}
|
|
25793
25803
|
if (b.strategy === "css" && b.kind === "testid" && p2.valueIsName && b.hint) {
|
|
@@ -25863,6 +25873,9 @@ function renameMatch(oldValue, candidates, codeLine) {
|
|
|
25863
25873
|
const same4 = pool.filter((v) => hashStem(v) === stem3);
|
|
25864
25874
|
if (same4.length === 1) return { value: same4[0], score: 0.9, via: "rename" };
|
|
25865
25875
|
}
|
|
25876
|
+
const ws = wrapperSibling(oldValue, pool);
|
|
25877
|
+
if (ws === "ambiguous") return null;
|
|
25878
|
+
if (ws) return { value: ws, score: 0.85, via: "rename" };
|
|
25866
25879
|
const a = oldValue.toLowerCase();
|
|
25867
25880
|
const scored = pool.map((v) => ({ v, score: idSimilarity(a, v.toLowerCase()) })).filter((s) => s.score >= 0.55).sort((x, y) => y.score - x.score);
|
|
25868
25881
|
if (scored.length > 0) {
|
|
@@ -25889,6 +25902,23 @@ function renameMatch(oldValue, candidates, codeLine) {
|
|
|
25889
25902
|
}
|
|
25890
25903
|
return null;
|
|
25891
25904
|
}
|
|
25905
|
+
function wrapperSibling(oldValue, pool) {
|
|
25906
|
+
const cut = Math.max(oldValue.lastIndexOf("-"), oldValue.lastIndexOf("_"));
|
|
25907
|
+
if (cut <= 0 || cut === oldValue.length - 1) return null;
|
|
25908
|
+
const stem3 = oldValue.slice(0, cut), sep9 = oldValue[cut], word = oldValue.slice(cut + 1);
|
|
25909
|
+
if (stem3.length < 3 || /[-_]/.test(word) || !pool.includes(stem3)) return null;
|
|
25910
|
+
const set = new Set(pool);
|
|
25911
|
+
const winners = [];
|
|
25912
|
+
for (const v of pool) {
|
|
25913
|
+
if (!v.startsWith(stem3 + sep9)) continue;
|
|
25914
|
+
const w2 = v.slice(stem3.length + 1);
|
|
25915
|
+
if (!w2 || w2 === word || /[-_]/.test(w2)) continue;
|
|
25916
|
+
const repeated = pool.some((x) => x !== stem3 && !x.endsWith(sep9 + w2) && set.has(`${x}${sep9}${w2}`));
|
|
25917
|
+
if (repeated) winners.push(v);
|
|
25918
|
+
}
|
|
25919
|
+
if (winners.length === 0) return null;
|
|
25920
|
+
return winners.length === 1 ? winners[0] : "ambiguous";
|
|
25921
|
+
}
|
|
25892
25922
|
function jaccard(a, b) {
|
|
25893
25923
|
let inter = 0;
|
|
25894
25924
|
for (const t of a) if (b.has(t)) inter++;
|
|
@@ -26162,6 +26192,7 @@ function tierTemplateFamily(broken, elements) {
|
|
|
26162
26192
|
if (j < 0) continue;
|
|
26163
26193
|
const a2 = c2.slice(0, j), b2 = c2.slice(j + dyn.length);
|
|
26164
26194
|
if (a2 === a && b2 === b) continue;
|
|
26195
|
+
if (a2 === "" && b2 === "") continue;
|
|
26165
26196
|
const key2 = `${a2}\0${b2}`;
|
|
26166
26197
|
if (families.has(key2)) continue;
|
|
26167
26198
|
const re = new RegExp(`^${esc2(a2)}(.+)${esc2(b2)}$`);
|
|
@@ -26206,7 +26237,7 @@ function deterministicFromElements(broken, elements, codeLine) {
|
|
|
26206
26237
|
return null;
|
|
26207
26238
|
}
|
|
26208
26239
|
}
|
|
26209
|
-
function tierRecordedFallback(broken, entries, elements) {
|
|
26240
|
+
function tierRecordedFallback(broken, entries, elements, take) {
|
|
26210
26241
|
const matchesBroken = (l) => {
|
|
26211
26242
|
const v = String(l.value || "");
|
|
26212
26243
|
if (!v) return false;
|
|
@@ -26219,21 +26250,30 @@ function tierRecordedFallback(broken, entries, elements) {
|
|
|
26219
26250
|
const locs = (entry2.locators ?? []).filter((l) => l.value);
|
|
26220
26251
|
if (!locs.some(matchesBroken)) continue;
|
|
26221
26252
|
const alternatives = locs.filter((l) => !matchesBroken(l)).sort((a, b) => (b.confidence ?? 0) - (a.confidence ?? 0));
|
|
26253
|
+
const reanchor = broken.method === "getByTestId";
|
|
26222
26254
|
for (const alt of alternatives) {
|
|
26223
|
-
const value = mapToStrategy(broken, String(alt.strategy || ""), String(alt.value));
|
|
26255
|
+
const value = reanchor ? mapToLocator(String(alt.strategy || ""), String(alt.value)) : mapToStrategy(broken, String(alt.strategy || ""), String(alt.value));
|
|
26224
26256
|
if (!value) continue;
|
|
26225
26257
|
if (elements.length > 0 && !evidenceSupports(value, broken, elements)) continue;
|
|
26226
|
-
|
|
26258
|
+
const prop = {
|
|
26227
26259
|
value,
|
|
26228
26260
|
valueIsName: broken.strategy === "id" || broken.strategy === "name" || broken.strategy === "accessibility-id",
|
|
26261
|
+
...reanchor ? { reanchor: true } : {},
|
|
26229
26262
|
source: "recorded-fallback",
|
|
26230
26263
|
confidence: Math.min(0.9, alt.confidence ?? 0.7),
|
|
26231
26264
|
rationale: `The recorder saved "${alt.value}" as the next-best locator for this step${entry2.description ? ` (${entry2.description})` : ""}${elements.length ? ", and it matches an element on the page" : ""}.`
|
|
26232
26265
|
};
|
|
26266
|
+
if (!take || take(prop)) return prop;
|
|
26233
26267
|
}
|
|
26234
26268
|
}
|
|
26235
26269
|
return null;
|
|
26236
26270
|
}
|
|
26271
|
+
function mapToLocator(altStrategy, altValue) {
|
|
26272
|
+
const s = altStrategy.toLowerCase();
|
|
26273
|
+
if (s === "css") return altValue;
|
|
26274
|
+
if (s === "xpath" && /^(?:\(|\.?\/)/.test(altValue)) return altValue;
|
|
26275
|
+
return null;
|
|
26276
|
+
}
|
|
26237
26277
|
function mapToStrategy(broken, altStrategy, altValue) {
|
|
26238
26278
|
const s = altStrategy.toLowerCase();
|
|
26239
26279
|
switch (broken.strategy) {
|
|
@@ -26727,6 +26767,19 @@ var init_failure_analyzer = __esm({
|
|
|
26727
26767
|
\u2022 Scroll it into view, or use { force: true } only when the cover is expected`
|
|
26728
26768
|
};
|
|
26729
26769
|
}
|
|
26770
|
+
if (/locator resolved to/i.test(lower) && /intercepts pointer events|element is not enabled|element is not editable/i.test(lower)) {
|
|
26771
|
+
const covered = /intercepts pointer events/i.test(lower);
|
|
26772
|
+
return {
|
|
26773
|
+
category: "test-issue",
|
|
26774
|
+
signal: "element-interaction",
|
|
26775
|
+
rootCause: covered ? "The element was found, but another element on top of it (an overlay, modal, cookie banner or sticky header) took every click." : "The element was found, but it stayed disabled (or read-only) for the whole wait, so the action never happened.",
|
|
26776
|
+
suggestedFix: covered ? `\u2022 Close or wait out the overlay / modal / banner covering it
|
|
26777
|
+
\u2022 Wait for the page to finish what opened it (an animation, a loading state)
|
|
26778
|
+
\u2022 Use { force: true } only when the cover is expected and harmless` : `\u2022 Do what enables it first (fill the required fields, accept the terms\u2026)
|
|
26779
|
+
\u2022 Wait for the page's loading state to end before the action
|
|
26780
|
+
\u2022 Check the locator picks the enabled element, not a disabled twin`
|
|
26781
|
+
};
|
|
26782
|
+
}
|
|
26730
26783
|
if (/element not interactable|elementnotinteractable|element is not reachable by keyboard/i.test(lower)) {
|
|
26731
26784
|
return {
|
|
26732
26785
|
category: "test-issue",
|
|
@@ -28153,6 +28206,7 @@ function intentConflict(p2, broken, elements, intent) {
|
|
|
28153
28206
|
if (intent.kinds && targets.every((t) => !fitsKinds(t, intent.kinds))) {
|
|
28154
28207
|
return `the code uses it as a ${kindName(intent.kinds)} (${intent.kindEvidence}), but ${describeEl(targets[0])} is not one`;
|
|
28155
28208
|
}
|
|
28209
|
+
if (p2.source === "recorded-fallback") return null;
|
|
28156
28210
|
const claims = targets.map((t) => claimedBy(t, intent));
|
|
28157
28211
|
if (claims.every(Boolean)) return `${describeEl(targets[0])} is already used by ${claims[0]}`;
|
|
28158
28212
|
return null;
|
|
@@ -28599,6 +28653,16 @@ function locateSites(projectPath2, tiers, preferredFiles, display, opts = {}) {
|
|
|
28599
28653
|
return text3 === null ? [] : findSitesInText(text3, matchers, rel.replace(/\\/g, "/"));
|
|
28600
28654
|
};
|
|
28601
28655
|
const pick = (file, hits) => pickByFrames(projectPath2, file, hits, frames);
|
|
28656
|
+
for (const f of frames) {
|
|
28657
|
+
const onLine = [];
|
|
28658
|
+
for (const matchers of tiers) {
|
|
28659
|
+
for (const s of hitsIn(f.file, matchers)) {
|
|
28660
|
+
if (s.line === f.line && !onLine.some((o) => o.file === s.file && o.valueStart === s.valueStart && o.find === s.find)) onLine.push(s);
|
|
28661
|
+
}
|
|
28662
|
+
if (onLine.length > 0) break;
|
|
28663
|
+
}
|
|
28664
|
+
if (onLine.length === 1) return { sites: onLine };
|
|
28665
|
+
}
|
|
28602
28666
|
for (const matchers of tiers) {
|
|
28603
28667
|
const own = [];
|
|
28604
28668
|
for (const f of [...new Set(preferredFiles.filter(Boolean))]) {
|
|
@@ -31681,6 +31745,7 @@ var auto_heal_service_exports = {};
|
|
|
31681
31745
|
__export(auto_heal_service_exports, {
|
|
31682
31746
|
_drainAutoHeal: () => _drainAutoHeal,
|
|
31683
31747
|
couldHealRun: () => couldHealRun,
|
|
31748
|
+
findKeptFixFor: () => findKeptFixFor,
|
|
31684
31749
|
gotFurther: () => gotFurther,
|
|
31685
31750
|
initAutoHeal: () => initAutoHeal,
|
|
31686
31751
|
isHealBusy: () => isHealBusy,
|
|
@@ -31689,7 +31754,8 @@ __export(auto_heal_service_exports, {
|
|
|
31689
31754
|
recordRejectedFix: () => recordRejectedFix,
|
|
31690
31755
|
refreshSummary: () => refreshSummary,
|
|
31691
31756
|
traceWrittenDuring: () => traceWrittenDuring,
|
|
31692
|
-
triggerAutoHeal: () => triggerAutoHeal
|
|
31757
|
+
triggerAutoHeal: () => triggerAutoHeal,
|
|
31758
|
+
waitForParentRun: () => waitForParentRun
|
|
31693
31759
|
});
|
|
31694
31760
|
import { existsSync as existsSync52, mkdirSync as mkdirSync18, readFileSync as readFileSync47, writeFileSync as writeFileSync16, readdirSync as readdirSync29 } from "fs";
|
|
31695
31761
|
import { dirname as dirname21, join as join52 } from "path";
|
|
@@ -31883,6 +31949,20 @@ ${stack}`.slice(0, 3e3), lines);
|
|
|
31883
31949
|
}
|
|
31884
31950
|
return { candidates: candidates.slice(0, MAX_LOCATOR_CANDIDATES), frames };
|
|
31885
31951
|
}
|
|
31952
|
+
async function waitForParentRun(parentRunId, maxMs = PARENT_WAIT_MS, pollMs = PARENT_POLL_MS) {
|
|
31953
|
+
const until = Date.now() + maxMs;
|
|
31954
|
+
let logged = false;
|
|
31955
|
+
while (Date.now() < until) {
|
|
31956
|
+
const parent = deps?.resultsStore.getRun(parentRunId);
|
|
31957
|
+
if (!parent || parent.status !== "running") return;
|
|
31958
|
+
touchPending(parentRunId);
|
|
31959
|
+
if (!logged) {
|
|
31960
|
+
console.log(`[auto-heal] waiting for suite run ${parentRunId} to finish before healing its failed tests`);
|
|
31961
|
+
logged = true;
|
|
31962
|
+
}
|
|
31963
|
+
await new Promise((r) => setTimeout(r, pollMs));
|
|
31964
|
+
}
|
|
31965
|
+
}
|
|
31886
31966
|
async function healRun(runId, cfg) {
|
|
31887
31967
|
const { projectPath: projectPath2, resultsStore: resultsStore4 } = deps;
|
|
31888
31968
|
const run2 = resultsStore4.getRun(runId);
|
|
@@ -31890,6 +31970,7 @@ async function healRun(runId, cfg) {
|
|
|
31890
31970
|
if (run2.origin === "auto-heal" || run2.origin === "ai-fix") return;
|
|
31891
31971
|
const failed = run2.tests.filter((t) => t.status === "failed" || t.status === "error");
|
|
31892
31972
|
if (failed.length === 0) return;
|
|
31973
|
+
if (run2.parentRunId) await waitForParentRun(run2.parentRunId);
|
|
31893
31974
|
const effectiveMode = await resolveEffectiveMode(run2, cfg);
|
|
31894
31975
|
if (effectiveMode === "off") {
|
|
31895
31976
|
stampSkip(
|
|
@@ -31983,6 +32064,10 @@ async function findFix(run2, cfg, candidates, ev, spendAttempt) {
|
|
|
31983
32064
|
if (loc.reason) locateReasons.push(loc.reason);
|
|
31984
32065
|
}
|
|
31985
32066
|
if (!located) {
|
|
32067
|
+
if (ev.initial) {
|
|
32068
|
+
const kept = findKeptFixFor(run2, candidates);
|
|
32069
|
+
if (kept) return { kept };
|
|
32070
|
+
}
|
|
31986
32071
|
const resolved = candidates[0] ? ` The failing value was ${displayLocator(candidates[0])}.` : "";
|
|
31987
32072
|
return {
|
|
31988
32073
|
skip: `${locateReasons[0] ?? "The broken locator could not be found in the code."}${resolved} Dynamic or data-driven locators need a human decision \u2014 use "Fix in AI Assistant".`
|
|
@@ -32011,11 +32096,25 @@ async function findFix(run2, cfg, candidates, ev, spendAttempt) {
|
|
|
32011
32096
|
const intentRejections = [];
|
|
32012
32097
|
const accept = (p2, elements) => {
|
|
32013
32098
|
if (!p2) return false;
|
|
32099
|
+
if (rejectedNote) return false;
|
|
32014
32100
|
const problem = dialectProblem(p2.value, broken, dialect);
|
|
32015
32101
|
if (problem) {
|
|
32016
32102
|
console.log(`[auto-heal] '${rep.name}': rejected ${p2.source} proposal \u2014 ${problem}`);
|
|
32017
32103
|
return false;
|
|
32018
32104
|
}
|
|
32105
|
+
const dup = sites.find((s) => {
|
|
32106
|
+
const r = replacementFor(s, broken, p2);
|
|
32107
|
+
if (r === s.find) return false;
|
|
32108
|
+
try {
|
|
32109
|
+
return readFileSync47(join52(projectPath2, s.file), "utf8").includes(r);
|
|
32110
|
+
} catch {
|
|
32111
|
+
return false;
|
|
32112
|
+
}
|
|
32113
|
+
});
|
|
32114
|
+
if (dup) {
|
|
32115
|
+
console.log(`[auto-heal] '${rep.name}': rejected ${p2.source} proposal \u2014 '${p2.value}' already appears in ${dup.file}, so the edit could not be undone exactly`);
|
|
32116
|
+
return false;
|
|
32117
|
+
}
|
|
32019
32118
|
if (bareValueOnly && !p2.valueIsName) {
|
|
32020
32119
|
console.log(`[auto-heal] '${rep.name}': rejected ${p2.source} proposal \u2014 the code passes only a test id to a helper, and '${p2.value}' is a selector`);
|
|
32021
32120
|
return false;
|
|
@@ -32024,6 +32123,10 @@ async function findFix(run2, cfg, candidates, ev, spendAttempt) {
|
|
|
32024
32123
|
console.log(`[auto-heal] '${rep.name}': rejected ${p2.source} proposal \u2014 '${p2.value}' cannot be expressed in the template`);
|
|
32025
32124
|
return false;
|
|
32026
32125
|
}
|
|
32126
|
+
if (sites.some((s) => s.template && p2.value === s.template.dyn)) {
|
|
32127
|
+
console.log(`[auto-heal] '${rep.name}': rejected ${p2.source} proposal \u2014 '${p2.value}' is only the template's dynamic part`);
|
|
32128
|
+
return false;
|
|
32129
|
+
}
|
|
32027
32130
|
if (isRejectedFix(sites, broken, p2)) {
|
|
32028
32131
|
rejectedNote ??= `the fix found ("${p2.value}") is one you undid before, so it will not be applied again`;
|
|
32029
32132
|
return false;
|
|
@@ -32057,7 +32160,7 @@ async function findFix(run2, cfg, candidates, ev, spendAttempt) {
|
|
|
32057
32160
|
...loadRecordedEntries(projectPath2, [...preferredFiles, ...sites.map((s) => s.file)])
|
|
32058
32161
|
];
|
|
32059
32162
|
if (recorded.length > 0) {
|
|
32060
|
-
|
|
32163
|
+
tierRecordedFallback(broken, recorded, failurePageElements.length ? failurePageElements : traceElements, (p2) => accept(p2, traceElements));
|
|
32061
32164
|
}
|
|
32062
32165
|
if (!proposal && snapshotMd) accept(tier1Match(broken, parseAriaSnapshot(snapshotMd), dialect), traceElements);
|
|
32063
32166
|
for (const els of [failurePageElements, traceElements]) {
|
|
@@ -32084,7 +32187,7 @@ async function findFix(run2, cfg, candidates, ev, spendAttempt) {
|
|
|
32084
32187
|
}
|
|
32085
32188
|
}
|
|
32086
32189
|
if (!proposal && recorded.length > 0 && captureElements.length > 0) {
|
|
32087
|
-
|
|
32190
|
+
tierRecordedFallback(broken, recorded, captureElements, (p2) => accept(p2, captureElements));
|
|
32088
32191
|
}
|
|
32089
32192
|
}
|
|
32090
32193
|
if (!proposal) {
|
|
@@ -32295,6 +32398,10 @@ async function healUnit(run2, unit, cfg, snapshotByTest) {
|
|
|
32295
32398
|
stampSkip(run2.runId, names, first.skip);
|
|
32296
32399
|
return;
|
|
32297
32400
|
}
|
|
32401
|
+
if ("kept" in first) {
|
|
32402
|
+
await confirmKeptFix(run2, tests, unit.frames, first.kept);
|
|
32403
|
+
return;
|
|
32404
|
+
}
|
|
32298
32405
|
spendAttempt();
|
|
32299
32406
|
const fixes = [];
|
|
32300
32407
|
const applyFix = (fix) => {
|
|
@@ -32414,6 +32521,32 @@ ${f.test.stackTrace || ""}`;
|
|
|
32414
32521
|
rationale: stamp2.rationale
|
|
32415
32522
|
})).catch((err5) => console.error("[notify] Auto-heal notification failed:", err5));
|
|
32416
32523
|
}
|
|
32524
|
+
async function confirmKeptFix(run2, tests, frames, kept) {
|
|
32525
|
+
const names = tests.map((t) => t.name);
|
|
32526
|
+
const by = `the verified heal of "${kept.testName}" (${kept.stamp.from} \u2192 ${kept.stamp.to})`;
|
|
32527
|
+
console.log(`[auto-heal] run ${run2.runId}: ${names.length} test(s) failed on a locator already fixed by ${by} \u2014 re-running them with the fix`);
|
|
32528
|
+
let v;
|
|
32529
|
+
try {
|
|
32530
|
+
v = await verifyTests(tests, run2, frames);
|
|
32531
|
+
} catch (err5) {
|
|
32532
|
+
stampSkip(run2.runId, names, `The locator was already fixed by ${by}, but re-running this test with that fix hit an error: ${err5.message}`);
|
|
32533
|
+
return;
|
|
32534
|
+
}
|
|
32535
|
+
if (!v.passed) {
|
|
32536
|
+
stampSkip(run2.runId, names, `The locator was already fixed by ${by}, but this test still failed when re-run with that fix (${v.failedTest}). Nothing was changed \u2014 use "Fix in AI Assistant".`);
|
|
32537
|
+
return;
|
|
32538
|
+
}
|
|
32539
|
+
stampTests(run2, names, {
|
|
32540
|
+
...kept.stamp,
|
|
32541
|
+
state: "healed",
|
|
32542
|
+
verifyRunId: v.verifyRunId ?? kept.stamp.verifyRunId,
|
|
32543
|
+
rationale: `Already fixed in the code by ${by}; this test was re-run with that fix and passed. ${kept.stamp.rationale ?? ""}`.trim(),
|
|
32544
|
+
revertReason: void 0,
|
|
32545
|
+
partialNote: void 0,
|
|
32546
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
32547
|
+
});
|
|
32548
|
+
console.log(`[auto-heal] run ${run2.runId}: healed (${names.length} test(s) verified against the fix already in the code)`);
|
|
32549
|
+
}
|
|
32417
32550
|
async function verifyTests(tests, run2, frames) {
|
|
32418
32551
|
let verifyRunId;
|
|
32419
32552
|
for (const t of tests) {
|
|
@@ -32609,6 +32742,47 @@ function findPendingSuggestion(sites) {
|
|
|
32609
32742
|
}
|
|
32610
32743
|
return null;
|
|
32611
32744
|
}
|
|
32745
|
+
function findKeptFixFor(run2, candidates) {
|
|
32746
|
+
const { resultsStore: resultsStore4, projectPath: projectPath2 } = deps;
|
|
32747
|
+
const started = Date.parse(run2.startTime || "");
|
|
32748
|
+
if (!Number.isFinite(started)) return null;
|
|
32749
|
+
const values = candidates.flatMap((c2) => [c2.raw, c2.hint]).filter((v) => !!v && v.length >= 3);
|
|
32750
|
+
if (values.length === 0) return null;
|
|
32751
|
+
const quoted = values.map((v) => new RegExp(`(^|[^\\w-])${v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}($|[^\\w-])`));
|
|
32752
|
+
const fileCache = /* @__PURE__ */ new Map();
|
|
32753
|
+
const fileText = (rel) => {
|
|
32754
|
+
if (!fileCache.has(rel)) {
|
|
32755
|
+
try {
|
|
32756
|
+
fileCache.set(rel, readFileSync47(join52(projectPath2, rel), "utf8"));
|
|
32757
|
+
} catch {
|
|
32758
|
+
fileCache.set(rel, null);
|
|
32759
|
+
}
|
|
32760
|
+
}
|
|
32761
|
+
return fileCache.get(rel);
|
|
32762
|
+
};
|
|
32763
|
+
const pool = [];
|
|
32764
|
+
const parent = run2.parentRunId ? resultsStore4.getRun(run2.parentRunId) : void 0;
|
|
32765
|
+
if (parent) pool.push(parent);
|
|
32766
|
+
try {
|
|
32767
|
+
pool.push(...resultsStore4.getRunHistory(200, 0).runs);
|
|
32768
|
+
} catch {
|
|
32769
|
+
}
|
|
32770
|
+
for (const r of pool) {
|
|
32771
|
+
if (r.runId === run2.runId) continue;
|
|
32772
|
+
for (const t of r.tests) {
|
|
32773
|
+
const s = t.autoHeal;
|
|
32774
|
+
if (s?.state !== "healed" || !s.pairs?.length) continue;
|
|
32775
|
+
if (!(Date.parse(s.at) > started)) continue;
|
|
32776
|
+
if (!s.pairs.some((p2) => quoted.some((re) => re.test(p2.find)))) continue;
|
|
32777
|
+
if (!s.pairs.every((p2) => {
|
|
32778
|
+
const text3 = fileText(p2.file);
|
|
32779
|
+
return text3 !== null && text3.includes(p2.replace);
|
|
32780
|
+
})) continue;
|
|
32781
|
+
return { stamp: s, testName: t.name };
|
|
32782
|
+
}
|
|
32783
|
+
}
|
|
32784
|
+
return null;
|
|
32785
|
+
}
|
|
32612
32786
|
function flipIdenticalSuggestions(targets) {
|
|
32613
32787
|
const { resultsStore: resultsStore4 } = deps;
|
|
32614
32788
|
const want = targets.map((t) => `${t.file}|${t.find}|${t.replace}`).sort().join("\n");
|
|
@@ -32803,6 +32977,8 @@ async function runViaRunner(command, label4, original, opts = {}) {
|
|
|
32803
32977
|
if (opts.trace && /\bpytest\b/.test(command) && !/--tracing\b/.test(command) && usesPytestPlaywright()) {
|
|
32804
32978
|
command = `${command} --tracing retain-on-failure`;
|
|
32805
32979
|
}
|
|
32980
|
+
const parent = original.parentRunId ? resultsStore4.getRun(original.parentRunId) : void 0;
|
|
32981
|
+
const cloudFrom = original.source === "cloud" ? original : parent?.source === "cloud" ? parent : void 0;
|
|
32806
32982
|
try {
|
|
32807
32983
|
const res = await fetch(`${base}/api/runner/run`, {
|
|
32808
32984
|
method: "POST",
|
|
@@ -32813,9 +32989,9 @@ async function runViaRunner(command, label4, original, opts = {}) {
|
|
|
32813
32989
|
origin: "auto-heal",
|
|
32814
32990
|
label: label4,
|
|
32815
32991
|
headless: true,
|
|
32816
|
-
browser: original.targetBrowser || void 0,
|
|
32817
|
-
environment: original.targetEnvironment || void 0,
|
|
32818
|
-
cloudProvider:
|
|
32992
|
+
browser: original.targetBrowser || parent?.targetBrowser || void 0,
|
|
32993
|
+
environment: original.targetEnvironment || parent?.targetEnvironment || void 0,
|
|
32994
|
+
cloudProvider: cloudFrom?.cloudProvider
|
|
32819
32995
|
})
|
|
32820
32996
|
});
|
|
32821
32997
|
if (!res.ok) return { runId: null, passed: false };
|
|
@@ -32847,7 +33023,7 @@ async function runViaRunner(command, label4, original, opts = {}) {
|
|
|
32847
33023
|
return { runId: null, passed: false };
|
|
32848
33024
|
}
|
|
32849
33025
|
}
|
|
32850
|
-
var VERIFY_TIMEOUT_MS, VERIFY_POLL_MS, MAX_UNITS_PER_RUN, MAX_QUEUE, MAX_LOCATOR_CANDIDATES, deps, chain, queued, busy, pendingHeals, PENDING_STALE_MS, CATEGORY_EXPLAIN, MAX_CHAIN, LOCATOR_FAILURE, WAITISH, sourceFilesCache, PLAYWRIGHT_CONFIGS;
|
|
33026
|
+
var VERIFY_TIMEOUT_MS, VERIFY_POLL_MS, MAX_UNITS_PER_RUN, MAX_QUEUE, MAX_LOCATOR_CANDIDATES, deps, chain, queued, busy, pendingHeals, PENDING_STALE_MS, CATEGORY_EXPLAIN, MAX_CHAIN, LOCATOR_FAILURE, WAITISH, sourceFilesCache, PARENT_WAIT_MS, PARENT_POLL_MS, PLAYWRIGHT_CONFIGS;
|
|
32851
33027
|
var init_auto_heal_service = __esm({
|
|
32852
33028
|
"src/ui/services/auto-heal-service.ts"() {
|
|
32853
33029
|
"use strict";
|
|
@@ -32885,6 +33061,8 @@ var init_auto_heal_service = __esm({
|
|
|
32885
33061
|
LOCATOR_FAILURE = /no such element|unable to locate|could not be located|not found|never found|waiting for (?:locator|selector|getBy|get_by|element)|located by|still not (?:displayed|existing)|wasn't found|received: <element\(s\) not found>|strict mode violation|does not match any element|did not match any elements|did not appear in|resolved to 0 elements/i;
|
|
32886
33062
|
WAITISH = /wait|until|expected condition|located|timed out|timeout|did not appear/i;
|
|
32887
33063
|
sourceFilesCache = null;
|
|
33064
|
+
PARENT_WAIT_MS = 3 * 60 * 6e4;
|
|
33065
|
+
PARENT_POLL_MS = 3e3;
|
|
32888
33066
|
PLAYWRIGHT_CONFIGS = ["playwright.config.ts", "playwright.config.js", "playwright.config.mjs", "playwright.config.cjs", "playwright.config.mts"];
|
|
32889
33067
|
}
|
|
32890
33068
|
});
|
|
@@ -89456,7 +89634,7 @@ var init_project_scanner = __esm({
|
|
|
89456
89634
|
const entries = readdirSync36(fullPath, { withFileTypes: true });
|
|
89457
89635
|
for (const entry2 of entries) {
|
|
89458
89636
|
if (IGNORE_DIRS2.has(entry2.name)) continue;
|
|
89459
|
-
if (entry2.name.startsWith(".") && entry2.name !== ".env") continue;
|
|
89637
|
+
if (entry2.name.startsWith(".") && entry2.name !== ".env" && !(entry2.name === ".gitignore" && entry2.isFile())) continue;
|
|
89460
89638
|
if (budget.remaining <= 0) {
|
|
89461
89639
|
truncated = true;
|
|
89462
89640
|
budget.hitLimit = true;
|
|
@@ -89550,7 +89728,7 @@ var init_project_scanner = __esm({
|
|
|
89550
89728
|
const entries = readdirSync36(dir, { withFileTypes: true });
|
|
89551
89729
|
for (const entry2 of entries) {
|
|
89552
89730
|
if (IGNORE_DIRS2.has(entry2.name)) continue;
|
|
89553
|
-
if (entry2.name.startsWith(".") && entry2.name !== ".env" && !entry2.name.startsWith(".env.")) continue;
|
|
89731
|
+
if (entry2.name.startsWith(".") && entry2.name !== ".env" && !entry2.name.startsWith(".env.") && !(entry2.name === ".gitignore" && entry2.isFile())) continue;
|
|
89554
89732
|
const relPath = relDir ? join75(relDir, entry2.name) : entry2.name;
|
|
89555
89733
|
if (entry2.isDirectory()) {
|
|
89556
89734
|
callback(relPath, true);
|