pre auto insert
This commit is contained in:
22
server.ts
22
server.ts
@@ -75,17 +75,23 @@ function appendSuggestion(data: any) {
|
||||
if (data.id) lines.push(`static ${name}id = "#${data.id}"`);
|
||||
if (data.ariaLabel) lines.push(`static ${name}aria = "[aria-label='${data.ariaLabel}']"`);
|
||||
lines.push(``);
|
||||
lines.push(`// Suggested get function (use whichever selector fits best):`);
|
||||
lines.push(`// Suggested get function:`);
|
||||
|
||||
// Prefer aria > id > class for the get function selector variable
|
||||
const selectorVar = data.ariaLabel
|
||||
? `Mainpage.${name}aria`
|
||||
: data.id
|
||||
? `Mainpage.${name}id`
|
||||
: `Mainpage.${name}class`;
|
||||
// Selector: aria if available, otherwise class
|
||||
const selectorVar = data.ariaLabel ? `Mainpage.${name}aria` : `Mainpage.${name}class`;
|
||||
|
||||
// Always include text and tag if available
|
||||
const hasText = data.text && data.text.length > 0;
|
||||
const filterParts: string[] = [];
|
||||
if (data.tag) filterParts.push(`data.tag: "${data.tag}"`);
|
||||
if (hasText) filterParts.push(`text: "${data.text}"`);
|
||||
|
||||
lines.push(`get ${name}() {`);
|
||||
lines.push(` return cy.get(${selectorVar});`);
|
||||
if (hasText) {
|
||||
lines.push(` return cy.nccontains(${selectorVar}, '${data.text}');`);
|
||||
} else {
|
||||
lines.push(` return cy.get(${selectorVar});`);
|
||||
}
|
||||
lines.push(`}`);
|
||||
lines.push(``);
|
||||
lines.push(`// ------------------------------------------------`);
|
||||
|
||||
Reference in New Issue
Block a user