demo ready

This commit is contained in:
2026-02-23 01:29:15 +01:00
parent f4fd3fd6c5
commit f2eb31bdc7
12 changed files with 1917 additions and 144 deletions

View File

@@ -21,7 +21,7 @@ interface ParsedGetFn {
name: string;
body: string; // full body text
referencedStatics: string[]; // static variable names used in body
nccontainsText: string | null; // text in nccontains() if present
containsText: string | null; // text in contains() if present
}
function parsePageObject(): ParsedPageObject {
@@ -70,11 +70,11 @@ function parsePageObject(): ParsedPageObject {
body.includes(s)
);
// Extract nccontains text if present: nccontains(Mainpage.foo, 'some text')
const ncMatch = body.match(/nccontains\s*\([^,]+,\s*['"](.+?)['"]\s*\)/);
const nccontainsText = ncMatch ? ncMatch[1] : null;
// Extract contains text if present: contains(Mainpage.foo, 'some text')
const ncMatch = body.match(/contains\s*\([^,]+,\s*['"](.+?)['"]\s*\)/);
const containsText = ncMatch ? ncMatch[1] : null;
getFunctions.push({ name: fnName, body, referencedStatics, nccontainsText });
getFunctions.push({ name: fnName, body, referencedStatics, containsText });
continue;
}
@@ -116,9 +116,9 @@ function findMatch(data: any, po: ParsedPageObject): MatchResult {
const referencesMatch = fn.referencedStatics.some(s => matchingStatics.includes(s));
if (!referencesMatch) continue;
// If we have text, require nccontains to match it
// If we have text, require contains to match it
if (rawText) {
if (fn.nccontainsText && fn.nccontainsText.toLowerCase() === rawText.toLowerCase()) {
if (fn.containsText && fn.containsText.toLowerCase() === rawText.toLowerCase()) {
return { type: "full_match", fnName: fn.name };
}
} else {
@@ -228,7 +228,7 @@ function handleClick(data: any) {
// Static exists, just create the get function
const getFnName = buildGetFnName(data);
const getBody = hasText
? ` return cy.nccontains(${match.selectorVar}, '${rawText}');`
? ` return cy.contains(${match.selectorVar}, '${rawText}');`
: ` return cy.get(${match.selectorVar});`;
const getBlock = ` get ${getFnName}() {\n${getBody}\n }`;
@@ -250,7 +250,7 @@ function handleClick(data: any) {
const staticName = data.ariaLabel ? `${baseName}aria` : `${baseName}class`;
const staticLine = `static ${staticName} = ${staticValue}`;
const getBody = hasText
? ` return cy.nccontains(${selectorVar}, '${rawText}');`
? ` return cy.contains(${selectorVar}, '${rawText}');`
: ` return cy.get(${selectorVar});`;
const getBlock = ` get ${getFnName}() {\n${getBody}\n }`;