lazyscout 0.3.4 → 0.3.6
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
|
@@ -260,6 +260,9 @@ function isSessionEndingLabel(...labels) {
|
|
|
260
260
|
return false;
|
|
261
261
|
return SESSION_ENDING_KEYWORDS.some((keyword) => haystack.includes(keyword.toLowerCase()));
|
|
262
262
|
}
|
|
263
|
+
function isUnsafeAutoClick(...labels) {
|
|
264
|
+
return isSessionEndingLabel(...labels);
|
|
265
|
+
}
|
|
263
266
|
var MAX_BLOCK_KEYWORDS = 100;
|
|
264
267
|
var MAX_KEYWORD_LENGTH = 80;
|
|
265
268
|
function normalizeBlockedKeywords(value) {
|
|
@@ -522,13 +525,6 @@ function collectPageData() {
|
|
|
522
525
|
};
|
|
523
526
|
}
|
|
524
527
|
|
|
525
|
-
// ../../packages/explorer/dist/safety.js
|
|
526
|
-
function canFollowLink(href, accessibleName, keywords = []) {
|
|
527
|
-
if (!href)
|
|
528
|
-
return false;
|
|
529
|
-
return !isBlockedLabel(keywords, accessibleName, href);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
528
|
// ../../packages/explorer/dist/mapToPageModel.js
|
|
533
529
|
function toUIElement(raw, keywords) {
|
|
534
530
|
return {
|
|
@@ -682,341 +678,6 @@ async function launchBrowser(options = {}) {
|
|
|
682
678
|
throw new ExplorerError("browser-error", `unable to launch a browser (tried: ${failures.join(", ")})`, options.userDataDir ? "Close any other LazyScout browser for this Project \u2014 the login browser and a recording both hold its profile \u2014 and try again" : 'Please install Google Chrome or Microsoft Edge or run "npx playwright install chromium" and try again');
|
|
683
679
|
}
|
|
684
680
|
|
|
685
|
-
// ../../packages/explorer/dist/exploreWebsite.js
|
|
686
|
-
var DEFAULT_EXPLORE_OPTIONS = {
|
|
687
|
-
maxPages: 20,
|
|
688
|
-
maxDepth: 3,
|
|
689
|
-
pageTimeoutMs: 2e4,
|
|
690
|
-
totalTimeoutMs: 12e4,
|
|
691
|
-
waitAfterNavigationMs: 750,
|
|
692
|
-
maxStatesPerPage: 8,
|
|
693
|
-
maxActionsPerState: 8,
|
|
694
|
-
maxTotalStates: 80,
|
|
695
|
-
actionTimeoutMs: 2e3,
|
|
696
|
-
stateDiscoveryTimeoutMs: 350,
|
|
697
|
-
blockedKeywords: [],
|
|
698
|
-
maxNavigationProbesPerPage: 6
|
|
699
|
-
};
|
|
700
|
-
async function exploreWebsite(startUrl, options = {}, policy = LOCAL_QA_POLICY) {
|
|
701
|
-
const config2 = { ...DEFAULT_EXPLORE_OPTIONS, ...options };
|
|
702
|
-
const startedAt = Date.now();
|
|
703
|
-
const check = checkTargetUrl(startUrl, policy);
|
|
704
|
-
if (!check.ok)
|
|
705
|
-
throw new ExplorerError(check.code, check.message);
|
|
706
|
-
const origin = check.url.origin;
|
|
707
|
-
const entryUrl = normalizeUrl(check.url.toString());
|
|
708
|
-
const pages = [];
|
|
709
|
-
const issues = [];
|
|
710
|
-
const visited = /* @__PURE__ */ new Set();
|
|
711
|
-
const queue = [{ url: entryUrl, depth: 0 }];
|
|
712
|
-
const actionGraph = {
|
|
713
|
-
states: [],
|
|
714
|
-
edges: [],
|
|
715
|
-
visitedStateIds: [],
|
|
716
|
-
visitedActionKeys: [],
|
|
717
|
-
failedActionKeys: [],
|
|
718
|
-
blockedActionKeys: []
|
|
719
|
-
};
|
|
720
|
-
let urlsSkipped = 0;
|
|
721
|
-
let limitReached = "none";
|
|
722
|
-
const launched = await launchBrowser(config2.browserProfileDir ? { userDataDir: config2.browserProfileDir } : {});
|
|
723
|
-
const { context, label: browserLabel } = launched;
|
|
724
|
-
try {
|
|
725
|
-
context.setDefaultTimeout(config2.pageTimeoutMs);
|
|
726
|
-
const page = await context.newPage();
|
|
727
|
-
while (queue.length > 0) {
|
|
728
|
-
if (pages.length >= config2.maxPages) {
|
|
729
|
-
limitReached = "max-pages-reached";
|
|
730
|
-
urlsSkipped += queue.length;
|
|
731
|
-
break;
|
|
732
|
-
}
|
|
733
|
-
if (Date.now() - startedAt > config2.totalTimeoutMs) {
|
|
734
|
-
limitReached = "timeout-reached";
|
|
735
|
-
urlsSkipped += queue.length;
|
|
736
|
-
break;
|
|
737
|
-
}
|
|
738
|
-
const item = queue.shift();
|
|
739
|
-
if (visited.has(item.url))
|
|
740
|
-
continue;
|
|
741
|
-
visited.add(item.url);
|
|
742
|
-
const result = await visitPage(page, item, config2, config2.blockedKeywords);
|
|
743
|
-
if (result.kind === "issue") {
|
|
744
|
-
issues.push(result.issue);
|
|
745
|
-
continue;
|
|
746
|
-
}
|
|
747
|
-
const finalKey = normalizeUrl(result.page.finalUrl);
|
|
748
|
-
if (finalKey !== item.url && visited.has(finalKey)) {
|
|
749
|
-
urlsSkipped++;
|
|
750
|
-
continue;
|
|
751
|
-
}
|
|
752
|
-
visited.add(finalKey);
|
|
753
|
-
pages.push(result.page);
|
|
754
|
-
addState(actionGraph, result.page.state);
|
|
755
|
-
await discoverSafeStates(page, result.page, config2, origin, actionGraph);
|
|
756
|
-
if (item.depth >= config2.maxDepth) {
|
|
757
|
-
if (result.page.links.length > 0)
|
|
758
|
-
limitReached = limitReached === "none" ? "max-depth-reached" : limitReached;
|
|
759
|
-
continue;
|
|
760
|
-
}
|
|
761
|
-
const enqueue = (href) => {
|
|
762
|
-
if (!href)
|
|
763
|
-
return;
|
|
764
|
-
if (!isSameOrigin(href, origin) || !isCrawlableUrl(href)) {
|
|
765
|
-
urlsSkipped++;
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
const next = normalizeUrl(href);
|
|
769
|
-
if (visited.has(next) || queue.some((queued) => queued.url === next))
|
|
770
|
-
return;
|
|
771
|
-
queue.push({ url: next, depth: item.depth + 1 });
|
|
772
|
-
};
|
|
773
|
-
for (const link of result.page.links) {
|
|
774
|
-
if (!canFollowLink(link.href, link.accessibleName, config2.blockedKeywords))
|
|
775
|
-
continue;
|
|
776
|
-
enqueue(link.href);
|
|
777
|
-
}
|
|
778
|
-
await probeNavigationControls(page, result.page, config2, origin, actionGraph, enqueue, () => Date.now() - startedAt > config2.totalTimeoutMs);
|
|
779
|
-
}
|
|
780
|
-
} finally {
|
|
781
|
-
await launched.close().catch(() => void 0);
|
|
782
|
-
}
|
|
783
|
-
addNavigationEdges(pages, actionGraph, config2.blockedKeywords);
|
|
784
|
-
return {
|
|
785
|
-
startUrl: entryUrl,
|
|
786
|
-
origin,
|
|
787
|
-
pages,
|
|
788
|
-
issues,
|
|
789
|
-
stats: {
|
|
790
|
-
browser: browserLabel,
|
|
791
|
-
pagesVisited: pages.length,
|
|
792
|
-
urlsSkipped,
|
|
793
|
-
durationMs: Date.now() - startedAt,
|
|
794
|
-
limitReached
|
|
795
|
-
},
|
|
796
|
-
actionGraph
|
|
797
|
-
};
|
|
798
|
-
}
|
|
799
|
-
function addNavigationEdges(pages, graph, keywords) {
|
|
800
|
-
for (const page of pages) {
|
|
801
|
-
const source = page.state;
|
|
802
|
-
if (!source)
|
|
803
|
-
continue;
|
|
804
|
-
for (const link of page.links) {
|
|
805
|
-
if (!link.href || !link.accessibleName)
|
|
806
|
-
continue;
|
|
807
|
-
const safe = canFollowLink(link.href, link.accessibleName, keywords);
|
|
808
|
-
const target = pages.find((candidate) => candidate.finalUrl === link.href || candidate.url === link.href)?.state;
|
|
809
|
-
const action = {
|
|
810
|
-
id: `${source.id}|navigate|${link.cssSelector}`,
|
|
811
|
-
type: "navigate",
|
|
812
|
-
description: `Navigate to \u201C${link.accessibleName}\u201D`,
|
|
813
|
-
target: link.accessibleName,
|
|
814
|
-
selector: link.cssSelector,
|
|
815
|
-
locator: { role: link.role, name: link.accessibleName },
|
|
816
|
-
safe,
|
|
817
|
-
reason: safe ? void 0 : "Link matched the Project click filter and was not opened"
|
|
818
|
-
};
|
|
819
|
-
addEdge(graph, source.id, target?.id, action, safe && target ? "visited" : safe ? "discovered" : "blocked");
|
|
820
|
-
if (!safe)
|
|
821
|
-
graph.blockedActionKeys.push(action.id);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
function addState(graph, state) {
|
|
826
|
-
if (!state || graph.states.some((candidate) => candidate.id === state.id))
|
|
827
|
-
return;
|
|
828
|
-
graph.states.push(state);
|
|
829
|
-
graph.visitedStateIds.push(state.id);
|
|
830
|
-
}
|
|
831
|
-
async function discoverSafeStates(page, source, config2, origin, graph) {
|
|
832
|
-
const initial = source.state;
|
|
833
|
-
if (!initial || graph.states.length >= config2.maxTotalStates)
|
|
834
|
-
return;
|
|
835
|
-
const sourceUrl = source.finalUrl;
|
|
836
|
-
const interactions = initial.interactions.slice(0, config2.maxActionsPerState);
|
|
837
|
-
let statesForPage = 1;
|
|
838
|
-
for (const interaction of interactions) {
|
|
839
|
-
if (statesForPage >= config2.maxStatesPerPage || graph.states.length >= config2.maxTotalStates)
|
|
840
|
-
break;
|
|
841
|
-
const action = actionFromInteraction(initial.id, interaction, config2.blockedKeywords);
|
|
842
|
-
const actionKey = action.id;
|
|
843
|
-
if (graph.visitedActionKeys.includes(actionKey) || graph.failedActionKeys.includes(actionKey))
|
|
844
|
-
continue;
|
|
845
|
-
if (!action.safe) {
|
|
846
|
-
addEdge(graph, initial.id, void 0, action, "blocked");
|
|
847
|
-
graph.blockedActionKeys.push(actionKey);
|
|
848
|
-
continue;
|
|
849
|
-
}
|
|
850
|
-
try {
|
|
851
|
-
await page.locator(interaction.cssSelector).click({ timeout: config2.actionTimeoutMs });
|
|
852
|
-
await page.waitForTimeout(config2.stateDiscoveryTimeoutMs);
|
|
853
|
-
if (!isSameOrigin(page.url(), origin)) {
|
|
854
|
-
addEdge(graph, initial.id, void 0, { ...action, safe: false, reason: "Action left the approved origin" }, "blocked");
|
|
855
|
-
graph.blockedActionKeys.push(actionKey);
|
|
856
|
-
continue;
|
|
857
|
-
}
|
|
858
|
-
const raw = await page.evaluate(collectPageData);
|
|
859
|
-
const observed = mapToPageModel(raw, {
|
|
860
|
-
url: page.url(),
|
|
861
|
-
finalUrl: page.url(),
|
|
862
|
-
depth: source.depth,
|
|
863
|
-
statusCode: source.statusCode
|
|
864
|
-
}, config2.blockedKeywords).state;
|
|
865
|
-
if (!observed)
|
|
866
|
-
continue;
|
|
867
|
-
addState(graph, observed);
|
|
868
|
-
addEdge(graph, initial.id, observed.id, action, "visited");
|
|
869
|
-
graph.visitedActionKeys.push(actionKey);
|
|
870
|
-
if (observed.id !== initial.id)
|
|
871
|
-
statesForPage += 1;
|
|
872
|
-
} catch (error) {
|
|
873
|
-
addEdge(graph, initial.id, void 0, action, "failed");
|
|
874
|
-
graph.failedActionKeys.push(actionKey);
|
|
875
|
-
} finally {
|
|
876
|
-
await page.goto(sourceUrl, { waitUntil: "domcontentloaded", timeout: config2.pageTimeoutMs }).catch(() => void 0);
|
|
877
|
-
await page.waitForTimeout(Math.min(config2.waitAfterNavigationMs, 300));
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
async function probeNavigationControls(page, source, config2, origin, graph, enqueue, outOfTime) {
|
|
882
|
-
if (config2.maxNavigationProbesPerPage <= 0)
|
|
883
|
-
return;
|
|
884
|
-
const sourceUrl = source.finalUrl;
|
|
885
|
-
const sourceKey = normalizeUrl(sourceUrl);
|
|
886
|
-
const stateId2 = source.state?.id;
|
|
887
|
-
const candidates = source.buttons.filter((button) => button.accessibleName && !button.destructive && !button.disabled).slice(0, config2.maxNavigationProbesPerPage);
|
|
888
|
-
for (const candidate of candidates) {
|
|
889
|
-
if (outOfTime())
|
|
890
|
-
break;
|
|
891
|
-
const action = {
|
|
892
|
-
id: `${stateId2 ?? sourceKey}|navigate|${candidate.cssSelector}`,
|
|
893
|
-
type: "navigate",
|
|
894
|
-
description: `Navigate by clicking \u201C${candidate.accessibleName}\u201D`,
|
|
895
|
-
target: candidate.accessibleName,
|
|
896
|
-
selector: candidate.cssSelector,
|
|
897
|
-
locator: { role: candidate.role, name: candidate.accessibleName },
|
|
898
|
-
safe: true
|
|
899
|
-
};
|
|
900
|
-
if (graph.visitedActionKeys.includes(action.id) || graph.failedActionKeys.includes(action.id))
|
|
901
|
-
continue;
|
|
902
|
-
try {
|
|
903
|
-
if (normalizeUrl(page.url()) !== sourceKey) {
|
|
904
|
-
await page.goto(sourceUrl, { waitUntil: "domcontentloaded", timeout: config2.pageTimeoutMs });
|
|
905
|
-
}
|
|
906
|
-
await page.locator(candidate.cssSelector).click({ timeout: config2.actionTimeoutMs });
|
|
907
|
-
await page.waitForTimeout(config2.stateDiscoveryTimeoutMs);
|
|
908
|
-
const reached = page.url();
|
|
909
|
-
if (normalizeUrl(reached) === sourceKey)
|
|
910
|
-
continue;
|
|
911
|
-
if (!isSameOrigin(reached, origin)) {
|
|
912
|
-
if (stateId2)
|
|
913
|
-
addEdge(graph, stateId2, void 0, { ...action, safe: false, reason: "Action left the approved origin" }, "blocked");
|
|
914
|
-
graph.blockedActionKeys.push(action.id);
|
|
915
|
-
continue;
|
|
916
|
-
}
|
|
917
|
-
enqueue(reached);
|
|
918
|
-
if (stateId2)
|
|
919
|
-
addEdge(graph, stateId2, void 0, action, "discovered");
|
|
920
|
-
graph.visitedActionKeys.push(action.id);
|
|
921
|
-
} catch {
|
|
922
|
-
if (stateId2)
|
|
923
|
-
addEdge(graph, stateId2, void 0, action, "failed");
|
|
924
|
-
graph.failedActionKeys.push(action.id);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
if (normalizeUrl(page.url()) !== sourceKey) {
|
|
928
|
-
await page.goto(sourceUrl, { waitUntil: "domcontentloaded", timeout: config2.pageTimeoutMs }).catch(() => void 0);
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
function actionFromInteraction(stateId2, interaction, keywords) {
|
|
932
|
-
const type = interaction.kind === "tab" ? "selectTab" : interaction.kind === "accordion" ? "expandAccordion" : interaction.kind === "dropdown" ? "openDropdown" : interaction.expanded ? "closeDialog" : "openModal";
|
|
933
|
-
const blocked = isBlockedLabel(keywords, interaction.name);
|
|
934
|
-
const description = `${type === "selectTab" ? "Select" : type === "expandAccordion" ? "Expand" : "Open"} \u201C${interaction.name}\u201D`;
|
|
935
|
-
return {
|
|
936
|
-
id: `${stateId2}|${type}|${interaction.cssSelector}`,
|
|
937
|
-
type,
|
|
938
|
-
description,
|
|
939
|
-
target: interaction.name,
|
|
940
|
-
selector: interaction.cssSelector,
|
|
941
|
-
locator: { role: interaction.role, name: interaction.name },
|
|
942
|
-
safe: !blocked,
|
|
943
|
-
reason: blocked ? "Action matched the Project click filter and was not executed" : void 0
|
|
944
|
-
};
|
|
945
|
-
}
|
|
946
|
-
function addEdge(graph, fromStateId, toStateId, action, status) {
|
|
947
|
-
const id = `${fromStateId}|${action.id}|${toStateId ?? status}`;
|
|
948
|
-
if (graph.edges.some((edge) => edge.id === id))
|
|
949
|
-
return;
|
|
950
|
-
graph.edges.push({ id, fromStateId, toStateId, action, status });
|
|
951
|
-
}
|
|
952
|
-
async function visitPage(page, item, config2, keywords) {
|
|
953
|
-
try {
|
|
954
|
-
const apiRequests = [];
|
|
955
|
-
const requestStarted = /* @__PURE__ */ new Map();
|
|
956
|
-
const onRequest = (request) => {
|
|
957
|
-
if (request.resourceType() === "xhr" || request.resourceType() === "fetch")
|
|
958
|
-
requestStarted.set(request.url(), Date.now());
|
|
959
|
-
};
|
|
960
|
-
const onResponse = (response2) => {
|
|
961
|
-
const request = response2.request();
|
|
962
|
-
if (request.resourceType() !== "xhr" && request.resourceType() !== "fetch")
|
|
963
|
-
return;
|
|
964
|
-
apiRequests.push({
|
|
965
|
-
id: `api-${apiRequests.length + 1}`,
|
|
966
|
-
method: request.method(),
|
|
967
|
-
url: redactUrl(request.url()),
|
|
968
|
-
status: response2.status(),
|
|
969
|
-
durationMs: Date.now() - (requestStarted.get(request.url()) ?? Date.now()),
|
|
970
|
-
resourceType: request.resourceType(),
|
|
971
|
-
sourceUrl: redactUrl(item.url),
|
|
972
|
-
contentType: response2.headers()["content-type"]
|
|
973
|
-
});
|
|
974
|
-
};
|
|
975
|
-
page.on("request", onRequest);
|
|
976
|
-
page.on("response", onResponse);
|
|
977
|
-
const response = await page.goto(item.url, {
|
|
978
|
-
waitUntil: "domcontentloaded",
|
|
979
|
-
timeout: config2.pageTimeoutMs
|
|
980
|
-
});
|
|
981
|
-
const status = response?.status();
|
|
982
|
-
if (status !== void 0 && status >= 400) {
|
|
983
|
-
return {
|
|
984
|
-
kind: "issue",
|
|
985
|
-
issue: { url: item.url, code: "http-error", message: `The server returned HTTP ${status}.` }
|
|
986
|
-
};
|
|
987
|
-
}
|
|
988
|
-
await page.waitForLoadState("networkidle", { timeout: Math.min(config2.pageTimeoutMs, 5e3) }).catch(() => void 0);
|
|
989
|
-
await page.waitForTimeout(config2.waitAfterNavigationMs);
|
|
990
|
-
const challengeText = `${await page.title()} ${await page.locator("body").innerText().catch(() => "")}`.toLowerCase();
|
|
991
|
-
if (challengeText.includes("cloudflare") || challengeText.includes("checking your browser") || challengeText.includes("verify you are human") || challengeText.includes("just a moment")) {
|
|
992
|
-
return {
|
|
993
|
-
kind: "issue",
|
|
994
|
-
issue: {
|
|
995
|
-
url: item.url,
|
|
996
|
-
code: "cloudflare",
|
|
997
|
-
message: "Cloudflare/browser challenge \u2014 self check the website in a browser and try again"
|
|
998
|
-
}
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
const finalUrl = page.url();
|
|
1002
|
-
const raw = await page.evaluate(collectPageData);
|
|
1003
|
-
page.off("request", onRequest);
|
|
1004
|
-
page.off("response", onResponse);
|
|
1005
|
-
return {
|
|
1006
|
-
kind: "page",
|
|
1007
|
-
page: mapToPageModel(raw, {
|
|
1008
|
-
url: item.url,
|
|
1009
|
-
finalUrl,
|
|
1010
|
-
depth: item.depth,
|
|
1011
|
-
statusCode: status,
|
|
1012
|
-
apiRequests
|
|
1013
|
-
}, keywords)
|
|
1014
|
-
};
|
|
1015
|
-
} catch (error) {
|
|
1016
|
-
return { kind: "issue", issue: toExploreIssue(item.url, error) };
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
681
|
// ../../packages/explorer/dist/scopedExplorer.js
|
|
1021
682
|
var DEFAULT_LIMITS = {
|
|
1022
683
|
maxPages: 20,
|
|
@@ -1472,7 +1133,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1472
1133
|
if (visitedStates.has(modalState.id))
|
|
1473
1134
|
return { candidates: [] };
|
|
1474
1135
|
visitedStates.add(modalState.id);
|
|
1475
|
-
|
|
1136
|
+
addState(actionGraph, modalState);
|
|
1476
1137
|
debug(`State discovered: ${modalState.name} (modal)`, { stateId: modalState.id, url: page.url() });
|
|
1477
1138
|
const modalCandidates = await discoverSafeCandidates(page, modalState);
|
|
1478
1139
|
const safeCandidates = modalCandidates.filter((c) => c.action.safe).slice(0, legacyOptions.maxActionsPerState);
|
|
@@ -1480,7 +1141,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1480
1141
|
if (actionGraph.visitedActionKeys.includes(mc.action.id) || actionGraph.failedActionKeys.includes(mc.action.id))
|
|
1481
1142
|
continue;
|
|
1482
1143
|
if (!mc.action.safe) {
|
|
1483
|
-
|
|
1144
|
+
addEdge(actionGraph, modalState.id, void 0, mc.action, "blocked");
|
|
1484
1145
|
actionGraph.blockedActionKeys.push(mc.action.id);
|
|
1485
1146
|
totalActionsBlocked++;
|
|
1486
1147
|
debug(`Blocked: ${mc.action.target} (${mc.action.reason || "unsafe"})`, {
|
|
@@ -1493,7 +1154,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1493
1154
|
totalActionsExecuted++;
|
|
1494
1155
|
if (!result.success) {
|
|
1495
1156
|
totalActionsFailed++;
|
|
1496
|
-
|
|
1157
|
+
addEdge(actionGraph, modalState.id, void 0, mc.action, "failed");
|
|
1497
1158
|
actionGraph.failedActionKeys.push(mc.action.id);
|
|
1498
1159
|
debug(`Failed: ${mc.action.target}`, { actionId: mc.action.id, stateId: modalState.id });
|
|
1499
1160
|
continue;
|
|
@@ -1504,8 +1165,8 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1504
1165
|
const newState = newModel.state;
|
|
1505
1166
|
if (newState && !visitedStates.has(newState.id)) {
|
|
1506
1167
|
visitedStates.add(newState.id);
|
|
1507
|
-
|
|
1508
|
-
|
|
1168
|
+
addState(actionGraph, newState);
|
|
1169
|
+
addEdge(actionGraph, modalState.id, newState.id, mc.action, "visited");
|
|
1509
1170
|
debug(`New state in modal: ${newState.name}`, { stateId: newState.id });
|
|
1510
1171
|
}
|
|
1511
1172
|
}
|
|
@@ -1557,7 +1218,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1557
1218
|
visitedUrls.add(normalizeUrl(initialPage.finalUrl));
|
|
1558
1219
|
if (initialPage.state) {
|
|
1559
1220
|
visitedStates.add(initialPage.state.id);
|
|
1560
|
-
|
|
1221
|
+
addState(actionGraph, initialPage.state);
|
|
1561
1222
|
debug(`State discovered: ${initialPage.state.name}`, {
|
|
1562
1223
|
stateId: initialPage.state.id,
|
|
1563
1224
|
url: redactUrl(initialPage.finalUrl)
|
|
@@ -1646,7 +1307,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1646
1307
|
continue;
|
|
1647
1308
|
if (!visitedStates.has(currentState.id)) {
|
|
1648
1309
|
visitedStates.add(currentState.id);
|
|
1649
|
-
|
|
1310
|
+
addState(actionGraph, currentState);
|
|
1650
1311
|
}
|
|
1651
1312
|
if (config2.mode === "current-page")
|
|
1652
1313
|
continue;
|
|
@@ -1660,7 +1321,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1660
1321
|
for (const candidate of candidates) {
|
|
1661
1322
|
if (!candidate.action.safe && candidate.action.reason) {
|
|
1662
1323
|
totalActionsBlocked++;
|
|
1663
|
-
|
|
1324
|
+
addEdge(actionGraph, currentState.id, void 0, candidate.action, "blocked");
|
|
1664
1325
|
actionGraph.blockedActionKeys.push(candidate.action.id);
|
|
1665
1326
|
const blockReason = isSessionEnding(candidate.action.target, void 0) ? "session-ending action" : candidate.action.reason;
|
|
1666
1327
|
debug(`Blocked: ${candidate.action.target} (${blockReason})`, {
|
|
@@ -1691,7 +1352,7 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1691
1352
|
totalActionsExecuted++;
|
|
1692
1353
|
if (!result.success) {
|
|
1693
1354
|
totalActionsFailed++;
|
|
1694
|
-
|
|
1355
|
+
addEdge(actionGraph, currentState.id, void 0, candidate.action, "failed");
|
|
1695
1356
|
actionGraph.failedActionKeys.push(candidate.action.id);
|
|
1696
1357
|
debug(`Failed: ${candidate.action.target}`, { actionId: candidate.action.id });
|
|
1697
1358
|
await restoreState(page, beforeUrl, candidate.restoreStrategy, item.entryFlow);
|
|
@@ -1718,8 +1379,8 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1718
1379
|
const newState = newModel.state;
|
|
1719
1380
|
if (newState && !visitedStates.has(newState.id)) {
|
|
1720
1381
|
visitedStates.add(newState.id);
|
|
1721
|
-
|
|
1722
|
-
|
|
1382
|
+
addState(actionGraph, newState);
|
|
1383
|
+
addEdge(actionGraph, currentState.id, newState.id, candidate.action, "visited");
|
|
1723
1384
|
debug(`New state: ${newState.name}`, { stateId: newState.id, url: redactUrl(afterUrl) });
|
|
1724
1385
|
if (!visitedUrls.has(normalizedAfter)) {
|
|
1725
1386
|
visitedUrls.add(normalizedAfter);
|
|
@@ -1736,9 +1397,9 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1736
1397
|
entryFlow: newEntryFlow
|
|
1737
1398
|
});
|
|
1738
1399
|
} else if (newState) {
|
|
1739
|
-
|
|
1400
|
+
addEdge(actionGraph, currentState.id, newState.id, candidate.action, "visited");
|
|
1740
1401
|
} else {
|
|
1741
|
-
|
|
1402
|
+
addEdge(actionGraph, currentState.id, void 0, candidate.action, "visited");
|
|
1742
1403
|
}
|
|
1743
1404
|
if (normalizedAfter !== normalizeUrl(beforeUrl)) {
|
|
1744
1405
|
await restoreState(page, beforeUrl, candidate.restoreStrategy, item.entryFlow);
|
|
@@ -1784,13 +1445,13 @@ async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions
|
|
|
1784
1445
|
actionGraph
|
|
1785
1446
|
};
|
|
1786
1447
|
}
|
|
1787
|
-
function
|
|
1448
|
+
function addState(graph, state) {
|
|
1788
1449
|
if (!state || graph.states.some((s) => s.id === state.id))
|
|
1789
1450
|
return;
|
|
1790
1451
|
graph.states.push(state);
|
|
1791
1452
|
graph.visitedStateIds.push(state.id);
|
|
1792
1453
|
}
|
|
1793
|
-
function
|
|
1454
|
+
function addEdge(graph, fromStateId, toStateId, action, status) {
|
|
1794
1455
|
const id = `${fromStateId}|${action.id}|${toStateId ?? status}`;
|
|
1795
1456
|
if (graph.edges.some((edge) => edge.id === id))
|
|
1796
1457
|
return;
|
|
@@ -2441,7 +2102,7 @@ function translateStep(step) {
|
|
|
2441
2102
|
}
|
|
2442
2103
|
}
|
|
2443
2104
|
function translate(value) {
|
|
2444
|
-
return value.replace(/^(.+) page displays required controls$/, "$1 \u0E41\u0E2A\u0E14\u0E07
|
|
2105
|
+
return value.replace(/^(.+) page displays required controls$/, "$1 \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19").replace(/^All (\d+) controls detected on the page are visible\.$/, "\u0E1E\u0E1A\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14 $1 \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25\u0E2D\u0E22\u0E39\u0E48").replace(/^(.+) is required$/, "$1 \u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19").replace(/^Submit (.+) with valid data$/, "\u0E2A\u0E48\u0E07 $1 \u0E14\u0E49\u0E27\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^Navigate to (.+)$/, "\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^The application is available at (.+)$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19\u0E17\u0E35\u0E48 $1").replace(/^The application is available$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19").replace(/^Valid test data is prepared$/, "\u0E40\u0E15\u0E23\u0E35\u0E22\u0E21\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E41\u0E25\u0E49\u0E27").replace(/^Disposable test data is prepared$/, "\u0E40\u0E15\u0E23\u0E35\u0E22\u0E21\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E25\u0E1A\u0E44\u0E14\u0E49\u0E41\u0E25\u0E49\u0E27").replace(/^Leave "(.+)" empty$/, '\u0E40\u0E27\u0E49\u0E19\u0E0A\u0E48\u0E2D\u0E07 "$1" \u0E27\u0E48\u0E32\u0E07\u0E44\u0E27\u0E49').replace(/^Select "(.+)"$/, '\u0E40\u0E25\u0E37\u0E2D\u0E01 "$1"').replace(/^Verify that a validation message is displayed for the empty required field, and the form is not submitted\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E0A\u0E48\u0E2D\u0E07\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19\u0E0B\u0E36\u0E48\u0E07\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07 \u0E41\u0E25\u0E30\u0E1F\u0E2D\u0E23\u0E4C\u0E21\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E2A\u0E48\u0E07").replace(/^The browser navigates to (.+) and the page "(.+)" is displayed\.$/, '\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1 \u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E2B\u0E19\u0E49\u0E32 "$2"').replace(/^The browser navigates to (.+)\.$/, "\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^Dialog "(.+)" is visible\.$/, '\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E42\u0E15\u0E49\u0E15\u0E2D\u0E1A "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Validation message "(.+)" is visible\.$/, '\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19 "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Heading "(.+)" is visible\.$/, '\u0E2B\u0E31\u0E27\u0E02\u0E49\u0E2D "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Observed state requires tester review before automation\.$/, "\u0E2A\u0E16\u0E32\u0E19\u0E30\u0E17\u0E35\u0E48\u0E1E\u0E1A\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E01\u0E48\u0E2D\u0E19\u0E17\u0E33 Automation").replace(/^Verify "(.+)" action \(manual\)$/, '\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A action "$1" \u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07').replace(/^Open (.+)$/, "\u0E40\u0E1B\u0E34\u0E14 $1").replace(/^The page is reachable and rendered$/, "\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E1B\u0E34\u0E14\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25\u0E44\u0E14\u0E49").replace(/^Expected behavior is not known from static exploration; review manually\.$/, "\u0E44\u0E21\u0E48\u0E17\u0E23\u0E32\u0E1A\u0E1E\u0E24\u0E15\u0E34\u0E01\u0E23\u0E23\u0E21\u0E08\u0E32\u0E01\u0E01\u0E32\u0E23\u0E2A\u0E33\u0E23\u0E27\u0E08\u0E41\u0E1A\u0E1A static \u0E01\u0E23\u0E38\u0E13\u0E32\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07").replace(/^Verify that the result is displayed according to application requirements \(needs review by tester\)\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E41\u0E2A\u0E14\u0E07\u0E15\u0E32\u0E21\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E02\u0E2D\u0E07\u0E23\u0E30\u0E1A\u0E1A (\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A)").replace(/^Generated from elements detected on the page\.$/, "\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A").replace(/^Evidence: the field has the HTML "required" attribute\.$/, '\u0E2B\u0E25\u0E31\u0E01\u0E10\u0E32\u0E19: \u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E21\u0E35\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C HTML "required"').replace(/^No "required" attribute found — confirm with the specification whether this field is mandatory\.$/, '\u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C "required" \u2014 \u0E42\u0E1B\u0E23\u0E14\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E01\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E27\u0E48\u0E32\u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E19\u0E35\u0E49\u0E1A\u0E31\u0E07\u0E04\u0E31\u0E1A\u0E01\u0E23\u0E2D\u0E01\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48').replace(/^Sample values are placeholders — replace them with real test data before running\.$/, "\u0E04\u0E48\u0E32\u0E15\u0E31\u0E27\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E1E\u0E35\u0E22\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E41\u0E17\u0E19\u0E17\u0E35\u0E48 \u2014 \u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E08\u0E23\u0E34\u0E07\u0E01\u0E48\u0E2D\u0E19\u0E40\u0E23\u0E34\u0E48\u0E21\u0E17\u0E14\u0E2A\u0E2D\u0E1A").replace(/^Explorer did not open this page — expected result needs review\.$/, "Explorer \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E40\u0E1B\u0E34\u0E14\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49 \u2014 \u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07\u0E15\u0E49\u0E2D\u0E07\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A").replace(/^Detected as a potentially destructive action — Explorer did not click it\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A\u0E27\u0E48\u0E32\u0E2D\u0E32\u0E08\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E01\u0E23\u0E30\u0E17\u0E33\u0E17\u0E35\u0E48\u0E17\u0E33\u0E25\u0E32\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25 \u2014 Explorer \u0E08\u0E36\u0E07\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E04\u0E25\u0E34\u0E01").replace(/^Manually trigger (.+) "(.+)" in a safe test environment$/, '\u0E2A\u0E31\u0E48\u0E07\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19 $1 "$2" \u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07\u0E43\u0E19\u0E2A\u0E20\u0E32\u0E1E\u0E41\u0E27\u0E14\u0E25\u0E49\u0E2D\u0E21\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E1B\u0E25\u0E2D\u0E14\u0E20\u0E31\u0E22');
|
|
2445
2106
|
}
|
|
2446
2107
|
function safeNormalize(url) {
|
|
2447
2108
|
try {
|
|
@@ -2529,17 +2190,19 @@ function generateTestData(pages) {
|
|
|
2529
2190
|
var UTF8_BOM = "\uFEFF";
|
|
2530
2191
|
var CSV_COLUMNS = [
|
|
2531
2192
|
"TC_ID",
|
|
2532
|
-
"Module",
|
|
2533
2193
|
"Folder",
|
|
2534
|
-
"Tags",
|
|
2535
|
-
"Requirements",
|
|
2536
2194
|
"Title",
|
|
2537
|
-
"Preconditions",
|
|
2538
|
-
"Test_Steps",
|
|
2539
|
-
"Expected_Result",
|
|
2540
2195
|
"Type",
|
|
2541
2196
|
"Priority",
|
|
2197
|
+
"Test_Steps",
|
|
2198
|
+
"Expected_Result",
|
|
2542
2199
|
"Automation_Status",
|
|
2200
|
+
"Preconditions",
|
|
2201
|
+
"Notes",
|
|
2202
|
+
"Tags",
|
|
2203
|
+
// Canonical fields are retained after the visible table columns so exported suites can be imported losslessly.
|
|
2204
|
+
"Module",
|
|
2205
|
+
"Requirements",
|
|
2543
2206
|
"Source_URL"
|
|
2544
2207
|
];
|
|
2545
2208
|
var TEST_DATA_CSV_COLUMNS = [
|
|
@@ -2562,17 +2225,18 @@ function toRow(values) {
|
|
|
2562
2225
|
function testCaseRow(testCase) {
|
|
2563
2226
|
return toRow([
|
|
2564
2227
|
testCase.id,
|
|
2565
|
-
testCase.module,
|
|
2566
|
-
testCase.folder ?? "",
|
|
2567
|
-
(testCase.tags ?? []).join(", "),
|
|
2568
|
-
(testCase.requirements ?? []).join(", "),
|
|
2228
|
+
testCase.folder ?? testCase.module,
|
|
2569
2229
|
testCase.title,
|
|
2570
|
-
testCase.preconditions.join("\n"),
|
|
2571
|
-
describeSteps(testCase.steps),
|
|
2572
|
-
testCase.expectedResult,
|
|
2573
2230
|
testCase.type,
|
|
2574
2231
|
testCase.priority,
|
|
2232
|
+
describeSteps(testCase.steps),
|
|
2233
|
+
testCase.expectedResult,
|
|
2575
2234
|
testCase.automationStatus,
|
|
2235
|
+
testCase.preconditions.join("\n"),
|
|
2236
|
+
testCase.notes ?? "",
|
|
2237
|
+
(testCase.tags ?? []).join(", "),
|
|
2238
|
+
testCase.module,
|
|
2239
|
+
(testCase.requirements ?? []).join(", "),
|
|
2576
2240
|
testCase.sourceUrl
|
|
2577
2241
|
]);
|
|
2578
2242
|
}
|
|
@@ -2600,8 +2264,7 @@ function exportTestCasesToCsv(testCases, testData = []) {
|
|
|
2600
2264
|
// src/commands/scan.ts
|
|
2601
2265
|
async function runScan(options) {
|
|
2602
2266
|
console.log(`checking scan ${redactUrl(options.url)} ...`);
|
|
2603
|
-
const
|
|
2604
|
-
const result = useScoped ? await exploreWithScope(options.url, {
|
|
2267
|
+
const result = await exploreWithScope(options.url, {
|
|
2605
2268
|
startPath: options.startPath,
|
|
2606
2269
|
scopePath: options.scopePath,
|
|
2607
2270
|
mode: options.mode ?? "site",
|
|
@@ -2615,9 +2278,6 @@ async function runScan(options) {
|
|
|
2615
2278
|
maxActionRetries: 2,
|
|
2616
2279
|
explorationTimeoutMs: 3e5
|
|
2617
2280
|
}
|
|
2618
|
-
}) : await exploreWebsite(options.url, {
|
|
2619
|
-
...options.maxPages !== void 0 ? { maxPages: options.maxPages } : {},
|
|
2620
|
-
...options.maxDepth !== void 0 ? { maxDepth: options.maxDepth } : {}
|
|
2621
2281
|
});
|
|
2622
2282
|
const testCases = generateTestCases(result.pages);
|
|
2623
2283
|
const testData = generateTestData(result.pages);
|
|
@@ -3011,20 +2671,32 @@ function registerAnalyzeRoute(app, workspaceRoot) {
|
|
|
3011
2671
|
}
|
|
3012
2672
|
const browserProfileDir = body.projectId ? await browserProfileDirectory(workspaceRoot, body.projectId).catch(() => void 0) : void 0;
|
|
3013
2673
|
try {
|
|
3014
|
-
const result = await
|
|
3015
|
-
|
|
3016
|
-
|
|
2674
|
+
const result = await exploreWithScope(check.url.toString(), {
|
|
2675
|
+
startPath: body.startPath,
|
|
2676
|
+
scopePath: body.scopePath,
|
|
2677
|
+
mode: body.mode ?? "site",
|
|
2678
|
+
debug: body.debug ?? false,
|
|
2679
|
+
limits: {
|
|
2680
|
+
maxPages: clamp(body.maxPages, 1, config.limits.maxPages, config.limits.maxPages),
|
|
2681
|
+
maxDepth: clamp(body.maxDepth, 0, config.limits.maxDepth, config.limits.maxDepth),
|
|
2682
|
+
maxStates: 80,
|
|
2683
|
+
maxActionsPerState: 8,
|
|
2684
|
+
maxTotalActions: 200,
|
|
2685
|
+
maxActionRetries: 2,
|
|
2686
|
+
explorationTimeoutMs: 3e5
|
|
2687
|
+
}
|
|
2688
|
+
}, {
|
|
3017
2689
|
waitAfterNavigationMs: clamp(body.waitAfterNavigationMs, 0, 5e3, 750),
|
|
3018
2690
|
blockedKeywords: normalizeBlockedKeywords(body.blockedKeywords),
|
|
3019
2691
|
...browserProfileDir ? { browserProfileDir } : {}
|
|
3020
|
-
}
|
|
2692
|
+
});
|
|
3021
2693
|
if (result.pages.length === 0) {
|
|
3022
2694
|
const firstIssue = result.issues[0];
|
|
3023
2695
|
throw new ExplorerError(firstIssue?.code ?? "navigation-failed", firstIssue?.message ?? "Could not open the website.", "Check that the URL is correct and the website is available.");
|
|
3024
2696
|
}
|
|
3025
2697
|
const testCases = [
|
|
3026
2698
|
...generateTestCases(result.pages, { language: body.language ?? "en" }),
|
|
3027
|
-
...generateStateFlowTestCases(result.actionGraph)
|
|
2699
|
+
...body.language === "th" ? localizeThai(generateStateFlowTestCases(result.actionGraph)) : generateStateFlowTestCases(result.actionGraph)
|
|
3028
2700
|
];
|
|
3029
2701
|
const runEvents = [
|
|
3030
2702
|
{
|
|
@@ -3695,8 +3367,6 @@ function debugLocator(stage, detail) {
|
|
|
3695
3367
|
console.log(`[LazyScout:${stage}]`, safe);
|
|
3696
3368
|
}
|
|
3697
3369
|
async function ensureSafeClick(target, fallbackLabel, blockedKeywords) {
|
|
3698
|
-
if (blockedKeywords.length === 0)
|
|
3699
|
-
return;
|
|
3700
3370
|
const labels = await Promise.all([
|
|
3701
3371
|
target.getAttribute("aria-label").catch(() => null),
|
|
3702
3372
|
target.getAttribute("title").catch(() => null),
|
|
@@ -3704,7 +3374,10 @@ async function ensureSafeClick(target, fallbackLabel, blockedKeywords) {
|
|
|
3704
3374
|
target.getAttribute("id").catch(() => null),
|
|
3705
3375
|
target.innerText().catch(() => "")
|
|
3706
3376
|
]);
|
|
3707
|
-
|
|
3377
|
+
const values = [fallbackLabel, ...labels.map((value) => value ?? void 0)];
|
|
3378
|
+
if (isUnsafeAutoClick(...values))
|
|
3379
|
+
throw new Error(`Blocked by mandatory safety policy: ${fallbackLabel}`);
|
|
3380
|
+
if (isBlockedLabel(blockedKeywords, ...values)) {
|
|
3708
3381
|
throw new Error(`Blocked by the Project click filter: ${fallbackLabel}`);
|
|
3709
3382
|
}
|
|
3710
3383
|
}
|
|
@@ -4246,7 +3919,7 @@ async function openInBrowser(url) {
|
|
|
4246
3919
|
}
|
|
4247
3920
|
|
|
4248
3921
|
// src/version.ts
|
|
4249
|
-
var VERSION = true ? "0.3.
|
|
3922
|
+
var VERSION = true ? "0.3.6" : "0.0.0-dev";
|
|
4250
3923
|
|
|
4251
3924
|
// src/commands/serve.ts
|
|
4252
3925
|
var DEFAULT_PORT = 4321;
|