aria-ease 7.1.0 → 7.2.0
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/ComboboxComponentStrategy-DHZS4NW6.js +5 -0
- package/dist/MenuComponentStrategy-L3QXLC6S.js +5 -0
- package/dist/cli.cjs +3 -3
- package/dist/cli.js +1 -1
- package/dist/{contractTestRunnerPlaywright-IUUAGMXP.js → contractTestRunnerPlaywright-2CEH3GPM.js} +2 -2
- package/dist/{contractTestRunnerPlaywright-44QPA5JG.js → contractTestRunnerPlaywright-RUKMUY5P.js} +2 -2
- package/dist/index.cjs +11 -11
- package/dist/index.js +9 -9
- package/dist/src/utils/test/ComboboxComponentStrategy-5AWO63DA.js +5 -0
- package/dist/src/utils/test/MenuComponentStrategy-QHVBLUBR.js +5 -0
- package/dist/src/utils/test/{contractTestRunnerPlaywright-VALOFEZZ.js → contractTestRunnerPlaywright-LUWM3RIL.js} +2 -2
- package/dist/src/utils/test/dsl/index.cjs +1 -1
- package/dist/src/utils/test/dsl/index.js +1 -1
- package/dist/src/utils/test/index.cjs +5 -5
- package/dist/src/utils/test/index.js +1 -1
- package/dist/{test-MWX7KH44.js → test-PCRWMQUO.js} +1 -1
- package/package.json +1 -1
- package/dist/ComboboxComponentStrategy-YSYLR2U5.js +0 -5
- package/dist/MenuComponentStrategy-C22BZEBH.js +0 -5
- package/dist/src/utils/test/ComboboxComponentStrategy-SICWLI27.js +0 -5
- package/dist/src/utils/test/MenuComponentStrategy-R4VPAHDE.js +0 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
'use strict';var playwright=require('playwright'),Me=require('path'),Be=require('fs-extra'),test=require('@playwright/test'),url=require('url'),fs=require('fs'),I=require('chalk'),xt=require('readline');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Me__default=/*#__PURE__*/_interopDefault(Me);var Be__default=/*#__PURE__*/_interopDefault(Be);var I__default=/*#__PURE__*/_interopDefault(I);var xt__default=/*#__PURE__*/_interopDefault(xt);var
|
|
1
|
+
'use strict';var playwright=require('playwright'),Me=require('path'),Be=require('fs-extra'),test=require('@playwright/test'),url=require('url'),fs=require('fs'),I=require('chalk'),xt=require('readline');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Me__default=/*#__PURE__*/_interopDefault(Me);var Be__default=/*#__PURE__*/_interopDefault(Be);var I__default=/*#__PURE__*/_interopDefault(I);var xt__default=/*#__PURE__*/_interopDefault(xt);var vt=Object.defineProperty;var V=(c,e)=>()=>(c&&(e=c(c=0)),e);var Q=(c,e)=>{for(var t in e)vt(c,t,{get:e[t],enumerable:true});};async function bt(){return re||(re=await playwright.chromium.launch({headless:true,args:["--disable-extensions","--disable-blink-features=AutomationControlled"]})),re}async function Tt(){return ie||(ie=await(await bt()).newContext({permissions:[],ignoreHTTPSErrors:true})),ie}async function De(){return await(await Tt()).newPage()}async function We(){ie&&(await ie.close(),ie=null),re&&(await re.close(),re=null);}var re,ie,be=V(()=>{re=null,ie=null;});function Z(c){return c==="required"||c==="recommended"||c==="optional"?c:$t}function ce(c){return c==="minimal"||c==="balanced"||c==="strict"||c==="paranoid"?c:"balanced"}function Oe(c,e){return {minimal:{required:"error",recommended:"ignore",optional:"ignore"},balanced:{required:"error",recommended:"warning",optional:"ignore"},strict:{required:"error",recommended:"error",optional:"warning"},paranoid:{required:"error",recommended:"error",optional:"error"}}[e][c]}var $t,Te=V(()=>{$t="required";});var Je={};Q(Je,{loadConfig:()=>kt});function St(c){let e=[];if(!c||typeof c!="object")return e.push("Config must be an object"),{valid:false,errors:e};let t=c;if(t.audit!==void 0){if(typeof t.audit!="object"||t.audit===null)e.push("audit must be an object");else if(t.audit.urls!==void 0&&(Array.isArray(t.audit.urls)?t.audit.urls.some(r=>typeof r!="string")&&e.push("audit.urls must contain only strings"):e.push("audit.urls must be an array")),t.audit.output!==void 0)if(typeof t.audit.output!="object")e.push("audit.output must be an object");else {let r=t.audit.output;r.format!==void 0&&(["json","csv","html","all"].includes(r.format)||e.push("audit.output.format must be one of: json, csv, html, all")),r.out!==void 0&&typeof r.out!="string"&&e.push("audit.output.out must be a string");}}if(t.test!==void 0)if(typeof t.test!="object"||t.test===null)e.push("test must be an object");else {t.test.disableTimeouts!==void 0&&typeof t.test.disableTimeouts!="boolean"&&e.push("test.disableTimeouts must be a boolean when provided");let r=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let i of r){let n=t.test[i];n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&e.push(`test.${i} must be a non-negative number when provided`);}t.test.components!==void 0&&(Array.isArray(t.test.components)?t.test.components.forEach((i,n)=>{if(typeof i!="object"||i===null)e.push(`test.components[${n}] must be an object`);else {typeof i.name!="string"&&e.push(`test.components[${n}].name must be a string`),i.contractPath!==void 0&&typeof i.contractPath!="string"&&e.push(`test.components[${n}].contractPath must be a string when provided`),i.strategyPath!==void 0&&typeof i.strategyPath!="string"&&e.push(`test.components[${n}].strategyPath must be a string when provided`),i.strictness!==void 0&&!["minimal","balanced","strict","paranoid"].includes(i.strictness)&&e.push(`test.components[${n}].strictness must be one of: minimal, balanced, strict, paranoid`),i.disableTimeouts!==void 0&&typeof i.disableTimeouts!="boolean"&&e.push(`test.components[${n}].disableTimeouts must be a boolean when provided`);let a=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let o of a){let f=i[o];f!==void 0&&(typeof f!="number"||!Number.isFinite(f)||f<0)&&e.push(`test.components[${n}].${o} must be a non-negative number when provided`);}}}):e.push("test.components must be an array")),t.test.strictness!==void 0&&(["minimal","balanced","strict","paranoid"].includes(t.test.strictness)||e.push("test.strictness must be one of: minimal, balanced, strict, paranoid"));}return t.contracts!==void 0&&(Array.isArray(t.contracts)?t.contracts.forEach((r,i)=>{typeof r!="object"||r===null?e.push(`contracts[${i}] must be an object`):(typeof r.src!="string"&&e.push(`contracts[${i}].src is required and must be a string`),r.out!==void 0&&typeof r.out!="string"&&e.push(`contracts[${i}].out must be a string`));}):e.push("contracts must be an array")),{valid:e.length===0,errors:e}}async function Ct(c){try{let e=Me__default.default.extname(c);if(e===".json"){let t=await Be__default.default.readFile(c,"utf-8");return JSON.parse(t)}else if([".js",".mjs",".cjs",".ts"].includes(e)){let t=await import(c);return t.default||t}return null}catch{return null}}async function kt(c=process.cwd()){let e=["ariaease.config.js","ariaease.config.mjs","ariaease.config.cjs","ariaease.config.json","ariaease.config.ts"],t=null,r=null,i=[];for(let n of e){let a=Me__default.default.resolve(c,n);if(await Be__default.default.pathExists(a)){if(r=a,t=await Ct(a),t===null){i.push(`Found config at ${n} but failed to load it. Check for syntax errors.`);continue}let o=St(t);if(!o.valid){i.push(`Config validation failed in ${n}:`),i.push(...o.errors.map(f=>` - ${f}`)),t=null;continue}break}}return {config:t||{},configPath:t?r:null,errors:i}}var Ke=V(()=>{});var ze={};Q(ze,{MenuComponentStrategy:()=>Se});var Se,Ge=V(()=>{Se=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>false))return;let n=false,a=this.selectors.main;if(a&&(await e.locator(a).first().focus(),await e.keyboard.press("Escape"),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n&&this.selectors.main&&(await e.locator(this.selectors.main).first().click({timeout:this.actionTimeoutMs}),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),n||(await e.mouse.click(10,10),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n)throw new Error(`\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
|
|
2
2
|
1. Escape key
|
|
3
3
|
2. Clicking trigger
|
|
4
4
|
3. Clicking outside
|
|
5
|
-
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus();}async shouldSkipTest(e,t){if(!(e.action.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")||e.assertions.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")))return false;let i=this.selectors.submenuTrigger;return i?await t.locator(i).count()===0:true}getMainSelector(){return this.mainSelector}};});var Ne={};Q(Ne,{AccordionComponentStrategy:()=>Ce});var Ce,Ye=V(()=>{Ce=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.panel||!this.selectors.trigger||this.selectors.popup)return;let t=this.selectors.trigger,r=this.selectors.panel;if(!t||!r)return;let i=await e.locator(t).all();for(let n of i){let a=await n.getAttribute("aria-expanded")==="true",o=await n.getAttribute("aria-controls");if(a&&o){await n.click({timeout:this.actionTimeoutMs});let f=e.locator(`#${o}`);await test.expect(f).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{});}}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var Qe={};Q(Qe,{ComboboxComponentStrategy:()=>Ae});var Ae,Xe=V(()=>{Ae=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>false))return;let n=false,a=this.selectors.
|
|
5
|
+
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus();}async shouldSkipTest(e,t){if(!(e.action.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")||e.assertions.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")))return false;let i=this.selectors.submenuTrigger;return i?await t.locator(i).count()===0:true}getMainSelector(){return this.mainSelector}};});var Ne={};Q(Ne,{AccordionComponentStrategy:()=>Ce});var Ce,Ye=V(()=>{Ce=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.panel||!this.selectors.trigger||this.selectors.popup)return;let t=this.selectors.trigger,r=this.selectors.panel;if(!t||!r)return;let i=await e.locator(t).all();for(let n of i){let a=await n.getAttribute("aria-expanded")==="true",o=await n.getAttribute("aria-controls");if(a&&o){await n.click({timeout:this.actionTimeoutMs});let f=e.locator(`#${o}`);await test.expect(f).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{});}}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var Qe={};Q(Qe,{ComboboxComponentStrategy:()=>Ae});var Ae,Xe=V(()=>{Ae=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>false))return;let n=false,a=this.selectors.main;if(a&&(await e.locator(a).first().focus(),await e.keyboard.press("Escape"),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n&&this.selectors.button&&(await e.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),n||(await e.mouse.click(10,10),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
|
|
6
6
|
1. Escape key
|
|
7
7
|
2. Clicking button
|
|
8
8
|
3. Clicking outside
|
|
@@ -27,15 +27,15 @@ ${"\u2550".repeat(60)}`),this.log(`\u{1F4CA} Summary
|
|
|
27
27
|
`),o>0?(this.log("\u{1F527} Next Steps:"),this.log(" 1. Review the failures above"),this.log(" 2. Fix ARIA attributes and keyboard handlers"),this.log(` 3. Re-run tests to verify fixes
|
|
28
28
|
`)):!this.isPlaywright&&this.skipped>0&&this.log(`\u2728 Optional: Run Playwright tests for complete validation
|
|
29
29
|
`),{passes:a,failures:o,skipped:this.skipped,duration:t}}error(e,t){this.log(`
|
|
30
|
-
\u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("");}};});var nt={};Q(nt,{RelativeTargetResolver:()=>O});var O,me=V(()=>{O=class{static async resolve(e,t,r){let i=await e.locator(t).all();if(typeof r=="number")return i[r-1];switch(r){case "first":return i[0];case "second":return i[1];case "last":return i[i.length-1];case "next":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])+1)%i.length;return i[a]}case "previous":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])-1+i.length)%i.length;return i[a]}default:return null}}};});var ne,ot=V(()=>{me();ne=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,t,r){try{if(e==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let a=this.page.locator(n).first();return await a.count()?(await a.evaluate((f,S)=>{f.setAttribute("aria-activedescendant",S);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let a=await O.resolve(this.page,n,t);return a?(await a.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let i=this.selectors[e];return i?(await this.page.locator(i).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${e}: ${i instanceof Error?i.message:String(i)}`}}}async type(e,t){try{let r=this.selectors[e];return r?(await this.page.locator(r).first().fill(t,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${e}: ${r instanceof Error?r.message:String(r)}`}}}async click(e,t){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for click action."};let n=await O.resolve(this.page,i,t);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for click.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${e}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(e,t,r){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[t]||t;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),e==="focusable"&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Home","End","Tab","Shift+Tab"].includes(n))return await this.page.keyboard.press(n),{success:!0};if(e==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let S=this.selectors.relative;if(!S)return {success:!1,error:"Relative selector not defined for keypress action."};let y=await O.resolve(this.page,S,r);return y?(await y.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let a=this.selectors[e];if(!a)return {success:!1,error:`Selector for keypress target ${e} not found.`};let o=this.page.locator(a).first();return await o.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await o.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${t} on ${e}: ${i instanceof Error?i.message:String(i)}`}}}async hover(e,t){try{if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for hover action."};let n=await O.resolve(this.page,i,t);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for hover.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${e}: ${r instanceof Error?r.message:String(r)}`}}}};});var le,at=V(()=>{me();le=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}async resolveTarget(e,t,r){try{if(e==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!t)return {target:null,error:"Relative target or expected value is not defined."};let a=await O.resolve(this.page,n,t);return a?{target:a}:{target:null,error:`Target ${e} not found.`}}let i=this.selectors[e];return i?{target:this.page.locator(i).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(i){return {target:null,error:`Failed to resolve target ${e}: ${i instanceof Error?i.message:String(i)}`}}}async validateVisibility(e,t,r,i,n){try{return r?(await test.expect(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${n}".`}):(await test.expect(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${n}".`})}catch{let a=this.selectors[t]||"",o=await this.page.evaluate(f=>{let S=f?document.querySelector(f):null;if(!S)return "element not found";let y=window.getComputedStyle(S);return `display:${y.display}, visibility:${y.visibility}, opacity:${y.opacity}`},a);return r?{success:false,failMessage:`${i} (actual: ${o})`}:{success:false,failMessage:`${i} ${t} is still visible (actual: ${o}).`}}}async validateAttribute(e,t,r,i,n,a){if(i==="!empty"){let S=await e.getAttribute(r);return S&&S.trim()!==""?{success:true,passMessage:`${t} has non-empty "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should not be empty, found "${S}".`}}if(typeof i!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",i),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(i)}`);let o=i.split(" | ").map(S=>S.trim()),f=await e.getAttribute(r);return f!==null&&o.includes(f)?{success:true,passMessage:`${t} has expected "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should be "${i}", found "${f}".`}}async validateValue(e,t,r,i,n){let a=await e.inputValue().catch(()=>"");return r==="!empty"?a&&a.trim()!==""?{success:true,passMessage:`${t} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should not be empty, found "${a}".`}:r===""?a===""?{success:true,passMessage:`${t} has empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be empty, found "${a}".`}:a===r?{success:true,passMessage:`${t} has expected value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be "${r}", found "${a}".`}}async validateFocus(e,t,r,i,n){try{return r?(await test.expect(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${n}".`}):(await test.expect(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${n}".`})}catch{let a=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${i} (actual focus: ${a})`}}}async validateRole(e,t,r,i,n){let a=await e.getAttribute("role");return a===r?{success:true,passMessage:`${t} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${i} Expected role "${r}", found "${a}".`}}async validate(e,t){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,i;if(e.controlledBy){let n=e.controlledBy,a=this.selectors[n.target];if(!a)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let o=null;if(n.relativeTarget?o=await O.resolve(this.page,a,n.relativeTarget):o=this.page.locator(a).first(),!o)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let f=n.attribute||"aria-controls",S=await o.getAttribute(f);if(!S)return {success:false,failMessage:`Controlling element does not have attribute '${f}'.`,target:null};if(r=this.page.locator(`#${S}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${S}' not found.`,target:null}}else {let n=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(r=n.target,i=n.error,i||!r)return {success:false,failMessage:i||`Target ${e.target} not found.`,target:null}}if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let n=await O.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),a=n?await n.getAttribute("id"):null,o=await r.getAttribute("aria-activedescendant");return a&&o===a?{success:true,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case "toBeVisible":return this.validateVisibility(r,e.target,true,e.failureMessage||"",t);case "notToBeVisible":return this.validateVisibility(r,e.target,false,e.failureMessage||"",t);case "toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(r,e.target,e.attribute,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return e.expectedValue!==void 0?this.validateValue(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,e.target,true,e.failureMessage||"",t);case "notToHaveFocus":return this.validateFocus(r,e.target,false,e.failureMessage||"",t);case "toHaveRole":return e.expectedValue!==void 0?this.validateRole(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${e.assertion}`}}}};});var ct={};Q(ct,{runContractTestsPlaywright:()=>Et});async function Et(c,e,t,r,i){let n=r?.test?.components?.find(h=>h.name===c),a=!!n?.contractPath,o=new de(true,a),f={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},S=r?.test?.disableTimeouts===true,x=n?.disableTimeouts===true||S,P=(h,_,J)=>{if(x)return 0;let D=h??_;return typeof D!="number"||!Number.isFinite(D)||D<0?J:D},z=P(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,f.actionTimeoutMs),ee=P(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,f.assertionTimeoutMs),ue=P(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,f.navigationTimeoutMs),ye=P(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,f.componentReadyTimeoutMs),Le=ce(t),te=n?.contractPath;if(!te)throw new Error(`Contract path not found for component: ${c}`);let gt=(()=>{if(Me__default.default.isAbsolute(te))return te;if(i){let _=Me__default.default.resolve(i,te);try{return fs.readFileSync(_,"utf-8"),_}catch{}}let h=Me__default.default.resolve(process.cwd(),te);try{return fs.readFileSync(h,"utf-8"),h}catch{return new URL(te,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname}})(),dt=fs.readFileSync(gt,"utf-8"),C=JSON.parse(dt),mt=(C.relationships?.length||0)+(C.static[0]?.assertions.length||0)+C.dynamic.length,ht=C.meta?.source?.apg,H=[],G=[],N=[],B=[],T=null,M=(h,_)=>{let J=Z(_),D=Oe(J,Le);if(D==="error")return H.push(h),{status:"fail",level:J,detail:h};if(D==="warning")return G.push(h),{status:"warn",level:J,detail:h};let K=`${h} (ignored by strictness=${Le}, level=${J})`;return B.push(K),{status:"skip",level:J,detail:K}};try{if(T=await De(),e){try{await T.goto(e,{waitUntil:"domcontentloaded",timeout:ue});}catch(s){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${s instanceof Error?s.message:String(s)}`)}await T.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let h=await ge.detect(c,n,z,ee,i);if(!h)throw new Error(`Unsupported component: ${c}`);let _=h.getMainSelector();if(!_)throw new Error(`CRITICAL: No selector found in contract for ${c}`);try{await T.locator(_).first().waitFor({state:"attached",timeout:ye});}catch(s){throw new Error(`
|
|
30
|
+
\u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("");}};});var nt={};Q(nt,{RelativeTargetResolver:()=>O});var O,me=V(()=>{O=class{static async resolve(e,t,r){let i=await e.locator(t).all();if(typeof r=="number")return i[r-1];switch(r){case "first":return i[0];case "second":return i[1];case "last":return i[i.length-1];case "next":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])+1)%i.length;return i[a]}case "previous":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])-1+i.length)%i.length;return i[a]}default:return null}}};});var ne,ot=V(()=>{me();ne=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,t,r){try{if(e==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let a=this.page.locator(n).first();return await a.count()?(await a.evaluate((f,S)=>{f.setAttribute("aria-activedescendant",S);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let a=await O.resolve(this.page,n,t);return a?(await a.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let i=this.selectors[e];return i?(await this.page.locator(i).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${e}: ${i instanceof Error?i.message:String(i)}`}}}async type(e,t){try{let r=this.selectors[e];return r?(await this.page.locator(r).first().fill(t,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${e}: ${r instanceof Error?r.message:String(r)}`}}}async click(e,t){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for click action."};let n=await O.resolve(this.page,i,t);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for click.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${e}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(e,t,r){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[t]||t;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),e==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let S=this.selectors.relative;if(!S)return {success:!1,error:"Relative selector not defined for keypress action."};let y=await O.resolve(this.page,S,r);return y?(await y.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let a=this.selectors[e];if(!a)return {success:!1,error:`Selector for keypress target ${e} not found.`};let o=this.page.locator(a).first();return await o.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await o.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${t} on ${e}: ${i instanceof Error?i.message:String(i)}`}}}async hover(e,t){try{if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for hover action."};let n=await O.resolve(this.page,i,t);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for hover.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${e}: ${r instanceof Error?r.message:String(r)}`}}}};});var le,at=V(()=>{me();le=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}async resolveTarget(e,t,r){try{if(e==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!t)return {target:null,error:"Relative target or expected value is not defined."};let a=await O.resolve(this.page,n,t);return a?{target:a}:{target:null,error:`Target ${e} not found.`}}let i=this.selectors[e];return i?{target:this.page.locator(i).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(i){return {target:null,error:`Failed to resolve target ${e}: ${i instanceof Error?i.message:String(i)}`}}}async validateVisibility(e,t,r,i,n){try{return r?(await test.expect(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${n}".`}):(await test.expect(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${n}".`})}catch{let a=this.selectors[t]||"",o=await this.page.evaluate(f=>{let S=f?document.querySelector(f):null;if(!S)return "element not found";let y=window.getComputedStyle(S);return `display:${y.display}, visibility:${y.visibility}, opacity:${y.opacity}`},a);return r?{success:false,failMessage:`${i} (actual: ${o})`}:{success:false,failMessage:`${i} ${t} is still visible (actual: ${o}).`}}}async validateAttribute(e,t,r,i,n,a){if(i==="!empty"){let S=await e.getAttribute(r);return S&&S.trim()!==""?{success:true,passMessage:`${t} has non-empty "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should not be empty, found "${S}".`}}if(typeof i!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",i),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(i)}`);let o=i.split(" | ").map(S=>S.trim()),f=await e.getAttribute(r);return f!==null&&o.includes(f)?{success:true,passMessage:`${t} has expected "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should be "${i}", found "${f}".`}}async validateValue(e,t,r,i,n){let a=await e.inputValue().catch(()=>"");return r==="!empty"?a&&a.trim()!==""?{success:true,passMessage:`${t} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should not be empty, found "${a}".`}:r===""?a===""?{success:true,passMessage:`${t} has empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be empty, found "${a}".`}:a===r?{success:true,passMessage:`${t} has expected value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be "${r}", found "${a}".`}}async validateFocus(e,t,r,i,n){try{return r?(await test.expect(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${n}".`}):(await test.expect(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${n}".`})}catch{let a=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${i} (actual focus: ${a})`}}}async validateRole(e,t,r,i,n){let a=await e.getAttribute("role");return a===r?{success:true,passMessage:`${t} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${i} Expected role "${r}", found "${a}".`}}async validate(e,t){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,i;if(e.controlledBy){let n=e.controlledBy,a=this.selectors[n.target];if(!a)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let o=null;if(n.relativeTarget?o=await O.resolve(this.page,a,n.relativeTarget):o=this.page.locator(a).first(),!o)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let f=n.attribute||"aria-controls",S=await o.getAttribute(f);if(!S)return {success:false,failMessage:`Controlling element does not have attribute '${f}'.`,target:null};if(r=this.page.locator(`#${S}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${S}' not found.`,target:null}}else {let n=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(r=n.target,i=n.error,i||!r)return {success:false,failMessage:i||`Target ${e.target} not found.`,target:null}}if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let n=await O.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),a=n?await n.getAttribute("id"):null,o=await r.getAttribute("aria-activedescendant");return a&&o===a?{success:true,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case "toBeVisible":return this.validateVisibility(r,e.target,true,e.failureMessage||"",t);case "notToBeVisible":return this.validateVisibility(r,e.target,false,e.failureMessage||"",t);case "toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(r,e.target,e.attribute,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return e.expectedValue!==void 0?this.validateValue(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,e.target,true,e.failureMessage||"",t);case "notToHaveFocus":return this.validateFocus(r,e.target,false,e.failureMessage||"",t);case "toHaveRole":return e.expectedValue!==void 0?this.validateRole(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${e.assertion}`}}}};});var ct={};Q(ct,{runContractTestsPlaywright:()=>Et});async function Et(c,e,t,r,i){let n=r?.test?.components?.find(h=>h.name===c),a=!!n?.contractPath,o=new de(true,a),f={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},S=r?.test?.disableTimeouts===true,x=n?.disableTimeouts===true||S,P=(h,_,J)=>{if(x)return 0;let D=h??_;return typeof D!="number"||!Number.isFinite(D)||D<0?J:D},z=P(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,f.actionTimeoutMs),ee=P(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,f.assertionTimeoutMs),ue=P(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,f.navigationTimeoutMs),ye=P(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,f.componentReadyTimeoutMs),Le=ce(t),te=n?.contractPath;if(!te)throw new Error(`Contract path not found for component: ${c}`);let gt=(()=>{if(Me__default.default.isAbsolute(te))return te;if(i){let _=Me__default.default.resolve(i,te);try{return fs.readFileSync(_,"utf-8"),_}catch{}}let h=Me__default.default.resolve(process.cwd(),te);try{return fs.readFileSync(h,"utf-8"),h}catch{return new URL(te,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname}})(),dt=fs.readFileSync(gt,"utf-8"),C=JSON.parse(dt),mt=(C.relationships?.length||0)+(C.static[0]?.assertions.length||0)+C.dynamic.length,ht=C.meta?.source?.apg,H=[],G=[],N=[],B=[],T=null,M=(h,_)=>{let J=Z(_),D=Oe(J,Le);if(D==="error")return H.push(h),{status:"fail",level:J,detail:h};if(D==="warning")return G.push(h),{status:"warn",level:J,detail:h};let K=`${h} (ignored by strictness=${Le}, level=${J})`;return B.push(K),{status:"skip",level:J,detail:K}};try{if(T=await De(),e){try{await T.goto(e,{waitUntil:"domcontentloaded",timeout:ue});}catch(s){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${s instanceof Error?s.message:String(s)}`)}await T.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let h=await ge.detect(c,n,z,ee,i);if(!h)throw new Error(`Unsupported component: ${c}`);let _=h.getMainSelector();if(!_)throw new Error(`CRITICAL: No selector found in contract for ${c}`);try{await T.locator(_).first().waitFor({state:"attached",timeout:ye});}catch(s){throw new Error(`
|
|
31
31
|
\u274C CRITICAL: Component not found on page!
|
|
32
32
|
This usually means:
|
|
33
33
|
- The component didn't render
|
|
34
34
|
- The URL is incorrect
|
|
35
35
|
- The component selector '${_}' in the contract is wrong
|
|
36
|
-
- Original error: ${s}`)}o.start(c,mt,ht),c==="menu"&&C.selectors.main&&await T.locator(C.selectors.main).first().waitFor({state:"visible",timeout:ye}).catch(()=>{});let J=c==="menu"&&C.selectors.submenuTrigger?await T.locator(C.selectors.submenuTrigger).count()>0:!1,D=s=>s.type==="aria-reference"&&[s.from,s.to].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||""))||s.type==="contains"&&[s.parent,s.child].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||"")),K=0,L=0,F=0;for(let s of C.relationships||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(m){G.push(`Warning: resetState failed before relationship test: ${m instanceof Error?m.message:String(m)}`);}let g=Z(s.level);if(Array.isArray(s.setup)&&s.setup.length>0){let $=function(p){return w.includes(p)};var Fe=$;let m=new ne(T,C.selectors,z),R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,w=["focus","type","click","keypress","hover"],v=p=>({...p,type:$(p.type)?p.type:"click"}),k=s.setup.map(v),E=await we(k,m,h,T,R,["submenu","submenuTrigger","submenuItems"]);if(E.skip){B.push(E.message||"Setup action skipped"),o.reportStaticTest(R,"skip",E.message,g);continue}if(!E.success){let p=`Relationship setup failed: ${E.error}`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(R,u.status,u.detail,u.level);continue}}if(c==="menu"&&!J&&D(s)){let R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,w="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";B.push(w),o.reportStaticTest(R,"skip",w,g);continue}if(s.type==="aria-reference"){let m=`${s.from}.${s.attribute} references ${s.to}`,R=C.selectors[s.from],w=C.selectors[s.to];if(!R||!w){let d=M(`Relationship selector missing: from="${s.from}" or to="${s.to}" not found in selectors.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let $=T.locator(R).first(),v=T.locator(w).first(),k=await $.count()>0,E=await v.count()>0;if(!k||!E){if(c==="menu"&&D(s)){let U="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";B.push(U),o.reportStaticTest(m,"skip",U,g);continue}let d=M(`Relationship target not found: ${k?s.to:s.from}.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let p=await $.getAttribute(s.attribute),u=await v.getAttribute("id");if(!u){let d=M(`Relationship target "${s.to}" must have an id for ${s.attribute} validation.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}if(!(p||"").split(/\s+/).filter(Boolean).includes(u)){let d=M(`Expected ${s.from} ${s.attribute} to reference id "${u}", found "${p||""}".`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}N.push(`Relationship valid: ${s.from}.${s.attribute} -> ${s.to} (id=${u}).`),K+=1,o.reportStaticTest(m,"pass",void 0,g);continue}if(s.type==="contains"){let m=`${s.parent} contains ${s.child}`,R=C.selectors[s.parent],w=C.selectors[s.child];if(!R||!w){let p=M(`Relationship selector missing: parent="${s.parent}" or child="${s.child}" not found in selectors.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}let $=T.locator(R).first();if(!(await $.count()>0)){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";B.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Relationship parent target not found: ${s.parent}.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}if(await $.locator(w).count()<1){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";B.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Expected ${s.parent} to contain descendant matching selector for ${s.child}.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}N.push(`Relationship valid: ${s.parent} contains ${s.child}.`),K+=1,o.reportStaticTest(m,"pass",void 0,g);}}async function Ve(s,g,m,R={}){if(!s||typeof s!="object"||!("ref"in s))return s;let w;if(s.ref==="relative"){if(!s.relativeTarget||!R.relativeBaseSelector)return;let $=m.locator(R.relativeBaseSelector),v=await $.count(),k=0;if(s.relativeTarget==="first"?k=0:s.relativeTarget==="second"?k=1:s.relativeTarget==="last"?k=v-1:isNaN(Number(s.relativeTarget))?k=0:k=Number(s.relativeTarget),k<0||k>=v)return;let E=$.nth(k);return await Ue(E,s.property||s.attribute)}else {if(w=g[s.ref],!w)throw new Error(`Selector for ref '${s.ref}' not found in contract selectors.`);let $=m.locator(w).first();return await Ue($,s.property||s.attribute)}}async function Ue(s,g){if(s)return !g||g==="id"?await s.getAttribute("id")??void 0:g==="class"?await s.getAttribute("class")??void 0:g==="textContent"?await s.evaluate(m=>m.textContent??void 0):g.startsWith("aria-")?await s.getAttribute(g)??void 0:g.endsWith("*")?await s.evaluate(R=>{let w=[];for(let $ of Array.from(R.attributes))$.name.startsWith("aria-")&&w.push(`${$.name}=${$.value}`);return w.join(";")}):await s.getAttribute(g)??void 0}let yt=new le(T,C.selectors,ee);async function we(s,g,m,R,w,$=[]){if(!Array.isArray(s)||s.length===0)return {success:!0};m&&typeof m.resetState=="function"&&await m.resetState(R);for(let v of s){let k={success:!0};try{if(v.type==="focus")v.target==="relative"&&v.relativeTarget?k=await g.focus("relative",v.relativeTarget):k=await g.focus(v.target);else if(v.type==="type"&&v.value)k=await g.type(v.target,v.value);else if(v.type==="click")k=await g.click(v.target,v.relativeTarget);else if(v.type==="keypress"&&v.key)k=await g.keypress(v.target,v.key,v.relativeTarget);else if(v.type==="hover")k=await g.hover(v.target,v.relativeTarget);else continue}catch(E){k={success:!1,error:E instanceof Error?E.message:String(E)};}if(!k.success){let E=k.error||"Setup action failed";return $.some(u=>w.includes(u)||E.includes(u))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${E}`}:{success:!1,error:E}}}return {success:!0}}for(let s of C.static[0]?.assertions||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(p){G.push(`Warning: resetState failed before static test: ${p instanceof Error?p.message:String(p)}`);}if(s.target==="relative")continue;let g=`${s.target}${s.attribute?` (${s.attribute})`:""}`,m=Z(s.level);if(c==="menu"&&s.target==="submenuTrigger"&&!J){let p=`Skipping submenu static assertion for ${s.target}: no submenu capability detected in rendered component.`;B.push(p),o.reportStaticTest(g,"skip",p,m);continue}let R=[];if(s.target||R.push("target"),s.attribute||R.push("attribute"),typeof s.expectedValue>"u"&&R.push("expectedValue"),R.length>0){let p=`${s.target||""}${s.attribute?` (${s.attribute})`:""}`,u=`Static assertion missing required field(s): ${R.join(", ")}`,b=M(u,s.level);b.status==="fail"&&(L+=1),b.status==="warn"&&(F+=1),o.reportStaticTest(p,b.status,b.detail,b.level);continue}if(Array.isArray(s.setup)&&s.setup.length>0){let b=function(l){return u.includes(l)};var Fe=b;let p=new ne(T,C.selectors,z),u=["focus","type","click","keypress","hover"],W=l=>({...l,type:b(l.type)?l.type:"click"}),d=s.setup.map(W),U=await we(d,p,h,T,g,["submenu","submenuTrigger","submenuItems"]);if(U.skip){B.push(U.message||"Setup action skipped"),o.reportStaticTest(g,"skip",U.message,m);continue}if(!U.success){let l=`Static setup failed: ${U.error}`,A=M(l,s.level);A.status==="fail"&&(L+=1),A.status==="warn"&&(F+=1),o.reportStaticTest(g,A.status,A.detail,A.level);continue}}let w=C.selectors[s.target];if(!w){let p=`Selector for target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let $=T.locator(w).first();if(!(await $.count()>0)){let p=`Target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let k=(p,u,b)=>{let W=new RegExp(`\\[${u}(?:=["']?([^\\]"']+)["']?)?\\]`),d=p.match(W);if(!d)return !1;if(!b)return !0;let U=d[1];return U?b.split(" | ").includes(U):!1},E=s.expectedValue;if(s.expectedValue&&typeof s.expectedValue=="object"&&"ref"in s.expectedValue){let p={},u=s.relativeTarget;if(s.expectedValue.ref==="relative"&&s.target==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}else if(s.expectedValue.ref==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}E=await Ve(s.expectedValue,C.selectors,T,p);}if(s.expectedValue)if(k(w,s.attribute,typeof E=="string"?E:void 0))N.push(`${s.attribute}="${E}" on ${s.target} verified by selector (already present in: ${w}).`),K+=1,o.reportStaticTest(g,"pass",void 0,m);else {let p=E??"",u=await yt.validateAttribute($,s.target,s.attribute,p,s.failureMessage,"Static ARIA Test");if(u.success&&u.passMessage)N.push(u.passMessage),K+=1,o.reportStaticTest(g,"pass",void 0,m);else if(!u.success&&u.failMessage){let b=M(u.failMessage,s.level);b.status==="fail"&&(L+=1),b.status==="warn"&&(F+=1),o.reportStaticTest(g,b.status,b.detail,b.level);}}else {let p=s.attribute.split(" | "),u=!1,b=!0;for(let W of p){let d=W.trim();if(k(w,d)){N.push(`${d} on ${s.target} verified by selector (already present in: ${w}).`),u=!0;continue}if(b=!1,await $.getAttribute(d)!==null){u=!0;break}}if(!u&&!b){let W=s.failureMessage+` None of the attributes "${s.attribute}" are present.`,d=M(W,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(g,d.status,d.detail,d.level);}else !b&&u?(N.push(`At least one of the attributes "${s.attribute}" exists on the element.`),K+=1,o.reportStaticTest(g,"pass",void 0,m)):(K+=1,o.reportStaticTest(g,"pass",void 0,m));}}for(let s of C.dynamic||[]){if(!s.assertions||s.assertions.length===0){let l="Skipping test - no assertions found for this dynamic test.";B.push(l),o.reportTest({description:s.description,level:Z(s.level)},"skip",l);continue}if(!T||T.isClosed()){console.warn(`
|
|
36
|
+
- Original error: ${s}`)}o.start(c,mt,ht),c==="menu"&&C.selectors.main&&await T.locator(C.selectors.main).first().waitFor({state:"visible",timeout:ye}).catch(()=>{});let J=c==="menu"&&C.selectors.submenuTrigger?await T.locator(C.selectors.submenuTrigger).count()>0:!1,D=s=>s.type==="aria-reference"&&[s.from,s.to].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||""))||s.type==="contains"&&[s.parent,s.child].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||"")),K=0,L=0,F=0;for(let s of C.relationships||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(m){G.push(`Warning: resetState failed before relationship test: ${m instanceof Error?m.message:String(m)}`);}let g=Z(s.level);if(Array.isArray(s.setup)&&s.setup.length>0){let $=function(p){return v.includes(p)};var Fe=$;let m=new ne(T,C.selectors,z),R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v=["focus","type","click","keypress","hover"],w=p=>({...p,type:$(p.type)?p.type:"click"}),k=s.setup.map(w),E=await ve(k,m,h,T,R,["submenu","submenuTrigger","submenuItems"]);if(E.skip){B.push(E.message||"Setup action skipped"),o.reportStaticTest(R,"skip",E.message,g);continue}if(!E.success){let p=`Relationship setup failed: ${E.error}`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(R,u.status,u.detail,u.level);continue}}if(c==="menu"&&!J&&D(s)){let R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";B.push(v),o.reportStaticTest(R,"skip",v,g);continue}if(s.type==="aria-reference"){let m=`${s.from}.${s.attribute} references ${s.to}`,R=C.selectors[s.from],v=C.selectors[s.to];if(!R||!v){let d=M(`Relationship selector missing: from="${s.from}" or to="${s.to}" not found in selectors.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let $=T.locator(R).first(),w=T.locator(v).first(),k=await $.count()>0,E=await w.count()>0;if(!k||!E){if(c==="menu"&&D(s)){let U="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";B.push(U),o.reportStaticTest(m,"skip",U,g);continue}let d=M(`Relationship target not found: ${k?s.to:s.from}.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let p=await $.getAttribute(s.attribute),u=await w.getAttribute("id");if(!u){let d=M(`Relationship target "${s.to}" must have an id for ${s.attribute} validation.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}if(!(p||"").split(/\s+/).filter(Boolean).includes(u)){let d=M(`Expected ${s.from} ${s.attribute} to reference id "${u}", found "${p||""}".`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}N.push(`Relationship valid: ${s.from}.${s.attribute} -> ${s.to} (id=${u}).`),K+=1,o.reportStaticTest(m,"pass",void 0,g);continue}if(s.type==="contains"){let m=`${s.parent} contains ${s.child}`,R=C.selectors[s.parent],v=C.selectors[s.child];if(!R||!v){let p=M(`Relationship selector missing: parent="${s.parent}" or child="${s.child}" not found in selectors.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}let $=T.locator(R).first();if(!(await $.count()>0)){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";B.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Relationship parent target not found: ${s.parent}.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}if(await $.locator(v).count()<1){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";B.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Expected ${s.parent} to contain descendant matching selector for ${s.child}.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}N.push(`Relationship valid: ${s.parent} contains ${s.child}.`),K+=1,o.reportStaticTest(m,"pass",void 0,g);}}async function Ve(s,g,m,R={}){if(!s||typeof s!="object"||!("ref"in s))return s;let v;if(s.ref==="relative"){if(!s.relativeTarget||!R.relativeBaseSelector)return;let $=m.locator(R.relativeBaseSelector),w=await $.count(),k=0;if(s.relativeTarget==="first"?k=0:s.relativeTarget==="second"?k=1:s.relativeTarget==="last"?k=w-1:isNaN(Number(s.relativeTarget))?k=0:k=Number(s.relativeTarget),k<0||k>=w)return;let E=$.nth(k);return await Ue(E,s.property||s.attribute)}else {if(v=g[s.ref],!v)throw new Error(`Selector for ref '${s.ref}' not found in contract selectors.`);let $=m.locator(v).first();return await Ue($,s.property||s.attribute)}}async function Ue(s,g){if(s)return !g||g==="id"?await s.getAttribute("id")??void 0:g==="class"?await s.getAttribute("class")??void 0:g==="textContent"?await s.evaluate(m=>m.textContent??void 0):g.startsWith("aria-")?await s.getAttribute(g)??void 0:g.endsWith("*")?await s.evaluate(R=>{let v=[];for(let $ of Array.from(R.attributes))$.name.startsWith("aria-")&&v.push(`${$.name}=${$.value}`);return v.join(";")}):await s.getAttribute(g)??void 0}let yt=new le(T,C.selectors,ee);async function ve(s,g,m,R,v,$=[]){if(!Array.isArray(s)||s.length===0)return {success:!0};m&&typeof m.resetState=="function"&&await m.resetState(R);for(let w of s){let k={success:!0};try{if(w.type==="focus")w.target==="relative"&&w.relativeTarget?k=await g.focus("relative",w.relativeTarget):k=await g.focus(w.target);else if(w.type==="type"&&w.value)k=await g.type(w.target,w.value);else if(w.type==="click")k=await g.click(w.target,w.relativeTarget);else if(w.type==="keypress"&&w.key)k=await g.keypress(w.target,w.key,w.relativeTarget);else if(w.type==="hover")k=await g.hover(w.target,w.relativeTarget);else continue}catch(E){k={success:!1,error:E instanceof Error?E.message:String(E)};}if(!k.success){let E=k.error||"Setup action failed";return $.some(u=>v.includes(u)||E.includes(u))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${E}`}:{success:!1,error:E}}}return {success:!0}}for(let s of C.static[0]?.assertions||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(p){G.push(`Warning: resetState failed before static test: ${p instanceof Error?p.message:String(p)}`);}if(s.target==="relative")continue;let g=`${s.target}${s.attribute?` (${s.attribute})`:""}`,m=Z(s.level);if(c==="menu"&&s.target==="submenuTrigger"&&!J){let p=`Skipping submenu static assertion for ${s.target}: no submenu capability detected in rendered component.`;B.push(p),o.reportStaticTest(g,"skip",p,m);continue}let R=[];if(s.target||R.push("target"),s.attribute||R.push("attribute"),typeof s.expectedValue>"u"&&R.push("expectedValue"),R.length>0){let p=`${s.target||""}${s.attribute?` (${s.attribute})`:""}`,u=`Static assertion missing required field(s): ${R.join(", ")}`,b=M(u,s.level);b.status==="fail"&&(L+=1),b.status==="warn"&&(F+=1),o.reportStaticTest(p,b.status,b.detail,b.level);continue}if(Array.isArray(s.setup)&&s.setup.length>0){let b=function(l){return u.includes(l)};var Fe=b;let p=new ne(T,C.selectors,z),u=["focus","type","click","keypress","hover"],W=l=>({...l,type:b(l.type)?l.type:"click"}),d=s.setup.map(W),U=await ve(d,p,h,T,g,["submenu","submenuTrigger","submenuItems"]);if(U.skip){B.push(U.message||"Setup action skipped"),o.reportStaticTest(g,"skip",U.message,m);continue}if(!U.success){let l=`Static setup failed: ${U.error}`,A=M(l,s.level);A.status==="fail"&&(L+=1),A.status==="warn"&&(F+=1),o.reportStaticTest(g,A.status,A.detail,A.level);continue}}let v=C.selectors[s.target];if(!v){let p=`Selector for target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let $=T.locator(v).first();if(!(await $.count()>0)){let p=`Target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let k=(p,u,b)=>{let W=new RegExp(`\\[${u}(?:=["']?([^\\]"']+)["']?)?\\]`),d=p.match(W);if(!d)return !1;if(!b)return !0;let U=d[1];return U?b.split(" | ").includes(U):!1},E=s.expectedValue;if(s.expectedValue&&typeof s.expectedValue=="object"&&"ref"in s.expectedValue){let p={},u=s.relativeTarget;if(s.expectedValue.ref==="relative"&&s.target==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}else if(s.expectedValue.ref==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}E=await Ve(s.expectedValue,C.selectors,T,p);}if(s.expectedValue)if(k(v,s.attribute,typeof E=="string"?E:void 0))N.push(`${s.attribute}="${E}" on ${s.target} verified by selector (already present in: ${v}).`),K+=1,o.reportStaticTest(g,"pass",void 0,m);else {let p=E??"",u=await yt.validateAttribute($,s.target,s.attribute,p,s.failureMessage,"Static ARIA Test");if(u.success&&u.passMessage)N.push(u.passMessage),K+=1,o.reportStaticTest(g,"pass",void 0,m);else if(!u.success&&u.failMessage){let b=M(u.failMessage,s.level);b.status==="fail"&&(L+=1),b.status==="warn"&&(F+=1),o.reportStaticTest(g,b.status,b.detail,b.level);}}else {let p=s.attribute.split(" | "),u=!1,b=!0;for(let W of p){let d=W.trim();if(k(v,d)){N.push(`${d} on ${s.target} verified by selector (already present in: ${v}).`),u=!0;continue}if(b=!1,await $.getAttribute(d)!==null){u=!0;break}}if(!u&&!b){let W=s.failureMessage+` None of the attributes "${s.attribute}" are present.`,d=M(W,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(g,d.status,d.detail,d.level);}else !b&&u?(N.push(`At least one of the attributes "${s.attribute}" exists on the element.`),K+=1,o.reportStaticTest(g,"pass",void 0,m)):(K+=1,o.reportStaticTest(g,"pass",void 0,m));}}for(let s of C.dynamic||[]){if(!s.assertions||s.assertions.length===0){let l="Skipping test - no assertions found for this dynamic test.";B.push(l),o.reportTest({description:s.description,level:Z(s.level)},"skip",l);continue}if(!T||T.isClosed()){console.warn(`
|
|
37
37
|
\u26A0\uFE0F Browser closed - skipping remaining ${C.dynamic.length-C.dynamic.indexOf(s)} tests
|
|
38
|
-
`),H.push(`CRITICAL: Browser/page closed before completing all tests. ${C.dynamic.length-C.dynamic.indexOf(s)} tests skipped.`);break}try{await h.resetState(T);}catch(l){let A=l instanceof Error?l.message:String(l);throw o.error(A),l}let{setup:g=[],action:m,assertions:R}=s,
|
|
38
|
+
`),H.push(`CRITICAL: Browser/page closed before completing all tests. ${C.dynamic.length-C.dynamic.indexOf(s)} tests skipped.`);break}try{await h.resetState(T);}catch(l){let A=l instanceof Error?l.message:String(l);throw o.error(A),l}let{setup:g=[],action:m,assertions:R}=s,v=Z(s.level),$=new ne(T,C.selectors,z);if(Array.isArray(g)&&g.length>0){let A=function(j){return l.includes(j)};var Fe=A;let l=["focus","type","click","keypress","hover"],se=j=>({...j,type:A(j.type)?j.type:"click"}),we=g.map(se),q=await ve(we,$,h,T,s.description,["submenu","submenuTrigger","submenuItems"]);if(q.skip){B.push(q.message||"Setup action skipped"),o.reportTest({description:s.description,level:v},"skip",q.message);continue}if(!q.success){let j=M(`Setup failed: ${q.error}`,s.level);o.reportTest({description:s.description,level:v},j.status,j.detail);continue}}let w=H.length,k=G.length,E=B.length;if(await h.shouldSkipTest(s,T)){let l="Skipping test - component-specific conditions not met";B.push(l),o.reportTest({description:s.description,level:v},"skip",l);continue}let u=new le(T,C.selectors,ee),b=!1,W=null;for(let l of m){if(!T||T.isClosed()){H.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),b=!0;break}let A;if(l.type==="focus")l.target==="relative"&&l.relativeTarget?A=await $.focus("relative",l.relativeTarget):A=await $.focus(l.target);else if(l.type==="type"&&l.value)A=await $.type(l.target,l.value);else if(l.type==="click")A=await $.click(l.target,l.relativeTarget);else if(l.type==="keypress"&&l.key)A=await $.keypress(l.target,l.key,l.relativeTarget);else if(l.type==="hover")A=await $.hover(l.target,l.relativeTarget);else continue;if(!A.success){if(A.error){let se=M(A.error,s.level);W={status:se.status,detail:se.detail};}b=!0;break}}if(b){o.reportTest({description:s.description,level:v},W?.status||"fail",W?.detail||H[H.length-1]);continue}for(let l of R){let A;if(l.expectedValue&&typeof l.expectedValue=="object"&&"ref"in l.expectedValue)if(l.expectedValue.ref==="relative"){let{RelativeTargetResolver:Y}=await Promise.resolve().then(()=>(me(),nt)),j=C.selectors.relative;if(!j)throw new Error("Relative selector not defined in contract selectors.");let ae=l.relativeTarget||"first",X=await Y.resolve(T,j,ae);if(!X)throw new Error(`Could not resolve relative target '${ae}' for expectedValue.`);let He=l.expectedValue.property||l.expectedValue.attribute||"id";if(He==="textContent")A=await X.evaluate(pe=>pe.textContent??void 0);else {let pe=await X.getAttribute(He);A=pe===null?void 0:pe;}}else A=await Ve(l.expectedValue,C.selectors,T,{});else typeof l.expectedValue=="string"||typeof l.expectedValue>"u"?A=l.expectedValue:A="";let se={...l,expectedValue:A},we=A??"",q=await u.validate({...se,expectedValue:we},s.description);if(q.success&&q.passMessage)N.push(q.passMessage);else if(!q.success&&q.failMessage){let Y=[];if(l.target||Y.push("target"),l.assertion||Y.push("assertion"),["toHaveAttribute","toHaveValue","toHaveRole"].includes(l.assertion)&&(typeof l.attribute>"u"&&l.assertion==="toHaveAttribute"&&Y.push("attribute"),typeof l.expectedValue>"u"&&Y.push("expectedValue")),Y.length>0){let j=Z(l.level||s.level),ae=`Dynamic assertion missing required field(s): ${Y.join(", ")}`,X=M(ae,j);if(X.status==="skip")continue;H.push(ae),o.reportTest({description:s.description,level:j},X.status,X.detail);continue}}}let d=H.length,U=G.length,je=B.length;d>w?o.reportTest({description:s.description,level:v},"fail",H[H.length-1]):U>k?o.reportTest({description:s.description,level:v},"warn",G[G.length-1]):je>E?o.reportTest({description:s.description,level:v},"skip",B[B.length-1]):o.reportTest({description:s.description,level:v},"pass");}o.reportStatic(K,L,F),o.summary(H);}catch(h){if(h instanceof Error)throw h.message.includes("Executable doesn't exist")||h.message.includes("browserType.launch")?new Error(`
|
|
39
39
|
\u274C CRITICAL: Playwright browsers not found!
|
|
40
40
|
\u{1F4E6} Run: npx playwright install chromium`):h.message.includes("net::ERR_CONNECTION_REFUSED")||h.message.includes("NS_ERROR_CONNECTION_REFUSED")?new Error(`
|
|
41
41
|
\u274C CRITICAL: Cannot connect to dev server!
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {d,b}from'./chunk-APUMBDOT.js';import m from'path';async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=d(c.strictness),o={},d$1=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import('./configLoader-NCYRL2O6.js'),n=await t(process.cwd());if(o=n.config,n.configPath&&(d$1=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=d(r??o.test?.strictness);}}catch{c.strictness===void 0&&(p="balanced");}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import('./contractTestRunnerPlaywright-
|
|
1
|
+
import {d,b}from'./chunk-APUMBDOT.js';import m from'path';async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=d(c.strictness),o={},d$1=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import('./configLoader-NCYRL2O6.js'),n=await t(process.cwd());if(o=n.config,n.configPath&&(d$1=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=d(r??o.test?.strictness);}}catch{c.strictness===void 0&&(p="balanced");}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import('./contractTestRunnerPlaywright-LUWM3RIL.js');s=await n(a,t,p,o,d$1);}else throw new Error(`\u274C Dev server not running at ${e}
|
|
2
2
|
Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(t){throw t instanceof Error?t:new Error(`\u274C Contract test execution failed: ${String(t)}`)}let u={violations:i.violations,raw:i,contract:s};if(s.failures.length>0&&e==="Playwright")throw new Error(`
|
|
3
3
|
\u274C ${s.failures.length} accessibility contract test${s.failures.length>1?"s":""} failed (Playwright mode)
|
|
4
4
|
\u2705 ${s.passes.length} test${s.passes.length>1?"s":""} passed
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as g,d as f}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";import m from"path";async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=f(c.strictness),o={},d=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import("./configLoader-ZXTSCIP6.js"),n=await t(process.cwd());if(o=n.config,n.configPath&&(d=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=f(r??o.test?.strictness)}}catch{c.strictness===void 0&&(p="balanced")}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import("./contractTestRunnerPlaywright-
|
|
1
|
+
import{b as g,d as f}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";import m from"path";async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=f(c.strictness),o={},d=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import("./configLoader-ZXTSCIP6.js"),n=await t(process.cwd());if(o=n.config,n.configPath&&(d=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=f(r??o.test?.strictness)}}catch{c.strictness===void 0&&(p="balanced")}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import("./contractTestRunnerPlaywright-2CEH3GPM.js");s=await n(a,t,p,o,d)}else throw new Error(`\u274C Dev server not running at ${e}
|
|
2
2
|
Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(t){throw t instanceof Error?t:new Error(`\u274C Contract test execution failed: ${String(t)}`)}let u={violations:i.violations,raw:i,contract:s};if(s.failures.length>0&&e==="Playwright")throw new Error(`
|
|
3
3
|
\u274C ${s.failures.length} accessibility contract test${s.failures.length>1?"s":""} failed (Playwright mode)
|
|
4
4
|
\u2705 ${s.passes.length} test${s.passes.length>1?"s":""} passed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aria-ease",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Accessibility infrastructure for the entire frontend engineering lifecycle. Build accessible patterns, run automated audits, verify component interactions, and gate deployments — all in one system.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-SM6ZKEDR.js";import"./chunk-CNU4N4AY.js";var n=class{constructor(t,r,o=400,c=400){this.mainSelector=t;this.selectors=r;this.actionTimeoutMs=o;this.assertionTimeoutMs=c}async resetState(t){if(!this.selectors.popup)return;let r=this.selectors.popup,o=t.locator(r).first();if(!await o.isVisible().catch(()=>!1))return;let e=!1,s=this.selectors.input;if(!s&&this.selectors.focusable?s=this.selectors.focusable:s||(s=this.selectors.button),s&&(await t.locator(s).first().focus(),await t.keyboard.press("Escape"),e=await(0,i.expect)(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!e&&this.selectors.button&&(await t.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),e=await(0,i.expect)(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),e||(await t.mouse.click(10,10),e=await(0,i.expect)(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!e)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
|
|
2
|
-
1. Escape key
|
|
3
|
-
2. Clicking button
|
|
4
|
-
3. Clicking outside
|
|
5
|
-
This indicates a problem with the combobox component's close functionality.`);this.selectors.input&&await t.locator(this.selectors.input).first().clear()}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}};export{n as ComboboxComponentStrategy};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as r}from"./chunk-SM6ZKEDR.js";import"./chunk-CNU4N4AY.js";var c=class{constructor(t,o,i=400,n=400){this.mainSelector=t;this.selectors=o;this.actionTimeoutMs=i;this.assertionTimeoutMs=n}async resetState(t){if(!this.selectors.popup)return;let o=this.selectors.popup,i=t.locator(o).first();if(!await i.isVisible().catch(()=>!1))return;let s=!1,e=this.selectors.input;if(!e&&this.selectors.focusable?e=this.selectors.focusable:e||(e=this.selectors.main),e&&(await t.locator(e).first().focus(),await t.keyboard.press("Escape"),s=await(0,r.expect)(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!s&&this.selectors.main&&(await t.locator(this.selectors.main).first().click({timeout:this.actionTimeoutMs}),s=await(0,r.expect)(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),s||(await t.mouse.click(10,10),s=await(0,r.expect)(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!s)throw new Error(`\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
|
|
2
|
-
1. Escape key
|
|
3
|
-
2. Clicking trigger
|
|
4
|
-
3. Clicking outside
|
|
5
|
-
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await t.locator(this.selectors.input).first().clear(),this.selectors.main&&await t.locator(this.selectors.main).first().focus()}async shouldSkipTest(t,o){if(!(t.action.some(e=>e.target==="submenu"||e.target==="submenuTrigger"||e.target==="submenuItems")||t.assertions.some(e=>e.target==="submenu"||e.target==="submenuTrigger"||e.target==="submenuItems")))return!1;let n=this.selectors.submenuTrigger;return n?await o.locator(n).count()===0:!0}getMainSelector(){return this.mainSelector}};export{c as MenuComponentStrategy};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {expect}from'@playwright/test';var n=class{constructor(t,r,o=400,c=400){this.mainSelector=t;this.selectors=r;this.actionTimeoutMs=o;this.assertionTimeoutMs=c;}async resetState(t){if(!this.selectors.popup)return;let r=this.selectors.popup,o=t.locator(r).first();if(!await o.isVisible().catch(()=>false))return;let e=false,s=this.selectors.input;if(!s&&this.selectors.focusable?s=this.selectors.focusable:s||(s=this.selectors.button),s&&(await t.locator(s).first().focus(),await t.keyboard.press("Escape"),e=await expect(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!e&&this.selectors.button&&(await t.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),e=await expect(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),e||(await t.mouse.click(10,10),e=await expect(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!e)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
|
|
2
|
-
1. Escape key
|
|
3
|
-
2. Clicking button
|
|
4
|
-
3. Clicking outside
|
|
5
|
-
This indicates a problem with the combobox component's close functionality.`);this.selectors.input&&await t.locator(this.selectors.input).first().clear();}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};export{n as ComboboxComponentStrategy};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {expect}from'@playwright/test';var c=class{constructor(t,r,i=400,o=400){this.mainSelector=t;this.selectors=r;this.actionTimeoutMs=i;this.assertionTimeoutMs=o;}async resetState(t){if(!this.selectors.popup)return;let r=this.selectors.popup,i=t.locator(r).first();if(!await i.isVisible().catch(()=>false))return;let s=false,e=this.selectors.input;if(!e&&this.selectors.focusable?e=this.selectors.focusable:e||(e=this.selectors.main),e&&(await t.locator(e).first().focus(),await t.keyboard.press("Escape"),s=await expect(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!s&&this.selectors.main&&(await t.locator(this.selectors.main).first().click({timeout:this.actionTimeoutMs}),s=await expect(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),s||(await t.mouse.click(10,10),s=await expect(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!s)throw new Error(`\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
|
|
2
|
-
1. Escape key
|
|
3
|
-
2. Clicking trigger
|
|
4
|
-
3. Clicking outside
|
|
5
|
-
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await t.locator(this.selectors.input).first().clear(),this.selectors.main&&await t.locator(this.selectors.main).first().focus();}async shouldSkipTest(t,r){if(!(t.action.some(e=>e.target==="submenu"||e.target==="submenuTrigger"||e.target==="submenuItems")||t.assertions.some(e=>e.target==="submenu"||e.target==="submenuTrigger"||e.target==="submenuItems")))return false;let o=this.selectors.submenuTrigger;return o?await r.locator(o).count()===0:true}getMainSelector(){return this.mainSelector}};export{c as MenuComponentStrategy};
|