@sudobility/testomniac_runner_service 0.1.96 → 0.1.98

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.
@@ -1,3 +1,16 @@
1
1
  import type { AnalyzerContext } from "../types";
2
- export declare function generateNavigationTestInteractions(_analyzer: any, _context: AnalyzerContext): Promise<void>;
2
+ /**
3
+ * Create direct navigation interactions for same-origin links discovered on
4
+ * the current page. These are placed in the "Direct Navigations" surface
5
+ * which runs as execution group 0 (before hover/content interactions), so
6
+ * discovered pages get short dependency chains.
7
+ *
8
+ * Navigation interactions never have a dependencyTestInteractionId — they
9
+ * navigate directly via goto.
10
+ *
11
+ * Items are passed through selectRepresentativeItems so that product grids
12
+ * (18 product links with the same structure) produce only a few representative
13
+ * navigations instead of one per product.
14
+ */
15
+ export declare function generateNavigationTestInteractions(analyzer: any, context: AnalyzerContext): Promise<void>;
3
16
  //# sourceMappingURL=navigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/page-analyzer/generators/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,wBAAsB,kCAAkC,CACtD,SAAS,EAAE,GAAG,EACd,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,IAAI,CAAC,CAKf"}
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/page-analyzer/generators/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,wBAAsB,kCAAkC,CACtD,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,IAAI,CAAC,CAkFf"}
@@ -1,7 +1,98 @@
1
- export async function generateNavigationTestInteractions(_analyzer, _context) {
2
- // Navigation surface is managed externally (scan bootstrap + auto-created
3
- // navigations from hover-click discovery). Do not reconcile reconciling
4
- // with desiredKeys: [] would retire auto-created navigation interactions
5
- // before the runner can execute them.
1
+ /**
2
+ * Create direct navigation interactions for same-origin links discovered on
3
+ * the current page. These are placed in the "Direct Navigations" surface
4
+ * which runs as execution group 0 (before hover/content interactions), so
5
+ * discovered pages get short dependency chains.
6
+ *
7
+ * Navigation interactions never have a dependencyTestInteractionId — they
8
+ * navigate directly via goto.
9
+ *
10
+ * Items are passed through selectRepresentativeItems so that product grids
11
+ * (18 product links with the same structure) produce only a few representative
12
+ * navigations instead of one per product.
13
+ */
14
+ export async function generateNavigationTestInteractions(analyzer, context) {
15
+ const { api, runnerId, testEnvironmentId, sizeClass, uid, bundleRun } = context;
16
+ // Only generate for discovery runs that have a navigation surface
17
+ if (!context.navigationSurface || !bundleRun)
18
+ return;
19
+ const navSurfaceId = context.navigationSurface.id;
20
+ // Filter to navigation items with valid same-origin hrefs
21
+ const navItems = context.actionableItems.filter(item => {
22
+ if (item.actionKind !== "navigate" || !item.href)
23
+ return false;
24
+ // Skip anchors, mailto, tel, javascript
25
+ if (item.href === "#" ||
26
+ item.href.startsWith("#") ||
27
+ item.href.startsWith("mailto:") ||
28
+ item.href.startsWith("tel:") ||
29
+ item.href.startsWith("javascript:")) {
30
+ return false;
31
+ }
32
+ // Skip action URLs (e.g. add-to-cart links with side effects)
33
+ const path = extractRelativePath(item.href);
34
+ if (!path)
35
+ return false;
36
+ if (isActionUrl(path))
37
+ return false;
38
+ // Skip current page
39
+ if (path === context.currentPath)
40
+ return false;
41
+ return true;
42
+ });
43
+ if (navItems.length === 0)
44
+ return;
45
+ // Apply the same representative-item dedup used for hover/content
46
+ // interactions — product grid links get capped to MAX_REPS_PER_STYLE
47
+ const representative = analyzer.selectRepresentativeItems(navItems);
48
+ // Deduplicate by relative path
49
+ const seenPaths = new Set();
50
+ seenPaths.add(context.currentPath);
51
+ const navPaths = [];
52
+ for (const item of representative) {
53
+ const path = extractRelativePath(item.href);
54
+ if (!path || seenPaths.has(path))
55
+ continue;
56
+ seenPaths.add(path);
57
+ navPaths.push(path);
58
+ }
59
+ if (navPaths.length === 0)
60
+ return;
61
+ // Get the open surface run for Direct Navigations
62
+ const surfaceRuns = await api.getOpenTestSurfaceRuns(bundleRun.id);
63
+ const navSurfaceRun = surfaceRuns.find((sr) => sr.testSurfaceId === navSurfaceId);
64
+ if (!navSurfaceRun)
65
+ return;
66
+ for (const path of navPaths) {
67
+ const navInteraction = analyzer.buildNavigationTestInteraction(path, sizeClass, uid);
68
+ const saved = await api.ensureTestInteraction(runnerId, navSurfaceId, navInteraction, testEnvironmentId);
69
+ try {
70
+ await api.createTestInteractionRun({
71
+ testInteractionId: saved.id,
72
+ testSurfaceRunId: navSurfaceRun.id,
73
+ });
74
+ }
75
+ catch {
76
+ // Run may already exist
77
+ }
78
+ }
79
+ // Do NOT reconcile — other navigation interactions (from hover-click
80
+ // discovery or scan bootstrap) should not be retired.
81
+ }
82
+ function extractRelativePath(href) {
83
+ try {
84
+ const url = new URL(href, "http://placeholder");
85
+ return url.pathname + url.search;
86
+ }
87
+ catch {
88
+ return null;
89
+ }
90
+ }
91
+ /**
92
+ * Detect URLs that trigger server-side actions (add to cart, delete, etc.)
93
+ * rather than navigating to a viewable page.
94
+ */
95
+ function isActionUrl(path) {
96
+ return /[?&](ec_action|action|add_to_cart|remove|delete)=/i.test(path);
6
97
  }
7
98
  //# sourceMappingURL=navigation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../../../src/analyzer/page-analyzer/generators/navigation.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,SAAc,EACd,QAAyB;IAEzB,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,sCAAsC;AACxC,CAAC"}
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../../../src/analyzer/page-analyzer/generators/navigation.ts"],"names":[],"mappings":"AAEA;;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C3B,gBAAgB,EAAE,aAAa,CAAC,EAAE;aACnC,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,sDAAsD;AACxD,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAChD,OAAO,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,oDAAoD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/testomniac_runner_service",
3
- "version": "0.1.96",
3
+ "version": "0.1.98",
4
4
  "description": "Shared scanning logic for Testomniac scanner and Chrome extension",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",