skopix 2.0.84 → 2.0.85

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.
@@ -3878,21 +3878,40 @@ async function matchStepsToLibrary(suitesDir, steps) {
3878
3878
 
3879
3879
  let count = 0;
3880
3880
  const matched = steps.map(step => {
3881
- const sSel = (step.stableSelector || step.selector || '').toLowerCase();
3881
+ const sSel = (step.stableSelector || step.selector || '').toLowerCase().trim();
3882
3882
  if (!sSel) return step;
3883
3883
 
3884
- // Find matching library element
3885
3884
  const match = library.find(lib => {
3886
- const lSel = (lib.stableSelector || lib.selector || '').toLowerCase();
3885
+ const lSel = (lib.stableSelector || lib.selector || '').toLowerCase().trim();
3887
3886
  if (!lSel) return false;
3888
- // Exact match
3887
+
3888
+ // 1. Exact match
3889
3889
  if (sSel === lSel) return true;
3890
- // One contains the other (handles i.fa-plus vs a[title="x"] i.fa-plus)
3891
- if (sSel.includes(lSel) || lSel.includes(sSel)) return true;
3892
- // Shared key tokens
3893
- const keyTokens = lSel.match(/\.[a-z][a-z0-9_-]+|\[[\w-]+=["'][^"']+["']\]|#[a-z][a-z0-9_-]+/g) || [];
3894
- const strongTokens = keyTokens.filter(t => t.length > 8);
3895
- if (strongTokens.length > 0 && strongTokens.some(tok => sSel.includes(tok))) return true;
3890
+
3891
+ // 2. Extract pi-test-identifier values from both and compare
3892
+ const piFrom = (sSel.match(/pi-test-identifier[*^]?=["']([^"']+)["']/) || [])[1];
3893
+ const piLib = (lSel.match(/pi-test-identifier[*^]?=["']([^"']+)["']/) || [])[1];
3894
+ if (piFrom && piLib) {
3895
+ if (piFrom === piLib) return true;
3896
+ // One starts with the other (handles *= vs =)
3897
+ if (piFrom.startsWith(piLib) || piLib.startsWith(piFrom)) return true;
3898
+ }
3899
+
3900
+ // 3. Both use same has-text value (e.g. :has-text("Mariadb"))
3901
+ const textFrom = (sSel.match(/has-text\(["']([^"']+)["']\)/) || [])[1];
3902
+ const textLib = (lSel.match(/has-text\(["']([^"']+)["']\)/) || [])[1];
3903
+ if (textFrom && textLib && textFrom.toLowerCase() === textLib.toLowerCase()) {
3904
+ // Only match if same element type or one contains the other
3905
+ const tagFrom = sSel.split(':')[0].split(' ').pop();
3906
+ const tagLib = lSel.split(':')[0].split(' ').pop();
3907
+ if (tagFrom === tagLib || sSel.includes(lSel) || lSel.includes(sSel)) return true;
3908
+ }
3909
+
3910
+ // 4. Step selector is a child/descendant of library selector
3911
+ // e.g. "a[title='x'] i.fa-plus" should match "a[title='x']"
3912
+ if (lSel.length > 10 && sSel.includes(lSel)) return true;
3913
+ if (sSel.length > 10 && lSel.includes(sSel)) return true;
3914
+
3896
3915
  return false;
3897
3916
  });
3898
3917
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skopix",
3
- "version": "2.0.84",
3
+ "version": "2.0.85",
4
4
  "description": "Browser-based QA tool — record tests by using your app, replay them deterministically, generate Playwright code automatically",
5
5
  "main": "cli/index.js",
6
6
  "bin": {