aria-ease 7.0.1 → 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/RelativeTargetResolver-PDJM3ZJI.js +1 -0
- package/dist/TabsComponentStrategy-LKV6D2B7.js +1 -0
- package/dist/chunk-WIWSYIGK.js +1 -0
- package/dist/cli.cjs +61 -61
- package/dist/cli.js +1 -1
- package/dist/contractTestRunnerPlaywright-2CEH3GPM.js +46 -0
- package/dist/contractTestRunnerPlaywright-RUKMUY5P.js +46 -0
- package/dist/index.cjs +41 -41
- package/dist/index.d.cts +35 -11
- package/dist/index.d.ts +35 -11
- package/dist/index.js +14 -14
- 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/RelativeTargetResolver-5SIQLWPN.js +1 -0
- package/dist/src/utils/test/TabsComponentStrategy-DTQQUCK2.js +1 -0
- package/dist/src/utils/test/chunk-WIWSYIGK.js +1 -0
- package/dist/src/utils/test/contractTestRunnerPlaywright-LUWM3RIL.js +46 -0
- package/dist/src/utils/test/dsl/index.cjs +1 -1
- package/dist/src/utils/test/dsl/index.d.cts +35 -11
- package/dist/src/utils/test/dsl/index.d.ts +35 -11
- package/dist/src/utils/test/dsl/index.js +1 -1
- package/dist/src/utils/test/index.cjs +36 -36
- package/dist/src/utils/test/index.js +1 -1
- package/dist/{test-VXSCSKV5.js → test-PCRWMQUO.js} +1 -1
- package/package.json +2 -2
- package/dist/ComboboxComponentStrategy-YSYLR2U5.js +0 -5
- package/dist/MenuComponentStrategy-C22BZEBH.js +0 -5
- package/dist/RelativeTargetResolver-T4P25J2M.js +0 -1
- package/dist/TabsComponentStrategy-ADEEFJXM.js +0 -1
- package/dist/chunk-BHNO4ZI3.js +0 -1
- package/dist/contractTestRunnerPlaywright-FOCQTM4L.js +0 -46
- package/dist/contractTestRunnerPlaywright-QPU6HZXG.js +0 -46
- package/dist/src/utils/test/ComboboxComponentStrategy-SICWLI27.js +0 -5
- package/dist/src/utils/test/MenuComponentStrategy-R4VPAHDE.js +0 -5
- package/dist/src/utils/test/RelativeTargetResolver-UQQMZHI6.js +0 -1
- package/dist/src/utils/test/TabsComponentStrategy-L2PYNEW6.js +0 -1
- package/dist/src/utils/test/chunk-BHNO4ZI3.js +0 -1
- package/dist/src/utils/test/contractTestRunnerPlaywright-YZCMF64Q.js +0 -46
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as s}from"./chunk-SM6ZKEDR.js";import"./chunk-CNU4N4AY.js";var r=class{constructor(t,i,o=400,c=400){this.mainSelector=t;this.selectors=i;this.actionTimeoutMs=o;this.assertionTimeoutMs=c}async resetState(t){if(!this.selectors.popup)return;let i=this.selectors.popup,o=t.locator(i).first();if(!await o.isVisible().catch(()=>!1))return;let e=!1,n=this.selectors.main;if(n&&(await t.locator(n).first().focus(),await t.keyboard.press("Escape"),e=await(0,s.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,s.expect)(o).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),e||(await t.mouse.click(10,10),e=await(0,s.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{r as ComboboxComponentStrategy};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as r}from"./chunk-SM6ZKEDR.js";import"./chunk-CNU4N4AY.js";var c=class{constructor(e,o,i=400,n=400){this.mainSelector=e;this.selectors=o;this.actionTimeoutMs=i;this.assertionTimeoutMs=n}async resetState(e){if(!this.selectors.popup)return;let o=this.selectors.popup,i=e.locator(o).first();if(!await i.isVisible().catch(()=>!1))return;let s=!1,t=this.selectors.main;if(t&&(await e.locator(t).first().focus(),await e.keyboard.press("Escape"),s=await(0,r.expect)(i).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!s&&this.selectors.main&&(await e.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 e.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 e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus()}async shouldSkipTest(e,o){if(!(e.action.some(t=>t.target==="submenu"||t.target==="submenuTrigger"||t.target==="submenuItems")||e.assertions.some(t=>t.target==="submenu"||t.target==="submenuTrigger"||t.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-WIWSYIGK.js";import"./chunk-CNU4N4AY.js";export{a as RelativeTargetResolver};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-CNU4N4AY.js";var o=class{constructor(t,e){this.mainSelector=t;this.selectors=e}async resetState(){}async shouldSkipTest(t,e){if(t.orientation!==void 0&&this.selectors.tablist){let r=this.selectors.tablist,i=await e.locator(r).first().getAttribute("aria-orientation");if(t.orientation!==i)return!0}return!1}getMainSelector(){return this.mainSelector}};export{o as TabsComponentStrategy};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=class{static async resolve(t,n,r){let e=await t.locator(n).all();if(typeof r=="number")return e[r-1];switch(r){case"first":return e[0];case"second":return e[1];case"last":return e[e.length-1];case"next":{let s=(await t.evaluate(([c])=>Array.from(document.querySelectorAll(c)).indexOf(document.activeElement),[n])+1)%e.length;return e[s]}case"previous":{let s=(await t.evaluate(([c])=>Array.from(document.querySelectorAll(c)).indexOf(document.activeElement),[n])-1+e.length)%e.length;return e[s]}default:return null}}};export{a};
|
package/dist/cli.cjs
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var os=Object.create;var He=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var as=Object.getOwnPropertyNames;var cs=Object.getPrototypeOf,ls=Object.prototype.hasOwnProperty;var
|
|
2
|
+
"use strict";var os=Object.create;var He=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var as=Object.getOwnPropertyNames;var cs=Object.getPrototypeOf,ls=Object.prototype.hasOwnProperty;var j=(c,e)=>()=>(c&&(e=c(c=0)),e);var X=(c,e)=>{for(var t in e)He(c,t,{get:e[t],enumerable:!0})},Oe=(c,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of as(e))!ls.call(c,s)&&s!==t&&He(c,s,{get:()=>e[s],enumerable:!(r=ns(e,s))||r.enumerable});return c},Ae=(c,e,t)=>(Oe(c,e,"default"),t&&Oe(t,e,"default")),I=(c,e,t)=>(t=c!=null?os(cs(c)):{},Oe(e||!c||!c.__esModule?He(t,"default",{value:c,enumerable:!0}):t,c));var _e={};X(_e,{loadConfig:()=>Je});function us(c){let e=[];if(!c||typeof c!="object")return e.push("Config must be an object"),{valid:!1,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 s of r){let i=t.test[s];i!==void 0&&(typeof i!="number"||!Number.isFinite(i)||i<0)&&e.push(`test.${s} must be a non-negative number when provided`)}t.test.components!==void 0&&(Array.isArray(t.test.components)?t.test.components.forEach((s,i)=>{if(typeof s!="object"||s===null)e.push(`test.components[${i}] must be an object`);else{typeof s.name!="string"&&e.push(`test.components[${i}].name must be a string`),s.contractPath!==void 0&&typeof s.contractPath!="string"&&e.push(`test.components[${i}].contractPath must be a string when provided`),s.strategyPath!==void 0&&typeof s.strategyPath!="string"&&e.push(`test.components[${i}].strategyPath must be a string when provided`),s.strictness!==void 0&&!["minimal","balanced","strict","paranoid"].includes(s.strictness)&&e.push(`test.components[${i}].strictness must be one of: minimal, balanced, strict, paranoid`),s.disableTimeouts!==void 0&&typeof s.disableTimeouts!="boolean"&&e.push(`test.components[${i}].disableTimeouts must be a boolean when provided`);let n=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let a of n){let l=s[a];l!==void 0&&(typeof l!="number"||!Number.isFinite(l)||l<0)&&e.push(`test.components[${i}].${a} 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,s)=>{typeof r!="object"||r===null?e.push(`contracts[${s}] must be an object`):(typeof r.src!="string"&&e.push(`contracts[${s}].src is required and must be a string`),r.out!==void 0&&typeof r.out!="string"&&e.push(`contracts[${s}].out must be a string`))}):e.push("contracts must be an array")),{valid:e.length===0,errors:e}}async function ps(c){try{let e=Ne.default.extname(c);if(e===".json"){let t=await We.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 Je(c=process.cwd()){let e=["ariaease.config.js","ariaease.config.mjs","ariaease.config.cjs","ariaease.config.json","ariaease.config.ts"],t=null,r=null,s=[];for(let i of e){let n=Ne.default.resolve(c,i);if(await We.default.pathExists(n)){if(r=n,t=await ps(n),t===null){s.push(`Found config at ${i} but failed to load it. Check for syntax errors.`);continue}let a=us(t);if(!a.valid){s.push(`Config validation failed in ${i}:`),s.push(...a.errors.map(l=>` - ${l}`)),t=null;continue}break}}return{config:t||{},configPath:t?r:null,errors:s}}var Ne,We,Re=j(()=>{"use strict";Ne=I(require("path"),1),We=I(require("fs-extra"),1)});var bt={};X(bt,{BADGE_CONFIGS:()=>ze,displayAllBadges:()=>ds,displayBadgeInfo:()=>Ge,getBadgeMarkdown:()=>me,promptAddBadge:()=>Ye});function me(c){let e=ze[c];return`[](https://github.com/aria-ease/aria-ease)`}function Ge(c){let e=me(c);console.log(O.default.cyan(`
|
|
3
3
|
\u{1F3C5} Show your accessibility commitment!`)),console.log(O.default.white(` Add this badge to your README.md:
|
|
4
4
|
`)),console.log(O.default.green(" "+e)),console.log(O.default.dim(`
|
|
5
5
|
This helps others discover accessibility tools and shows you care!
|
|
6
|
-
`))}async function Ye(c,e=process.cwd()){let t=ht.default.join(e,"README.md");if(!await
|
|
7
|
-
`),s=0;for(let i=0;i<r.length;i++){let
|
|
8
|
-
`),"utf-8")}function
|
|
6
|
+
`))}async function Ye(c,e=process.cwd()){let t=ht.default.join(e,"README.md");if(!await Ee.default.pathExists(t)){console.log(O.default.yellow(" \u2139\uFE0F No README.md found in current directory"));return}let s=await Ee.default.readFile(t,"utf-8"),i=me(c);if(s.includes(i)||s.includes(ze[c].fileName)){console.log(O.default.gray(" \u2713 Badge already in README.md"));return}let n=yt.default.createInterface({input:process.stdin,output:process.stdout}),a=await new Promise(l=>{n.question(O.default.cyan(" Add badge to README.md now? (y/n): "),u=>{n.close(),l(u.toLowerCase().trim())})});a==="y"||a==="yes"?(await fs(t,s,i),console.log(O.default.green(" \u2713 Badge added to README.md!"))):console.log(O.default.gray(" Skipped. You can add it manually anytime."))}async function fs(c,e,t){let r=e.split(`
|
|
7
|
+
`),s=0;for(let i=0;i<r.length;i++){let n=r[i].trim();if(n.startsWith("[![")||n.startsWith("[!")){s=i+1;continue}if(s>0&&!n.startsWith("[![")&&!n.startsWith("[!")&&n.length>0)break;if(s===0&&n.startsWith("#")){s=i+2;break}}s===0&&(s=1),r.splice(s,0,t),await Ee.default.writeFile(c,r.join(`
|
|
8
|
+
`),"utf-8")}function ds(){console.log(O.default.cyan(`
|
|
9
9
|
\u{1F4CD} Available badges:`)),console.log(O.default.white(`
|
|
10
|
-
For audits:`)),console.log(O.default.green(" "+
|
|
11
|
-
For component testing:`)),console.log(O.default.green(" "+
|
|
12
|
-
For both (verified):`)),console.log(O.default.green(" "+
|
|
10
|
+
For audits:`)),console.log(O.default.green(" "+me("audit"))),console.log(O.default.white(`
|
|
11
|
+
For component testing:`)),console.log(O.default.green(" "+me("component"))),console.log(O.default.white(`
|
|
12
|
+
For both (verified):`)),console.log(O.default.green(" "+me("verified"))),console.log("")}var Ee,ht,O,yt,ze,Ke=j(()=>{"use strict";Ee=I(require("fs-extra"),1),ht=I(require("path"),1),O=I(require("chalk"),1),yt=I(require("readline"),1),ze={audit:{type:"audit",fileName:"audited-by-aria-ease.svg",label:"Audited by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/audited-by-aria-ease.svg"},component:{type:"component",fileName:"components-tested-aria-ease.svg",label:"Components tested: aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/components-tested-aria-ease.svg"},verified:{type:"verified",fileName:"verified-by-aria-ease.svg",label:"Verified by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/verified-by-aria-ease.svg"}}});var Xe={};X(Xe,{createAuditBrowser:()=>gs,runAudit:()=>ms});async function gs(){return await Qe.chromium.launch({headless:!0})}async function ms(c,e){let t=e.browser,r=!1,s=6e4,i="domcontentloaded";try{t||(t=await Qe.chromium.launch({headless:!0}),r=!0);let n=await t.newContext(),a=await n.newPage();await a.goto(c,{waitUntil:i,timeout:s});try{await a.waitForSelector("main",{state:"visible",timeout:s})}catch(f){console.warn(`\u26A0\uFE0F Warning: <main> landmark not found or not visible on ${c} after ${s}ms. Audit will continue, but results may be inaccurate. Consider adding a <main> element to improve audit accuracy. ${f instanceof Error?f.message:String(f)}`)}let u=await new wt.default({page:a}).withTags(["wcag2a","wcag2aa","wcag21a","wcag21aa"]).analyze();return await a.close(),await n.close(),u}catch(n){throw n instanceof Error?n.message.includes("Executable doesn't exist")?(console.error(`
|
|
13
13
|
\u274C Playwright browsers not found!
|
|
14
14
|
`),console.log("\u{1F4E6} First-time setup required:"),console.log(` Run: npx playwright install chromium
|
|
15
15
|
`),console.log("\u{1F4A1} This downloads the browser needed for auditing (~200MB)"),console.log(` You only need to do this once.
|
|
16
|
-
`)):
|
|
16
|
+
`)):n.message.includes("page.goto: net::ERR_CONNECTION_REFUSED")?(console.error(`
|
|
17
17
|
\u274C Server Not Running!
|
|
18
|
-
`),console.log(" Make sure your server is running before auditing URL"),console.log(" Run: npm run dev # or your start command")):
|
|
18
|
+
`),console.log(" Make sure your server is running before auditing URL"),console.log(" Run: npm run dev # or your start command")):n.message.includes("page.goto: Protocol error (Page.navigate): Cannot navigate to invalid URL")?console.error(`
|
|
19
19
|
\u274C Cannot audit invalid URL
|
|
20
|
-
`):(console.error("\u274C Audit error:",
|
|
21
|
-
`)}function
|
|
20
|
+
`):(console.error("\u274C Audit error:",n.message),console.log(" Make sure you provide a valid URL")):console.error("\u274C Audit error (non-Error):",String(n)),n}finally{t&&r&&await t.close()}}var wt,Qe,Ze=j(()=>{"use strict";wt=I(require("@axe-core/playwright"),1),Qe=require("playwright")});var $t={};X($t,{formatResults:()=>hs});function hs(c,e){switch(e){case"json":return JSON.stringify(c.flatMap(({url:t,result:r})=>r?r.violations.flatMap(s=>s.nodes.map(i=>({URL:t,Rule:s.id,Impact:s.impact,Description:s.description,Target:i.target,FailureSummary:i.failureSummary}))):[]),null,2);case"csv":return ys(c);case"html":return bs(c);default:return""}}function ys(c){let e=["URL,Rule,Impact,Description,Target,FailureSummary"];return c.forEach(({url:t,result:r})=>{r&&r.violations.forEach(s=>{s.nodes.forEach(i=>{e.push(he(t)+","+he(s.id)+","+he(s.impact)+","+he(s.description)+","+he(Array.isArray(i.target)?i.target.join("; "):String(i.target))+","+he(i.failureSummary??""))})})}),e.join(`
|
|
21
|
+
`)}function he(c){return`"${String(c??"").replace(/"/g,'""')}"`}function bs(c){let e={pagesAudited:0,pagesWithViolations:0,totalViolations:0,distinctRules:new Set,impactCounts:new Map};c.forEach(({result:u})=>{if(!u)return;e.pagesAudited++,u.violations.reduce((h,y)=>{let L=(y.nodes||[]).length;if(L>0){e.distinctRules.add(y.id),e.totalViolations+=L,h+=L;let H=String(y.impact??"unknown");e.impactCounts.set(H,(e.impactCounts.get(H)||0)+L)}return h},0)>0&&e.pagesWithViolations++});let t=[];c.forEach(({url:u,result:f})=>{f&&f.violations.forEach(h=>{h.nodes.forEach(y=>{let L=Array.isArray(y.target)?y.target.join("; "):String(y.target);t.push(`
|
|
22
22
|
<tr>
|
|
23
|
-
<td class="nowrap">${
|
|
24
|
-
<td class="nowrap">${
|
|
25
|
-
<td class="impact ${vt(String(
|
|
26
|
-
<td class="desc">${
|
|
27
|
-
<td class="target"><code>${
|
|
28
|
-
<td class="fail">${
|
|
23
|
+
<td class="nowrap">${pe(u)}</td>
|
|
24
|
+
<td class="nowrap">${pe(h.id)}</td>
|
|
25
|
+
<td class="impact ${vt(String(h.impact??"unknown"))}">${pe(String(h.impact??""))}</td>
|
|
26
|
+
<td class="desc">${pe(h.description??"")}</td>
|
|
27
|
+
<td class="target"><code>${pe(L)}</code></td>
|
|
28
|
+
<td class="fail">${pe(y.failureSummary??"").split(/\r?\n/).join("<br/>")}</td>
|
|
29
29
|
</tr>
|
|
30
|
-
`)})})});let r=Array.from(e.impactCounts.entries()).map(([
|
|
31
|
-
`),s=new Date,i=
|
|
30
|
+
`)})})});let r=Array.from(e.impactCounts.entries()).map(([u,f])=>`<li><strong class="impact ${vt(u)}">${pe(u)}</strong>: ${f}</li>`).join(`
|
|
31
|
+
`),s=new Date,i=u=>String(u).padStart(2,"0");return`
|
|
32
32
|
<!DOCTYPE html>
|
|
33
33
|
<html lang="en">
|
|
34
34
|
<head>
|
|
@@ -103,18 +103,18 @@
|
|
|
103
103
|
</table>
|
|
104
104
|
</body>
|
|
105
105
|
</html>
|
|
106
|
-
`.trim()}function
|
|
106
|
+
`.trim()}function pe(c){return String(c??"").replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function vt(c){return String(c??"").toLowerCase().replace(/[^a-z0-9]+/g,"-")}var St=j(()=>{"use strict"});async function ws(){return ye||(ye=await Tt.chromium.launch({headless:!0,args:["--disable-extensions","--disable-blink-features=AutomationControlled"]})),ye}async function vs(){return be||(be=await(await ws()).newContext({permissions:[],ignoreHTTPSErrors:!0})),be}async function Ct(){return await(await vs()).newPage()}async function kt(){be&&(await be.close(),be=null),ye&&(await ye.close(),ye=null)}var Tt,ye,be,et=j(()=>{"use strict";Tt=require("playwright"),ye=null,be=null});function fe(c){return c==="required"||c==="recommended"||c==="optional"?c:$s}function $e(c){return c==="minimal"||c==="balanced"||c==="strict"||c==="paranoid"?c:"balanced"}function At(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 $s,tt=j(()=>{"use strict";$s="required"});var F={};X(F,{default:()=>Rt.default});var Rt,Se=j(()=>{"use strict";Ae(F,require("playwright/test"));Rt=I(require("playwright/test"),1)});var Et={};X(Et,{MenuComponentStrategy:()=>st});var st,xt=j(()=>{"use strict";Se();st=class{constructor(e,t,r=400,s=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=s}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>!1))return;let i=!1,n=this.selectors.main;if(n&&(await e.locator(n).first().focus(),await e.keyboard.press("Escape"),i=await(0,F.expect)(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!i&&this.selectors.main&&(await e.locator(this.selectors.main).first().click({timeout:this.actionTimeoutMs}),i=await(0,F.expect)(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),i||(await e.mouse.click(10,10),i=await(0,F.expect)(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!i)throw new Error(`\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
|
|
107
107
|
1. Escape key
|
|
108
108
|
2. Clicking trigger
|
|
109
109
|
3. Clicking outside
|
|
110
|
-
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(
|
|
110
|
+
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(n=>n.target==="submenu"||n.target==="submenuTrigger"||n.target==="submenuItems")||e.assertions.some(n=>n.target==="submenu"||n.target==="submenuTrigger"||n.target==="submenuItems")))return!1;let s=this.selectors.submenuTrigger;return s?await t.locator(s).count()===0:!0}getMainSelector(){return this.mainSelector}}});var Mt={};X(Mt,{AccordionComponentStrategy:()=>rt});var rt,Pt=j(()=>{"use strict";Se();rt=class{constructor(e,t,r=400,s=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=s}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 s=await e.locator(t).all();for(let i of s){let n=await i.getAttribute("aria-expanded")==="true",a=await i.getAttribute("aria-controls");if(n&&a){await i.click({timeout:this.actionTimeoutMs});let l=e.locator(`#${a}`);await(0,F.expect)(l).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{})}}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var Bt={};X(Bt,{ComboboxComponentStrategy:()=>it});var it,Lt=j(()=>{"use strict";Se();it=class{constructor(e,t,r=400,s=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=s}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>!1))return;let i=!1,n=this.selectors.main;if(n&&(await e.locator(n).first().focus(),await e.keyboard.press("Escape"),i=await(0,F.expect)(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!i&&this.selectors.button&&(await e.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),i=await(0,F.expect)(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),i||(await e.mouse.click(10,10),i=await(0,F.expect)(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!i)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
|
|
111
111
|
1. Escape key
|
|
112
112
|
2. Clicking button
|
|
113
113
|
3. Clicking outside
|
|
114
|
-
This indicates a problem with the combobox component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear()}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var jt={};
|
|
114
|
+
This indicates a problem with the combobox component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear()}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var jt={};X(jt,{TabsComponentStrategy:()=>ot});var ot,It=j(()=>{"use strict";ot=class{constructor(e,t){this.mainSelector=e;this.selectors=t}async resetState(){}async shouldSkipTest(e,t){if(e.orientation!==void 0&&this.selectors.tablist){let r=this.selectors.tablist,i=await t.locator(r).first().getAttribute("aria-orientation");if(e.orientation!==i)return!0}return!1}getMainSelector(){return this.mainSelector}}});var nt,Ft,xe,Vt=j(()=>{"use strict";nt=I(require("path"),1),Ft=require("url"),xe=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies()}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>Promise.resolve().then(()=>(xt(),Et)).then(e=>e.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>Promise.resolve().then(()=>(Pt(),Mt)).then(e=>e.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>Promise.resolve().then(()=>(Lt(),Bt)).then(e=>e.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>Promise.resolve().then(()=>(It(),jt)).then(e=>e.TabsComponentStrategy))}async loadStrategy(e,t,r){try{if(t)try{let i=nt.default.isAbsolute(t)?t:nt.default.resolve(r||process.cwd(),t),n=await import((0,Ft.pathToFileURL)(i).href),a=n.default||n;if(!a)throw new Error(`No default export found in ${t}`);return a}catch(i){throw new Error(`Failed to load custom strategy from ${t}: ${i instanceof Error?i.message:String(i)}`)}let s=this.builtInStrategies.get(e);return s?s():null}catch(s){throw new Error(`Strategy loading failed for ${e}: ${s instanceof Error?s.message:String(s)}`)}}has(e,t){return!!t||this.builtInStrategies.has(e)}}});var Me,Pe,Ss,Be,Ut=j(()=>{"use strict";Me=require("fs"),Pe=I(require("path"),1);Vt();Ss={},Be=class{static strategyRegistry=new xe;static isComponentConfig(e){return typeof e=="object"&&e!==null}static async detect(e,t,r=400,s=400,i){let n=this.isComponentConfig(t)?t:void 0,a=n?.contractPath;if(!a)throw new Error(`Contract path not found for component: ${e}`);let l=(()=>{if(Pe.default.isAbsolute(a))return a;if(i){let M=Pe.default.resolve(i,a);try{return(0,Me.readFileSync)(M,"utf-8"),M}catch{}}let H=Pe.default.resolve(process.cwd(),a);try{return(0,Me.readFileSync)(H,"utf-8"),H}catch{return new URL(a,Ss.url).pathname}})(),u=(0,Me.readFileSync)(l,"utf-8"),h=JSON.parse(u).selectors,y=await this.strategyRegistry.loadStrategy(e,n?.strategyPath,i);if(!y)return null;let L=h.main;return e==="tabs"?new y(L,h):new y(L,h,r,s)}}});var Le,Dt=j(()=>{"use strict";Le=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=!1;isCustomContract=!1;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=!1;hasPrintedDynamicSection=!1;constructor(e=!1,t=!1){this.isPlaywright=e,this.isCustomContract=t}log(e){process.stderr.write(e+`
|
|
115
115
|
`)}start(e,t,r){this.startTime=Date.now(),this.componentName=e,this.totalTests=t,this.hasPrintedStaticSection=!1,this.hasPrintedDynamicSection=!1,r&&(this.apgUrl=r);let s="Playwright (Real Browser)";this.log(`
|
|
116
116
|
${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${e.charAt(0).toUpperCase()+e.slice(1)} Component - ${s}`),this.log(`${"\u2550".repeat(60)}
|
|
117
|
-
`)}reportStatic(e,t,r=0){this.staticPasses=e,this.staticFailures=t,this.staticWarnings=r}reportStaticTest(e,t,r,s){this.hasPrintedStaticSection||(this.log(`${"\u2500".repeat(60)}`),this.log("\u{1F9EA} Static Assertions"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedStaticSection=!0);let i=t==="pass"?"\u2713":t==="warn"?"\u26A0":t==="skip"?"\u25CB":"\u2717";this.log(` ${i} ${e}`),s&&this.log(` \u21B3 level=${s}`),(t==="fail"||t==="warn"||t==="skip")&&r&&this.log(` \u21B3 ${r}`)}reportTest(e,t,r){this.hasPrintedDynamicSection||(this.log(""),this.log(`${"\u2500".repeat(60)}`),this.log("\u2328\uFE0F Dynamic Interaction Tests"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedDynamicSection=!0);let s={description:e.description,status:t,failureMessage:r,level:e.level};t==="skip"&&(s.skipReason="Requires real browser (addEventListener events)"),this.dynamicResults.push(s);let i={pass:"\u2713",fail:"\u2717",warn:"\u26A0",skip:"\u25CB"},
|
|
117
|
+
`)}reportStatic(e,t,r=0){this.staticPasses=e,this.staticFailures=t,this.staticWarnings=r}reportStaticTest(e,t,r,s){this.hasPrintedStaticSection||(this.log(`${"\u2500".repeat(60)}`),this.log("\u{1F9EA} Static Assertions"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedStaticSection=!0);let i=t==="pass"?"\u2713":t==="warn"?"\u26A0":t==="skip"?"\u25CB":"\u2717";this.log(` ${i} ${e}`),s&&this.log(` \u21B3 level=${s}`),(t==="fail"||t==="warn"||t==="skip")&&r&&this.log(` \u21B3 ${r}`)}reportTest(e,t,r){this.hasPrintedDynamicSection||(this.log(""),this.log(`${"\u2500".repeat(60)}`),this.log("\u2328\uFE0F Dynamic Interaction Tests"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedDynamicSection=!0);let s={description:e.description,status:t,failureMessage:r,level:e.level};t==="skip"&&(s.skipReason="Requires real browser (addEventListener events)"),this.dynamicResults.push(s);let i={pass:"\u2713",fail:"\u2717",warn:"\u26A0",skip:"\u25CB"},n=e.level?`[${e.level.toUpperCase()}] `:"";this.log(` ${i[t]} ${n}${e.description}`),t==="skip"&&!this.isPlaywright&&this.log(" \u21B3 Skipped (runs only in Playwright)"),t==="fail"&&r&&this.log(` \u21B3 ${r}`),t==="warn"&&r&&this.log(` \u21B3 ${r}`),t==="skip"&&r&&this.log(` \u21B3 ${r}`)}reportFailures(e){e.length!==0&&(this.log(`
|
|
118
118
|
${"\u2500".repeat(60)}`),this.log(`\u274C Failures (${e.length}):
|
|
119
119
|
`),e.forEach((t,r)=>{this.log(`${r+1}. ${t}`),t.includes("aria-")?this.log(" \u{1F4A1} Add the missing ARIA attribute to improve screen reader support"):t.includes("focus")?this.log(" \u{1F4A1} Check keyboard event handlers and focus management"):t.includes("visible")&&this.log(" \u{1F4A1} Verify display/visibility styles and state management"),this.log("")}))}reportWarnings(){let e=this.dynamicResults.filter(t=>t.status==="warn");e.length===0&&this.staticWarnings===0||(this.log(`
|
|
120
120
|
${"\u2500".repeat(60)}`),this.log(`\u26A0\uFE0F Warnings (${this.staticWarnings+e.length}):
|
|
@@ -126,21 +126,21 @@ ${"\u2500".repeat(60)}`),this.log(`\u2139\uFE0F Skipped Tests (${this.skipped})
|
|
|
126
126
|
`),this.log("These tests use native keyboard events via addEventListener,"),this.log(`which only run in Playwright (real browser).
|
|
127
127
|
`),e.forEach((t,r)=>{this.log(`${r+1}. ${t.description}`)}),this.log(`
|
|
128
128
|
\u{1F4A1} Run with Playwright for full validation:`),this.log(` testUiComponent('${this.componentName}', null, 'http://localhost:5173/test-harness?component=component_name')
|
|
129
|
-
`)}summary(e){let t=Date.now()-this.startTime,r=this.dynamicResults.filter(f=>f.status==="pass").length,s=this.dynamicResults.filter(f=>f.status==="fail").length,i=this.dynamicResults.filter(f=>f.status==="warn").length;this.skipped=this.dynamicResults.filter(f=>f.status==="skip").length,this.warnings=this.staticWarnings+i;let
|
|
129
|
+
`)}summary(e){let t=Date.now()-this.startTime,r=this.dynamicResults.filter(f=>f.status==="pass").length,s=this.dynamicResults.filter(f=>f.status==="fail").length,i=this.dynamicResults.filter(f=>f.status==="warn").length;this.skipped=this.dynamicResults.filter(f=>f.status==="skip").length,this.warnings=this.staticWarnings+i;let n=this.staticPasses+r,a=this.staticFailures+s,l=n+a+this.warnings,u=()=>{let f=`${this.componentName.charAt(0).toUpperCase()}${this.componentName.slice(1)}`;return this.isCustomContract?`${f} component validates against your custom accessibility policy \u2713`:`${f} component meets Aria-Ease baseline WAI-ARIA expectations \u2713`};return e.length>0&&this.reportFailures(e),this.reportWarnings(),this.reportSkipped(),this.log(`
|
|
130
130
|
${"\u2550".repeat(60)}`),this.log(`\u{1F4CA} Summary
|
|
131
|
-
`),a===0&&this.skipped===0&&this.warnings===0?(this.log(`\u2705 All ${l} tests passed!`),this.log(` ${
|
|
131
|
+
`),a===0&&this.skipped===0&&this.warnings===0?(this.log(`\u2705 All ${l} tests passed!`),this.log(` ${u()}`)):a===0?(this.log(`\u2705 ${n}/${l} tests passed`),this.skipped>0&&this.log(`\u25CB ${this.skipped} tests skipped`),this.warnings>0&&this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings>1?"s":""}`),this.log(` ${u()}`)):(this.log(`\u274C ${a} test${a>1?"s":""} failed`),this.log(`\u2705 ${n} test${n>1?"s":""} passed`),this.warnings>0&&this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings>1?"s":""}`),this.skipped>0&&this.log(`\u25CB ${this.skipped} test${this.skipped>1?"s":""} skipped`)),this.log(`\u23F1\uFE0F Duration: ${t}ms`),this.log(`${"\u2550".repeat(60)}
|
|
132
132
|
`),a>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
|
|
133
133
|
`)):!this.isPlaywright&&this.skipped>0&&this.log(`\u2728 Optional: Run Playwright tests for complete validation
|
|
134
|
-
`),{passes:
|
|
135
|
-
\u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("")}}});var Ot={};K(Ot,{RelativeTargetResolver:()=>oe});var oe,Be=L(()=>{"use strict";oe=class{static async resolve(e,t,r){let s=await e.locator(t).all();switch(r){case"first":return s[0];case"second":return s[1];case"last":return s[s.length-1];case"next":{let o=(await e.evaluate(([a])=>Array.from(document.querySelectorAll(a)).indexOf(document.activeElement),[t])+1)%s.length;return s[o]}case"previous":{let o=(await e.evaluate(([a])=>Array.from(document.querySelectorAll(a)).indexOf(document.activeElement),[t])-1+s.length)%s.length;return s[o]}default:return null}}}});var ye,qt=L(()=>{"use strict";Be();ye=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 i=this.selectors.main;if(!i)return{success:!1,error:"Main selector not defined for virtual focus."};let o=this.page.locator(i).first();return await o.count()?(await o.evaluate((l,p)=>{l.setAttribute("aria-activedescendant",p)},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return{success:!1,error:"Relative selector not defined for focus action."};let o=await oe.resolve(this.page,i,t);return o?(await o.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to focus ${e}: ${s instanceof Error?s.message:String(s)}`}}}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:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,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 s=this.selectors.relative;if(!s)return{success:!1,error:"Relative selector not defined for click action."};let i=await oe.resolve(this.page,s,t);return i?(await i.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:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to click ${e}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(e,t){try{let s={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(s==="Space"?s=" ":s.includes(" ")&&(s=s.replace(/ /g,"")),e==="focusable"&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Home","End","Tab","Shift+Tab"].includes(s))return await this.page.keyboard.press(s),{success:!0};let i=this.selectors[e];if(!i)return{success:!1,error:`Selector for keypress target ${e} not found.`};let o=this.page.locator(i).first();return await o.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await o.press(s,{timeout:this.timeoutMs}),{success:!0})}catch(r){return this.isBrowserClosedError(r)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to press ${t} on ${e}: ${r instanceof Error?r.message:String(r)}`}}}async hover(e,t){try{if(e==="relative"&&t){let s=this.selectors.relative;if(!s)return{success:!1,error:"Relative selector not defined for hover action."};let i=await oe.resolve(this.page,s,t);return i?(await i.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:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to hover ${e}: ${r instanceof Error?r.message:String(r)}`}}}}});var $e,Ht=L(()=>{"use strict";ve();Be();$e=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 i=r?this.selectors[r]:this.selectors.relative;if(!i)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 o=await oe.resolve(this.page,i,t);return o?{target:o}:{target:null,error:`Target ${e} not found.`}}let s=this.selectors[e];return s?{target:this.page.locator(s).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(s){return{target:null,error:`Failed to resolve target ${e}: ${s instanceof Error?s.message:String(s)}`}}}async validateVisibility(e,t,r,s,i){try{return r?(await(0,I.expect)(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${i}".`}):(await(0,I.expect)(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${i}".`})}catch{let o=this.selectors[t]||"",a=await this.page.evaluate(l=>{let p=l?document.querySelector(l):null;if(!p)return"element not found";let f=window.getComputedStyle(p);return`display:${f.display}, visibility:${f.visibility}, opacity:${f.opacity}`},o);return r?{success:!1,failMessage:`${s} (actual: ${a})`}:{success:!1,failMessage:`${s} ${t} is still visible (actual: ${a}).`}}}async validateAttribute(e,t,r,s,i,o){if(s==="!empty"){let p=await e.getAttribute(r);return p&&p.trim()!==""?{success:!0,passMessage:`${t} has non-empty "${r}". Test: "${o}".`}:{success:!1,failMessage:`${i} ${t} "${r}" should not be empty, found "${p}".`}}if(typeof s!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",s),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(s)}`);let a=s.split(" | ").map(p=>p.trim()),l=await e.getAttribute(r);return l!==null&&a.includes(l)?{success:!0,passMessage:`${t} has expected "${r}". Test: "${o}".`}:{success:!1,failMessage:`${i} ${t} "${r}" should be "${s}", found "${l}".`}}async validateValue(e,t,r,s,i){let o=await e.inputValue().catch(()=>"");return r==="!empty"?o&&o.trim()!==""?{success:!0,passMessage:`${t} has non-empty value. Test: "${i}".`}:{success:!1,failMessage:`${s} ${t} value should not be empty, found "${o}".`}:r===""?o===""?{success:!0,passMessage:`${t} has empty value. Test: "${i}".`}:{success:!1,failMessage:`${s} ${t} value should be empty, found "${o}".`}:o===r?{success:!0,passMessage:`${t} has expected value. Test: "${i}".`}:{success:!1,failMessage:`${s} ${t} value should be "${r}", found "${o}".`}}async validateFocus(e,t,r,s,i){try{return r?(await(0,I.expect)(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${i}".`}):(await(0,I.expect)(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${i}".`})}catch{let o=await this.page.evaluate(()=>{let a=document.activeElement;return a?`${a.tagName}#${a.id||"no-id"}.${a.className||"no-class"}`:"no element focused"});return{success:!1,failMessage:`${s} (actual focus: ${o})`}}}async validateRole(e,t,r,s,i){let o=await e.getAttribute("role");return o===r?{success:!0,passMessage:`${t} has role "${r}". Test: "${i}".`}:{success:!1,failMessage:`${s} Expected role "${r}", found "${o}".`}}async validate(e,t){if(this.page.isClosed())return{success:!1,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let{target:r,error:s}=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(s||!r)return{success:!1,failMessage:s||`Target ${e.target} not found.`,target:null};if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let i=await oe.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),o=i?await i.getAttribute("id"):null,a=await r.getAttribute("aria-activedescendant");return o&&a===o?{success:!0,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:!1,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${a}".`}}switch(e.assertion){case"toBeVisible":return this.validateVisibility(r,e.target,!0,e.failureMessage||"",t);case"notToBeVisible":return this.validateVisibility(r,e.target,!1,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:!1,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:!1,failMessage:"Missing expectedValue for toHaveValue assertion"};case"toHaveFocus":return this.validateFocus(r,e.target,!0,e.failureMessage||"",t);case"notToHaveFocus":return this.validateFocus(r,e.target,!1,e.failureMessage||"",t);case"toHaveRole":return e.expectedValue!==void 0?this.validateRole(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:!1,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return{success:!1,failMessage:`Unknown assertion type: ${e.assertion}`}}}}});var Nt={};K(Nt,{runContractTestsPlaywright:()=>Ts});async function Ts(c,e,t,r,s){let i=r?.test?.components?.find(S=>S.name===c),o=!!i?.contractPath,a=new Pe(!0,o),l={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},p=r?.test?.disableTimeouts===!0,m=i?.disableTimeouts===!0||p,h=(S,se,re)=>{if(m)return 0;let Q=S??se;return typeof Q!="number"||!Number.isFinite(Q)||Q<0?re:Q},P=h(i?.actionTimeoutMs,r?.test?.actionTimeoutMs,l.actionTimeoutMs),q=h(i?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,l.assertionTimeoutMs),M=h(i?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,l.navigationTimeoutMs),U=h(i?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,l.componentReadyTimeoutMs),N=be(t),W=i?.contractPath;if(!W)throw new Error(`Contract path not found for component: ${c}`);let _=(()=>{if(je.default.isAbsolute(W))return W;if(s){let se=je.default.resolve(s,W);try{return(0,Le.readFileSync)(se,"utf-8"),se}catch{}}let S=je.default.resolve(process.cwd(),W);try{return(0,Le.readFileSync)(S,"utf-8"),S}catch{return new URL(W,Cs.url).pathname}})(),z=(0,Le.readFileSync)(_,"utf-8"),v=JSON.parse(z),Se=(v.relationships?.length||0)+(v.static[0]?.assertions.length||0)+v.dynamic.length,Fe=v.meta?.source?.apg,te=[],ae=[],ce=[],J=[],R=null,H=(S,se)=>{let re=he(se),Q=At(re,N);if(Q==="error")return te.push(S),{status:"fail",level:re,detail:S};if(Q==="warning")return ae.push(S),{status:"warn",level:re,detail:S};let ie=`${S} (ignored by strictness=${N}, level=${re})`;return J.push(ie),{status:"skip",level:re,detail:ie}};try{if(R=await Ct(),e){try{await R.goto(e,{waitUntil:"domcontentloaded",timeout:M})}catch(n){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${n instanceof Error?n.message:String(n)}`)}await R.addStyleTag({content:"* { transition: none !important; animation: none !important; }"})}let S=await Me.detect(c,i,P,q,s);if(!S)throw new Error(`Unsupported component: ${c}`);let se=S.getMainSelector();if(!se)throw new Error(`CRITICAL: No selector found in contract for ${c}`);try{await R.locator(se).first().waitFor({state:"attached",timeout:U})}catch(n){throw new Error(`
|
|
134
|
+
`),{passes:n,failures:a,skipped:this.skipped,duration:t}}error(e,t){this.log(`
|
|
135
|
+
\u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("")}}});var qt={};X(qt,{RelativeTargetResolver:()=>se});var se,je=j(()=>{"use strict";se=class{static async resolve(e,t,r){let s=await e.locator(t).all();if(typeof r=="number")return s[r-1];switch(r){case"first":return s[0];case"second":return s[1];case"last":return s[s.length-1];case"next":{let n=(await e.evaluate(([a])=>Array.from(document.querySelectorAll(a)).indexOf(document.activeElement),[t])+1)%s.length;return s[n]}case"previous":{let n=(await e.evaluate(([a])=>Array.from(document.querySelectorAll(a)).indexOf(document.activeElement),[t])-1+s.length)%s.length;return s[n]}default:return null}}}});var we,Ot=j(()=>{"use strict";je();we=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 i=this.selectors.main;if(!i)return{success:!1,error:"Main selector not defined for virtual focus."};let n=this.page.locator(i).first();return await n.count()?(await n.evaluate((l,u)=>{l.setAttribute("aria-activedescendant",u)},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return{success:!1,error:"Relative selector not defined for focus action."};let n=await se.resolve(this.page,i,t);return n?(await n.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to focus ${e}: ${s instanceof Error?s.message:String(s)}`}}}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:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,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 s=this.selectors.relative;if(!s)return{success:!1,error:"Relative selector not defined for click action."};let i=await se.resolve(this.page,s,t);return i?(await i.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:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to click ${e}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(e,t,r){try{let i={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(i==="Space"?i=" ":i.includes(" ")&&(i=i.replace(/ /g,"")),e==="relative"){if(r==null)return{success:!1,error:"relativeTarget must be provided for relative keypress."};let u=this.selectors.relative;if(!u)return{success:!1,error:"Relative selector not defined for keypress action."};let f=await se.resolve(this.page,u,r);return f?(await f.press(i,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let n=this.selectors[e];if(!n)return{success:!1,error:`Selector for keypress target ${e} not found.`};let a=this.page.locator(n).first();return await a.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await a.press(i,{timeout:this.timeoutMs}),{success:!0})}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to press ${t} on ${e}: ${s instanceof Error?s.message:String(s)}`}}}async hover(e,t){try{if(e==="relative"&&t){let s=this.selectors.relative;if(!s)return{success:!1,error:"Relative selector not defined for hover action."};let i=await se.resolve(this.page,s,t);return i?(await i.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:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to hover ${e}: ${r instanceof Error?r.message:String(r)}`}}}}});var Te,Ht=j(()=>{"use strict";Se();je();Te=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 i=r?this.selectors[r]:this.selectors.relative;if(!i)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 n=await se.resolve(this.page,i,t);return n?{target:n}:{target:null,error:`Target ${e} not found.`}}let s=this.selectors[e];return s?{target:this.page.locator(s).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(s){return{target:null,error:`Failed to resolve target ${e}: ${s instanceof Error?s.message:String(s)}`}}}async validateVisibility(e,t,r,s,i){try{return r?(await(0,F.expect)(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${i}".`}):(await(0,F.expect)(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${i}".`})}catch{let n=this.selectors[t]||"",a=await this.page.evaluate(l=>{let u=l?document.querySelector(l):null;if(!u)return"element not found";let f=window.getComputedStyle(u);return`display:${f.display}, visibility:${f.visibility}, opacity:${f.opacity}`},n);return r?{success:!1,failMessage:`${s} (actual: ${a})`}:{success:!1,failMessage:`${s} ${t} is still visible (actual: ${a}).`}}}async validateAttribute(e,t,r,s,i,n){if(s==="!empty"){let u=await e.getAttribute(r);return u&&u.trim()!==""?{success:!0,passMessage:`${t} has non-empty "${r}". Test: "${n}".`}:{success:!1,failMessage:`${i} ${t} "${r}" should not be empty, found "${u}".`}}if(typeof s!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",s),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(s)}`);let a=s.split(" | ").map(u=>u.trim()),l=await e.getAttribute(r);return l!==null&&a.includes(l)?{success:!0,passMessage:`${t} has expected "${r}". Test: "${n}".`}:{success:!1,failMessage:`${i} ${t} "${r}" should be "${s}", found "${l}".`}}async validateValue(e,t,r,s,i){let n=await e.inputValue().catch(()=>"");return r==="!empty"?n&&n.trim()!==""?{success:!0,passMessage:`${t} has non-empty value. Test: "${i}".`}:{success:!1,failMessage:`${s} ${t} value should not be empty, found "${n}".`}:r===""?n===""?{success:!0,passMessage:`${t} has empty value. Test: "${i}".`}:{success:!1,failMessage:`${s} ${t} value should be empty, found "${n}".`}:n===r?{success:!0,passMessage:`${t} has expected value. Test: "${i}".`}:{success:!1,failMessage:`${s} ${t} value should be "${r}", found "${n}".`}}async validateFocus(e,t,r,s,i){try{return r?(await(0,F.expect)(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${i}".`}):(await(0,F.expect)(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${i}".`})}catch{let n=await this.page.evaluate(()=>{let a=document.activeElement;return a?`${a.tagName}#${a.id||"no-id"}.${a.className||"no-class"}`:"no element focused"});return{success:!1,failMessage:`${s} (actual focus: ${n})`}}}async validateRole(e,t,r,s,i){let n=await e.getAttribute("role");return n===r?{success:!0,passMessage:`${t} has role "${r}". Test: "${i}".`}:{success:!1,failMessage:`${s} Expected role "${r}", found "${n}".`}}async validate(e,t){if(this.page.isClosed())return{success:!1,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,s;if(e.controlledBy){let i=e.controlledBy,n=this.selectors[i.target];if(!n)return{success:!1,failMessage:`Selector for controlledBy.target '${i.target}' not found.`,target:null};let a=null;if(i.relativeTarget?a=await se.resolve(this.page,n,i.relativeTarget):a=this.page.locator(n).first(),!a)return{success:!1,failMessage:"Controlling element for controlledBy not found.",target:null};let l=i.attribute||"aria-controls",u=await a.getAttribute(l);if(!u)return{success:!1,failMessage:`Controlling element does not have attribute '${l}'.`,target:null};if(r=this.page.locator(`#${u}`),!r||await r.count()===0)return{success:!1,failMessage:`Controlled element with id '${u}' not found.`,target:null}}else{let i=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(r=i.target,s=i.error,s||!r)return{success:!1,failMessage:s||`Target ${e.target} not found.`,target:null}}if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let i=await se.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),n=i?await i.getAttribute("id"):null,a=await r.getAttribute("aria-activedescendant");return n&&a===n?{success:!0,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:!1,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${a}".`}}switch(e.assertion){case"toBeVisible":return this.validateVisibility(r,e.target,!0,e.failureMessage||"",t);case"notToBeVisible":return this.validateVisibility(r,e.target,!1,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:!1,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:!1,failMessage:"Missing expectedValue for toHaveValue assertion"};case"toHaveFocus":return this.validateFocus(r,e.target,!0,e.failureMessage||"",t);case"notToHaveFocus":return this.validateFocus(r,e.target,!1,e.failureMessage||"",t);case"toHaveRole":return e.expectedValue!==void 0?this.validateRole(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:!1,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return{success:!1,failMessage:`Unknown assertion type: ${e.assertion}`}}}}});var Nt={};X(Nt,{runContractTestsPlaywright:()=>Ts});async function Ts(c,e,t,r,s){let i=r?.test?.components?.find(S=>S.name===c),n=!!i?.contractPath,a=new Le(!0,n),l={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},u=r?.test?.disableTimeouts===!0,h=i?.disableTimeouts===!0||u,y=(S,ie,oe)=>{if(h)return 0;let ee=S??ie;return typeof ee!="number"||!Number.isFinite(ee)||ee<0?oe:ee},L=y(i?.actionTimeoutMs,r?.test?.actionTimeoutMs,l.actionTimeoutMs),H=y(i?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,l.assertionTimeoutMs),M=y(i?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,l.navigationTimeoutMs),U=y(i?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,l.componentReadyTimeoutMs),W=$e(t),J=i?.contractPath;if(!J)throw new Error(`Contract path not found for component: ${c}`);let G=(()=>{if(Fe.default.isAbsolute(J))return J;if(s){let ie=Fe.default.resolve(s,J);try{return(0,Ie.readFileSync)(ie,"utf-8"),ie}catch{}}let S=Fe.default.resolve(process.cwd(),J);try{return(0,Ie.readFileSync)(S,"utf-8"),S}catch{return new URL(J,Cs.url).pathname}})(),Y=(0,Ie.readFileSync)(G,"utf-8"),v=JSON.parse(Y),Ce=(v.relationships?.length||0)+(v.static[0]?.assertions.length||0)+v.dynamic.length,Ue=v.meta?.source?.apg,Z=[],ae=[],ce=[],N=[],A=null,q=(S,ie)=>{let oe=fe(ie),ee=At(oe,W);if(ee==="error")return Z.push(S),{status:"fail",level:oe,detail:S};if(ee==="warning")return ae.push(S),{status:"warn",level:oe,detail:S};let ne=`${S} (ignored by strictness=${W}, level=${oe})`;return N.push(ne),{status:"skip",level:oe,detail:ne}};try{if(A=await Ct(),e){try{await A.goto(e,{waitUntil:"domcontentloaded",timeout:M})}catch(o){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${o instanceof Error?o.message:String(o)}`)}await A.addStyleTag({content:"* { transition: none !important; animation: none !important; }"})}let S=await Be.detect(c,i,L,H,s);if(!S)throw new Error(`Unsupported component: ${c}`);let ie=S.getMainSelector();if(!ie)throw new Error(`CRITICAL: No selector found in contract for ${c}`);try{await A.locator(ie).first().waitFor({state:"attached",timeout:U})}catch(o){throw new Error(`
|
|
136
136
|
\u274C CRITICAL: Component not found on page!
|
|
137
137
|
This usually means:
|
|
138
138
|
- The component didn't render
|
|
139
139
|
- The URL is incorrect
|
|
140
|
-
- The component selector '${
|
|
141
|
-
- Original error: ${n}`)}a.start(c,Se,Fe),c==="menu"&&v.selectors.main&&await R.locator(v.selectors.main).first().waitFor({state:"visible",timeout:U}).catch(()=>{});let re=c==="menu"&&v.selectors.submenuTrigger?await R.locator(v.selectors.submenuTrigger).count()>0:!1,Q=n=>n.type==="aria-reference"&&[n.from,n.to].some(d=>["submenu","submenuTrigger","submenuItems"].includes(d||""))||n.type==="contains"&&[n.parent,n.child].some(d=>["submenu","submenuTrigger","submenuItems"].includes(d||"")),ie=0,G=0,Y=0;for(let n of v.relationships||[]){if(S&&typeof S.resetState=="function")try{await S.resetState(R)}catch(b){ae.push(`Warning: resetState failed before relationship test: ${b instanceof Error?b.message:String(b)}`)}let d=he(n.level);if(Array.isArray(n.setup)&&n.setup.length>0){let E=function(u){return A.includes(u)};var pt=E;let b=new ye(R,v.selectors,P),x=n.type==="aria-reference"?`${n.from}.${n.attribute} references ${n.to}`:`${n.parent} contains ${n.child}`,A=["focus","type","click","keypress","hover"],C=u=>({...u,type:E(u.type)?u.type:"click"}),k=n.setup.map(C),y=await Ve(k,b,S,R,x,["submenu","submenuTrigger","submenuItems"]);if(y.skip){J.push(y.message||"Setup action skipped"),a.reportStaticTest(x,"skip",y.message,d);continue}if(!y.success){let u=`Relationship setup failed: ${y.error}`,w=H(u,n.level);w.status==="fail"&&(G+=1),w.status==="warn"&&(Y+=1),a.reportStaticTest(x,w.status,w.detail,w.level);continue}}if(c==="menu"&&!re&&Q(n)){let x=n.type==="aria-reference"?`${n.from}.${n.attribute} references ${n.to}`:`${n.parent} contains ${n.child}`,A="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";J.push(A),a.reportStaticTest(x,"skip",A,d);continue}if(n.type==="aria-reference"){let b=`${n.from}.${n.attribute} references ${n.to}`,x=v.selectors[n.from],A=v.selectors[n.to];if(!x||!A){let T=H(`Relationship selector missing: from="${n.from}" or to="${n.to}" not found in selectors.`,n.level);T.status==="fail"&&(G+=1),T.status==="warn"&&(Y+=1),a.reportStaticTest(b,T.status,T.detail,T.level);continue}let E=R.locator(x).first(),C=R.locator(A).first(),k=await E.count()>0,y=await C.count()>0;if(!k||!y){if(c==="menu"&&Q(n)){let we="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";J.push(we),a.reportStaticTest(b,"skip",we,d);continue}let T=H(`Relationship target not found: ${k?n.to:n.from}.`,n.level);T.status==="fail"&&(G+=1),T.status==="warn"&&(Y+=1),a.reportStaticTest(b,T.status,T.detail,T.level);continue}let u=await E.getAttribute(n.attribute),w=await C.getAttribute("id");if(!w){let T=H(`Relationship target "${n.to}" must have an id for ${n.attribute} validation.`,n.level);T.status==="fail"&&(G+=1),T.status==="warn"&&(Y+=1),a.reportStaticTest(b,T.status,T.detail,T.level);continue}if(!(u||"").split(/\s+/).filter(Boolean).includes(w)){let T=H(`Expected ${n.from} ${n.attribute} to reference id "${w}", found "${u||""}".`,n.level);T.status==="fail"&&(G+=1),T.status==="warn"&&(Y+=1),a.reportStaticTest(b,T.status,T.detail,T.level);continue}ce.push(`Relationship valid: ${n.from}.${n.attribute} -> ${n.to} (id=${w}).`),ie+=1,a.reportStaticTest(b,"pass",void 0,d);continue}if(n.type==="contains"){let b=`${n.parent} contains ${n.child}`,x=v.selectors[n.parent],A=v.selectors[n.child];if(!x||!A){let u=H(`Relationship selector missing: parent="${n.parent}" or child="${n.child}" not found in selectors.`,n.level);u.status==="fail"&&(G+=1),u.status==="warn"&&(Y+=1),a.reportStaticTest(b,u.status,u.detail,u.level);continue}let E=R.locator(x).first();if(!(await E.count()>0)){if(c==="menu"&&Q(n)){let w="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";J.push(w),a.reportStaticTest(b,"skip",w,d);continue}let u=H(`Relationship parent target not found: ${n.parent}.`,n.level);u.status==="fail"&&(G+=1),u.status==="warn"&&(Y+=1),a.reportStaticTest(b,u.status,u.detail,u.level);continue}if(await E.locator(A).count()<1){if(c==="menu"&&Q(n)){let w="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";J.push(w),a.reportStaticTest(b,"skip",w,d);continue}let u=H(`Expected ${n.parent} to contain descendant matching selector for ${n.child}.`,n.level);u.status==="fail"&&(G+=1),u.status==="warn"&&(Y+=1),a.reportStaticTest(b,u.status,u.detail,u.level);continue}ce.push(`Relationship valid: ${n.parent} contains ${n.child}.`),ie+=1,a.reportStaticTest(b,"pass",void 0,d)}}async function ft(n,d,b,x={}){if(!n||typeof n!="object"||!("ref"in n))return n;let A;if(n.ref==="relative"){if(!n.relativeTarget||!x.relativeBaseSelector)return;let E=b.locator(x.relativeBaseSelector),C=await E.count(),k=0;if(n.relativeTarget==="first"?k=0:n.relativeTarget==="second"?k=1:n.relativeTarget==="last"?k=C-1:isNaN(Number(n.relativeTarget))?k=0:k=Number(n.relativeTarget),k<0||k>=C)return;let y=E.nth(k);return await gt(y,n.property||n.attribute)}else{if(A=d[n.ref],!A)throw new Error(`Selector for ref '${n.ref}' not found in contract selectors.`);let E=b.locator(A).first();return await gt(E,n.property||n.attribute)}}async function gt(n,d){if(n)return!d||d==="id"?await n.getAttribute("id")??void 0:d==="class"?await n.getAttribute("class")??void 0:d==="textContent"?await n.evaluate(b=>b.textContent??void 0):d.startsWith("aria-")?await n.getAttribute(d)??void 0:d.endsWith("*")?await n.evaluate(x=>{let A=[];for(let E of Array.from(x.attributes))E.name.startsWith("aria-")&&A.push(`${E.name}=${E.value}`);return A.join(";")}):await n.getAttribute(d)??void 0}let is=new $e(R,v.selectors,q);async function Ve(n,d,b,x,A,E=[]){if(!Array.isArray(n)||n.length===0)return{success:!0};b&&typeof b.resetState=="function"&&await b.resetState(x);for(let C of n){let k={success:!0};try{if(C.type==="focus")C.target==="relative"&&C.relativeTarget?k=await d.focus("relative",C.relativeTarget):k=await d.focus(C.target);else if(C.type==="type"&&C.value)k=await d.type(C.target,C.value);else if(C.type==="click")k=await d.click(C.target,C.relativeTarget);else if(C.type==="keypress"&&C.key)k=await d.keypress(C.target,C.key);else if(C.type==="hover")k=await d.hover(C.target,C.relativeTarget);else continue}catch(y){k={success:!1,error:y instanceof Error?y.message:String(y)}}if(!k.success){let y=k.error||"Setup action failed";return E.some(w=>A.includes(w)||y.includes(w))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${y}`}:{success:!1,error:y}}}return{success:!0}}for(let n of v.static[0]?.assertions||[]){if(S&&typeof S.resetState=="function")try{await S.resetState(R)}catch(y){ae.push(`Warning: resetState failed before static test: ${y instanceof Error?y.message:String(y)}`)}if(n.target==="relative")continue;let d=`${n.target}${n.attribute?` (${n.attribute})`:""}`,b=he(n.level);if(c==="menu"&&n.target==="submenuTrigger"&&!re){let y=`Skipping submenu static assertion for ${n.target}: no submenu capability detected in rendered component.`;J.push(y),a.reportStaticTest(d,"skip",y,b);continue}if(Array.isArray(n.setup)&&n.setup.length>0){let w=function(ne){return u.includes(ne)};var pt=w;let y=new ye(R,v.selectors,P),u=["focus","type","click","keypress","hover"],X=ne=>({...ne,type:w(ne.type)?ne.type:"click"}),F=n.setup.map(X),T=await Ve(F,y,S,R,d,["submenu","submenuTrigger","submenuItems"]);if(T.skip){J.push(T.message||"Setup action skipped"),a.reportStaticTest(d,"skip",T.message,b);continue}if(!T.success){let ne=`Static setup failed: ${T.error}`,g=H(ne,n.level);g.status==="fail"&&(G+=1),g.status==="warn"&&(Y+=1),a.reportStaticTest(d,g.status,g.detail,g.level);continue}}let x=v.selectors[n.target];if(!x){let y=`Selector for target ${n.target} not found.`,u=H(y,n.level);u.status==="fail"&&(G+=1),u.status==="warn"&&(Y+=1),a.reportStaticTest(d,u.status,u.detail,u.level);continue}let A=R.locator(x).first();if(!(await A.count()>0)){let y=`Target ${n.target} not found.`,u=H(y,n.level);u.status==="fail"&&(G+=1),u.status==="warn"&&(Y+=1),a.reportStaticTest(d,u.status,u.detail,u.level);continue}let C=(y,u,w)=>{let X=new RegExp(`\\[${u}(?:=["']?([^\\]"']+)["']?)?\\]`),F=y.match(X);if(!F)return!1;if(!w)return!0;let T=F[1];return T?w.split(" | ").includes(T):!1},k=n.expectedValue;if(n.expectedValue&&typeof n.expectedValue=="object"&&"ref"in n.expectedValue){let y={},u=n.relativeTarget;if(n.expectedValue.ref==="relative"&&n.target==="relative"&&u){let w=v.selectors[u];if(!w)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);y.relativeBaseSelector=w}else if(n.expectedValue.ref==="relative"&&u){let w=v.selectors[u];if(!w)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);y.relativeBaseSelector=w}k=await ft(n.expectedValue,v.selectors,R,y),console.log("Expected value in static check",k)}if(n.expectedValue)if(C(x,n.attribute,typeof k=="string"?k:void 0))ce.push(`${n.attribute}="${k}" on ${n.target} verified by selector (already present in: ${x}).`),ie+=1,a.reportStaticTest(d,"pass",void 0,b);else{let y=k??"",u=await is.validateAttribute(A,n.target,n.attribute,y,n.failureMessage,"Static ARIA Test");if(u.success&&u.passMessage)ce.push(u.passMessage),ie+=1,a.reportStaticTest(d,"pass",void 0,b);else if(!u.success&&u.failMessage){let w=H(u.failMessage,n.level);w.status==="fail"&&(G+=1),w.status==="warn"&&(Y+=1),a.reportStaticTest(d,w.status,w.detail,w.level)}}else{let y=n.attribute.split(" | "),u=!1,w=!0;for(let X of y){let F=X.trim();if(C(x,F)){ce.push(`${F} on ${n.target} verified by selector (already present in: ${x}).`),u=!0;continue}if(w=!1,await A.getAttribute(F)!==null){u=!0;break}}if(!u&&!w){let X=n.failureMessage+` None of the attributes "${n.attribute}" are present.`,F=H(X,n.level);F.status==="fail"&&(G+=1),F.status==="warn"&&(Y+=1),a.reportStaticTest(d,F.status,F.detail,F.level)}else!w&&u?(ce.push(`At least one of the attributes "${n.attribute}" exists on the element.`),ie+=1,a.reportStaticTest(d,"pass",void 0,b)):(ie+=1,a.reportStaticTest(d,"pass",void 0,b))}}for(let n of v.dynamic||[]){if(!R||R.isClosed()){console.warn(`
|
|
142
|
-
\u26A0\uFE0F Browser closed - skipping remaining ${v.dynamic.length-v.dynamic.indexOf(
|
|
143
|
-
`),
|
|
140
|
+
- The component selector '${ie}' in the contract is wrong
|
|
141
|
+
- Original error: ${o}`)}a.start(c,Ce,Ue),c==="menu"&&v.selectors.main&&await A.locator(v.selectors.main).first().waitFor({state:"visible",timeout:U}).catch(()=>{});let oe=c==="menu"&&v.selectors.submenuTrigger?await A.locator(v.selectors.submenuTrigger).count()>0:!1,ee=o=>o.type==="aria-reference"&&[o.from,o.to].some(m=>["submenu","submenuTrigger","submenuItems"].includes(m||""))||o.type==="contains"&&[o.parent,o.child].some(m=>["submenu","submenuTrigger","submenuItems"].includes(m||"")),ne=0,_=0,z=0;for(let o of v.relationships||[]){if(S&&typeof S.resetState=="function")try{await S.resetState(A)}catch(w){ae.push(`Warning: resetState failed before relationship test: ${w instanceof Error?w.message:String(w)}`)}let m=fe(o.level);if(Array.isArray(o.setup)&&o.setup.length>0){let R=function(g){return T.includes(g)};var pt=R;let w=new we(A,v.selectors,L),P=o.type==="aria-reference"?`${o.from}.${o.attribute} references ${o.to}`:`${o.parent} contains ${o.child}`,T=["focus","type","click","keypress","hover"],C=g=>({...g,type:R(g.type)?g.type:"click"}),E=o.setup.map(C),B=await De(E,w,S,A,P,["submenu","submenuTrigger","submenuItems"]);if(B.skip){N.push(B.message||"Setup action skipped"),a.reportStaticTest(P,"skip",B.message,m);continue}if(!B.success){let g=`Relationship setup failed: ${B.error}`,d=q(g,o.level);d.status==="fail"&&(_+=1),d.status==="warn"&&(z+=1),a.reportStaticTest(P,d.status,d.detail,d.level);continue}}if(c==="menu"&&!oe&&ee(o)){let P=o.type==="aria-reference"?`${o.from}.${o.attribute} references ${o.to}`:`${o.parent} contains ${o.child}`,T="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";N.push(T),a.reportStaticTest(P,"skip",T,m);continue}if(o.type==="aria-reference"){let w=`${o.from}.${o.attribute} references ${o.to}`,P=v.selectors[o.from],T=v.selectors[o.to];if(!P||!T){let b=q(`Relationship selector missing: from="${o.from}" or to="${o.to}" not found in selectors.`,o.level);b.status==="fail"&&(_+=1),b.status==="warn"&&(z+=1),a.reportStaticTest(w,b.status,b.detail,b.level);continue}let R=A.locator(P).first(),C=A.locator(T).first(),E=await R.count()>0,B=await C.count()>0;if(!E||!B){if(c==="menu"&&ee(o)){let K="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";N.push(K),a.reportStaticTest(w,"skip",K,m);continue}let b=q(`Relationship target not found: ${E?o.to:o.from}.`,o.level);b.status==="fail"&&(_+=1),b.status==="warn"&&(z+=1),a.reportStaticTest(w,b.status,b.detail,b.level);continue}let g=await R.getAttribute(o.attribute),d=await C.getAttribute("id");if(!d){let b=q(`Relationship target "${o.to}" must have an id for ${o.attribute} validation.`,o.level);b.status==="fail"&&(_+=1),b.status==="warn"&&(z+=1),a.reportStaticTest(w,b.status,b.detail,b.level);continue}if(!(g||"").split(/\s+/).filter(Boolean).includes(d)){let b=q(`Expected ${o.from} ${o.attribute} to reference id "${d}", found "${g||""}".`,o.level);b.status==="fail"&&(_+=1),b.status==="warn"&&(z+=1),a.reportStaticTest(w,b.status,b.detail,b.level);continue}ce.push(`Relationship valid: ${o.from}.${o.attribute} -> ${o.to} (id=${d}).`),ne+=1,a.reportStaticTest(w,"pass",void 0,m);continue}if(o.type==="contains"){let w=`${o.parent} contains ${o.child}`,P=v.selectors[o.parent],T=v.selectors[o.child];if(!P||!T){let g=q(`Relationship selector missing: parent="${o.parent}" or child="${o.child}" not found in selectors.`,o.level);g.status==="fail"&&(_+=1),g.status==="warn"&&(z+=1),a.reportStaticTest(w,g.status,g.detail,g.level);continue}let R=A.locator(P).first();if(!(await R.count()>0)){if(c==="menu"&&ee(o)){let d="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";N.push(d),a.reportStaticTest(w,"skip",d,m);continue}let g=q(`Relationship parent target not found: ${o.parent}.`,o.level);g.status==="fail"&&(_+=1),g.status==="warn"&&(z+=1),a.reportStaticTest(w,g.status,g.detail,g.level);continue}if(await R.locator(T).count()<1){if(c==="menu"&&ee(o)){let d="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";N.push(d),a.reportStaticTest(w,"skip",d,m);continue}let g=q(`Expected ${o.parent} to contain descendant matching selector for ${o.child}.`,o.level);g.status==="fail"&&(_+=1),g.status==="warn"&&(z+=1),a.reportStaticTest(w,g.status,g.detail,g.level);continue}ce.push(`Relationship valid: ${o.parent} contains ${o.child}.`),ne+=1,a.reportStaticTest(w,"pass",void 0,m)}}async function ft(o,m,w,P={}){if(!o||typeof o!="object"||!("ref"in o))return o;let T;if(o.ref==="relative"){if(!o.relativeTarget||!P.relativeBaseSelector)return;let R=w.locator(P.relativeBaseSelector),C=await R.count(),E=0;if(o.relativeTarget==="first"?E=0:o.relativeTarget==="second"?E=1:o.relativeTarget==="last"?E=C-1:isNaN(Number(o.relativeTarget))?E=0:E=Number(o.relativeTarget),E<0||E>=C)return;let B=R.nth(E);return await dt(B,o.property||o.attribute)}else{if(T=m[o.ref],!T)throw new Error(`Selector for ref '${o.ref}' not found in contract selectors.`);let R=w.locator(T).first();return await dt(R,o.property||o.attribute)}}async function dt(o,m){if(o)return!m||m==="id"?await o.getAttribute("id")??void 0:m==="class"?await o.getAttribute("class")??void 0:m==="textContent"?await o.evaluate(w=>w.textContent??void 0):m.startsWith("aria-")?await o.getAttribute(m)??void 0:m.endsWith("*")?await o.evaluate(P=>{let T=[];for(let R of Array.from(P.attributes))R.name.startsWith("aria-")&&T.push(`${R.name}=${R.value}`);return T.join(";")}):await o.getAttribute(m)??void 0}let is=new Te(A,v.selectors,H);async function De(o,m,w,P,T,R=[]){if(!Array.isArray(o)||o.length===0)return{success:!0};w&&typeof w.resetState=="function"&&await w.resetState(P);for(let C of o){let E={success:!0};try{if(C.type==="focus")C.target==="relative"&&C.relativeTarget?E=await m.focus("relative",C.relativeTarget):E=await m.focus(C.target);else if(C.type==="type"&&C.value)E=await m.type(C.target,C.value);else if(C.type==="click")E=await m.click(C.target,C.relativeTarget);else if(C.type==="keypress"&&C.key)E=await m.keypress(C.target,C.key,C.relativeTarget);else if(C.type==="hover")E=await m.hover(C.target,C.relativeTarget);else continue}catch(B){E={success:!1,error:B instanceof Error?B.message:String(B)}}if(!E.success){let B=E.error||"Setup action failed";return R.some(d=>T.includes(d)||B.includes(d))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${B}`}:{success:!1,error:B}}}return{success:!0}}for(let o of v.static[0]?.assertions||[]){if(S&&typeof S.resetState=="function")try{await S.resetState(A)}catch(g){ae.push(`Warning: resetState failed before static test: ${g instanceof Error?g.message:String(g)}`)}if(o.target==="relative")continue;let m=`${o.target}${o.attribute?` (${o.attribute})`:""}`,w=fe(o.level);if(c==="menu"&&o.target==="submenuTrigger"&&!oe){let g=`Skipping submenu static assertion for ${o.target}: no submenu capability detected in rendered component.`;N.push(g),a.reportStaticTest(m,"skip",g,w);continue}let P=[];if(o.target||P.push("target"),o.attribute||P.push("attribute"),typeof o.expectedValue>"u"&&P.push("expectedValue"),P.length>0){let g=`${o.target||""}${o.attribute?` (${o.attribute})`:""}`,d=`Static assertion missing required field(s): ${P.join(", ")}`,k=q(d,o.level);k.status==="fail"&&(_+=1),k.status==="warn"&&(z+=1),a.reportStaticTest(g,k.status,k.detail,k.level);continue}if(Array.isArray(o.setup)&&o.setup.length>0){let k=function(p){return d.includes(p)};var pt=k;let g=new we(A,v.selectors,L),d=["focus","type","click","keypress","hover"],te=p=>({...p,type:k(p.type)?p.type:"click"}),b=o.setup.map(te),K=await De(b,g,S,A,m,["submenu","submenuTrigger","submenuItems"]);if(K.skip){N.push(K.message||"Setup action skipped"),a.reportStaticTest(m,"skip",K.message,w);continue}if(!K.success){let p=`Static setup failed: ${K.error}`,x=q(p,o.level);x.status==="fail"&&(_+=1),x.status==="warn"&&(z+=1),a.reportStaticTest(m,x.status,x.detail,x.level);continue}}let T=v.selectors[o.target];if(!T){let g=`Selector for target ${o.target} not found.`,d=q(g,o.level);d.status==="fail"&&(_+=1),d.status==="warn"&&(z+=1),a.reportStaticTest(m,d.status,d.detail,d.level);continue}let R=A.locator(T).first();if(!(await R.count()>0)){let g=`Target ${o.target} not found.`,d=q(g,o.level);d.status==="fail"&&(_+=1),d.status==="warn"&&(z+=1),a.reportStaticTest(m,d.status,d.detail,d.level);continue}let E=(g,d,k)=>{let te=new RegExp(`\\[${d}(?:=["']?([^\\]"']+)["']?)?\\]`),b=g.match(te);if(!b)return!1;if(!k)return!0;let K=b[1];return K?k.split(" | ").includes(K):!1},B=o.expectedValue;if(o.expectedValue&&typeof o.expectedValue=="object"&&"ref"in o.expectedValue){let g={},d=o.relativeTarget;if(o.expectedValue.ref==="relative"&&o.target==="relative"&&d){let k=v.selectors[d];if(!k)throw new Error(`Selector for relativeTarget '${d}' not found in contract selectors.`);g.relativeBaseSelector=k}else if(o.expectedValue.ref==="relative"&&d){let k=v.selectors[d];if(!k)throw new Error(`Selector for relativeTarget '${d}' not found in contract selectors.`);g.relativeBaseSelector=k}B=await ft(o.expectedValue,v.selectors,A,g)}if(o.expectedValue)if(E(T,o.attribute,typeof B=="string"?B:void 0))ce.push(`${o.attribute}="${B}" on ${o.target} verified by selector (already present in: ${T}).`),ne+=1,a.reportStaticTest(m,"pass",void 0,w);else{let g=B??"",d=await is.validateAttribute(R,o.target,o.attribute,g,o.failureMessage,"Static ARIA Test");if(d.success&&d.passMessage)ce.push(d.passMessage),ne+=1,a.reportStaticTest(m,"pass",void 0,w);else if(!d.success&&d.failMessage){let k=q(d.failMessage,o.level);k.status==="fail"&&(_+=1),k.status==="warn"&&(z+=1),a.reportStaticTest(m,k.status,k.detail,k.level)}}else{let g=o.attribute.split(" | "),d=!1,k=!0;for(let te of g){let b=te.trim();if(E(T,b)){ce.push(`${b} on ${o.target} verified by selector (already present in: ${T}).`),d=!0;continue}if(k=!1,await R.getAttribute(b)!==null){d=!0;break}}if(!d&&!k){let te=o.failureMessage+` None of the attributes "${o.attribute}" are present.`,b=q(te,o.level);b.status==="fail"&&(_+=1),b.status==="warn"&&(z+=1),a.reportStaticTest(m,b.status,b.detail,b.level)}else!k&&d?(ce.push(`At least one of the attributes "${o.attribute}" exists on the element.`),ne+=1,a.reportStaticTest(m,"pass",void 0,w)):(ne+=1,a.reportStaticTest(m,"pass",void 0,w))}}for(let o of v.dynamic||[]){if(!o.assertions||o.assertions.length===0){let p="Skipping test - no assertions found for this dynamic test.";N.push(p),a.reportTest({description:o.description,level:fe(o.level)},"skip",p);continue}if(!A||A.isClosed()){console.warn(`
|
|
142
|
+
\u26A0\uFE0F Browser closed - skipping remaining ${v.dynamic.length-v.dynamic.indexOf(o)} tests
|
|
143
|
+
`),Z.push(`CRITICAL: Browser/page closed before completing all tests. ${v.dynamic.length-v.dynamic.indexOf(o)} tests skipped.`);break}try{await S.resetState(A)}catch(p){let x=p instanceof Error?p.message:String(p);throw a.error(x),p}let{setup:m=[],action:w,assertions:P}=o,T=fe(o.level),R=new we(A,v.selectors,L);if(Array.isArray(m)&&m.length>0){let x=function(Q){return p.includes(Q)};var pt=x;let p=["focus","type","click","keypress","hover"],ge=Q=>({...Q,type:x(Q.type)?Q.type:"click"}),qe=m.map(ge),re=await De(qe,R,S,A,o.description,["submenu","submenuTrigger","submenuItems"]);if(re.skip){N.push(re.message||"Setup action skipped"),a.reportTest({description:o.description,level:T},"skip",re.message);continue}if(!re.success){let Q=q(`Setup failed: ${re.error}`,o.level);a.reportTest({description:o.description,level:T},Q.status,Q.detail);continue}}let C=Z.length,E=ae.length,B=N.length;if(await S.shouldSkipTest(o,A)){let p="Skipping test - component-specific conditions not met";N.push(p),a.reportTest({description:o.description,level:T},"skip",p);continue}let d=new Te(A,v.selectors,H),k=!1,te=null;for(let p of w){if(!A||A.isClosed()){Z.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),k=!0;break}let x;if(p.type==="focus")p.target==="relative"&&p.relativeTarget?x=await R.focus("relative",p.relativeTarget):x=await R.focus(p.target);else if(p.type==="type"&&p.value)x=await R.type(p.target,p.value);else if(p.type==="click")x=await R.click(p.target,p.relativeTarget);else if(p.type==="keypress"&&p.key)x=await R.keypress(p.target,p.key,p.relativeTarget);else if(p.type==="hover")x=await R.hover(p.target,p.relativeTarget);else continue;if(!x.success){if(x.error){let ge=q(x.error,o.level);te={status:ge.status,detail:ge.detail}}k=!0;break}}if(k){a.reportTest({description:o.description,level:T},te?.status||"fail",te?.detail||Z[Z.length-1]);continue}for(let p of P){let x;if(p.expectedValue&&typeof p.expectedValue=="object"&&"ref"in p.expectedValue)if(p.expectedValue.ref==="relative"){let{RelativeTargetResolver:le}=await Promise.resolve().then(()=>(je(),qt)),Q=v.selectors.relative;if(!Q)throw new Error("Relative selector not defined in contract selectors.");let ve=p.relativeTarget||"first",ue=await le.resolve(A,Q,ve);if(!ue)throw new Error(`Could not resolve relative target '${ve}' for expectedValue.`);let mt=p.expectedValue.property||p.expectedValue.attribute||"id";if(mt==="textContent")x=await ue.evaluate(ke=>ke.textContent??void 0);else{let ke=await ue.getAttribute(mt);x=ke===null?void 0:ke}}else x=await ft(p.expectedValue,v.selectors,A,{});else typeof p.expectedValue=="string"||typeof p.expectedValue>"u"?x=p.expectedValue:x="";let ge={...p,expectedValue:x},qe=x??"",re=await d.validate({...ge,expectedValue:qe},o.description);if(re.success&&re.passMessage)ce.push(re.passMessage);else if(!re.success&&re.failMessage){let le=[];if(p.target||le.push("target"),p.assertion||le.push("assertion"),["toHaveAttribute","toHaveValue","toHaveRole"].includes(p.assertion)&&(typeof p.attribute>"u"&&p.assertion==="toHaveAttribute"&&le.push("attribute"),typeof p.expectedValue>"u"&&le.push("expectedValue")),le.length>0){let Q=fe(p.level||o.level),ve=`Dynamic assertion missing required field(s): ${le.join(", ")}`,ue=q(ve,Q);if(ue.status==="skip")continue;Z.push(ve),a.reportTest({description:o.description,level:Q},ue.status,ue.detail);continue}}}let b=Z.length,K=ae.length,gt=N.length;b>C?a.reportTest({description:o.description,level:T},"fail",Z[Z.length-1]):K>E?a.reportTest({description:o.description,level:T},"warn",ae[ae.length-1]):gt>B?a.reportTest({description:o.description,level:T},"skip",N[N.length-1]):a.reportTest({description:o.description,level:T},"pass")}a.reportStatic(ne,_,z),a.summary(Z)}catch(S){if(S instanceof Error)throw S.message.includes("Executable doesn't exist")||S.message.includes("browserType.launch")?new Error(`
|
|
144
144
|
\u274C CRITICAL: Playwright browsers not found!
|
|
145
145
|
\u{1F4E6} Run: npx playwright install chromium`):S.message.includes("net::ERR_CONNECTION_REFUSED")||S.message.includes("NS_ERROR_CONNECTION_REFUSED")?new Error(`
|
|
146
146
|
\u274C CRITICAL: Cannot connect to dev server!
|
|
@@ -156,52 +156,52 @@ This usually means:
|
|
|
156
156
|
This usually means:
|
|
157
157
|
- The test timeout was too short
|
|
158
158
|
- The browser crashed
|
|
159
|
-
- An external process killed the browser`):S}finally{
|
|
160
|
-
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(f){throw f instanceof Error?f:new Error(`\u274C Contract test execution failed: ${String(f)}`)}let
|
|
159
|
+
- An external process killed the browser`):S}finally{A&&await A.close()}return{passes:ce,failures:Z,skipped:N,warnings:ae}}var Ie,Fe,Cs,Wt=j(()=>{"use strict";Ie=require("fs"),Fe=I(require("path"),1);et();Ut();Dt();Ot();Ht();tt();Cs={}});async function _t(c,e,t={}){if(!c||typeof c!="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 r={violations:[]};async function s(f){try{let h=await fetch(f,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(h.ok||h.status===304)return f}catch{return null}return null}let i=$e(t.strictness),n={},a=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:f}=await Promise.resolve().then(()=>(Re(),_e)),h=await f(process.cwd());if(n=h.config,h.configPath&&(a=Jt.default.dirname(h.configPath)),t.strictness===void 0){let y=n.test?.components?.find(L=>L?.name===c)?.strictness;i=$e(y??n.test?.strictness)}}catch{t.strictness===void 0&&(i="balanced")}let l;try{if(e){let f=await s(e);if(f){console.log(`\u{1F3AD} Running Playwright tests on ${f}`);let{runContractTestsPlaywright:h}=await Promise.resolve().then(()=>(Wt(),Nt));l=await h(c,f,i,n,a)}else throw new Error(`\u274C Dev server not running at ${e}
|
|
160
|
+
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(f){throw f instanceof Error?f:new Error(`\u274C Contract test execution failed: ${String(f)}`)}let u={violations:r.violations,raw:r,contract:l};if(l.failures.length>0&&e==="Playwright")throw new Error(`
|
|
161
161
|
\u274C ${l.failures.length} accessibility contract test${l.failures.length>1?"s":""} failed (Playwright mode)
|
|
162
162
|
\u2705 ${l.passes.length} test${l.passes.length>1?"s":""} passed
|
|
163
163
|
|
|
164
164
|
\u{1F4CB} Review the detailed test report above for specific failures.
|
|
165
|
-
\u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(r.violations.length>0){let f=r.violations.length,
|
|
166
|
-
- ${
|
|
167
|
-
Impact: ${
|
|
168
|
-
Affected elements: ${
|
|
169
|
-
Help: ${
|
|
165
|
+
\u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(r.violations.length>0){let f=r.violations.length,h=r.violations.map(y=>`
|
|
166
|
+
- ${y.id}: ${y.description}
|
|
167
|
+
Impact: ${y.impact}
|
|
168
|
+
Affected elements: ${y.nodes.length}
|
|
169
|
+
Help: ${y.helpUrl}`).join(`
|
|
170
170
|
`);throw new Error(`
|
|
171
171
|
\u274C ${f} axe accessibility violation${f>1?"s":""} detected
|
|
172
|
-
${
|
|
172
|
+
${h}
|
|
173
173
|
|
|
174
|
-
\u{1F4CB} Full details available in result.violations`)}return
|
|
175
|
-
`);let{exec:c}=await import("child_process"),e=(await import("chalk")).default;return new Promise((t,r)=>{c("npx vitest --run --reporter verbose",async(s,i,
|
|
174
|
+
\u{1F4CB} Full details available in result.violations`)}return u}async function zt(){await kt()}var Jt,at,Gt=j(()=>{"use strict";et();tt();Jt=I(require("path"),1);at=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(at=async()=>{console.log(`\u{1F680} Running component accessibility tests...
|
|
175
|
+
`);let{exec:c}=await import("child_process"),e=(await import("chalk")).default;return new Promise((t,r)=>{c("npx vitest --run --reporter verbose",async(s,i,n)=>{if(console.log(i),n&&console.error(n),!s||s.code===0){try{let{displayBadgeInfo:l,promptAddBadge:u}=await Promise.resolve().then(()=>(Ke(),bt));l("component"),await u("component",process.cwd()),console.log(e.dim(`
|
|
176
176
|
`+"\u2500".repeat(60))),console.log(e.cyan("\u{1F499} Found aria-ease helpful?")),console.log(e.white(" \u2022 Star us on GitHub: ")+e.blue.underline("https://github.com/aria-ease/aria-ease")),console.log(e.white(" \u2022 Share feedback: ")+e.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log(e.dim("\u2500".repeat(60)+`
|
|
177
|
-
`))}catch(l){console.error("Warning: Could not display badge prompt:",l)}t({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let l=s?.code||1;r(new Error(`Tests failed with code ${l}`)),process.exit(l)}})})})});var Yt={};
|
|
177
|
+
`))}catch(l){console.error("Warning: Could not display badge prompt:",l)}t({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let l=s?.code||1;r(new Error(`Tests failed with code ${l}`)),process.exit(l)}})})})});var Yt={};X(Yt,{cleanupTests:()=>zt,runTest:()=>at,testUiComponent:()=>_t});var Kt=j(()=>{"use strict";Gt()});function Qt(c){let e=[];if(!c||typeof c!="object")return{valid:!1,errors:[{path:"$",message:"Contract must be an object"}]};let t=c;if(!t.selectors)e.push({path:"$.selectors",message:"selectors is required"});else if(typeof t.selectors!="object"||t.selectors===null||Array.isArray(t.selectors))e.push({path:"$.selectors",message:"selectors must be an object"});else{let r=t.selectors;Object.entries(r).forEach(([s,i])=>{typeof i!="string"&&e.push({path:`$.selectors['${s}']`,message:"All selectors must be strings"})})}return Array.isArray(t.static)?t.static.forEach((r,s)=>{if(typeof r!="object"||r===null){e.push({path:`$.static[${s}]`,message:"static item must be an object"});return}let i=r;if(!Array.isArray(i.assertions)){e.push({path:`$.static[${s}].assertions`,message:"assertions must be an array"});return}i.assertions.forEach((n,a)=>{if(typeof n!="object"||n===null){e.push({path:`$.static[${s}].assertions[${a}]`,message:"assertion must be an object"});return}let l=n;typeof l.target!="string"&&e.push({path:`$.static[${s}].assertions[${a}].target`,message:"target is required and must be a string"}),typeof l.attribute!="string"&&e.push({path:`$.static[${s}].assertions[${a}].attribute`,message:"attribute is required and must be a string"}),typeof l.failureMessage!="string"&&e.push({path:`$.static[${s}].assertions[${a}].failureMessage`,message:"failureMessage is required and must be a string"}),l.level!==void 0&&!["required","recommended","optional"].includes(l.level)&&e.push({path:`$.static[${s}].assertions[${a}].level`,message:"level must be one of: required, recommended, optional"})})}):e.push({path:"$.static",message:"static must be an array"}),Array.isArray(t.dynamic)?t.dynamic.forEach((r,s)=>{if(typeof r!="object"||r===null){e.push({path:`$.dynamic[${s}]`,message:"dynamic item must be an object"});return}let i=r;typeof i.description!="string"&&e.push({path:`$.dynamic[${s}].description`,message:"description is required and must be a string"}),Array.isArray(i.action)?i.action.forEach((n,a)=>{if(typeof n!="object"||n===null){e.push({path:`$.dynamic[${s}].action[${a}]`,message:"action item must be an object"});return}let l=n;typeof l.type!="string"&&e.push({path:`$.dynamic[${s}].action[${a}].type`,message:"type is required and must be a string"}),typeof l.target!="string"&&e.push({path:`$.dynamic[${s}].action[${a}].target`,message:"target is required and must be a string"})}):e.push({path:`$.dynamic[${s}].action`,message:"action is required and must be an array"}),Array.isArray(i.assertions)?i.assertions.forEach((n,a)=>{if(typeof n!="object"||n===null){e.push({path:`$.dynamic[${s}].assertions[${a}]`,message:"assertion must be an object"});return}let l=n;typeof l.target!="string"&&e.push({path:`$.dynamic[${s}].assertions[${a}].target`,message:"target is required and must be a string"}),typeof l.assertion!="string"&&e.push({path:`$.dynamic[${s}].assertions[${a}].assertion`,message:"assertion is required and must be a string"}),l.level!==void 0&&!["required","recommended","optional"].includes(l.level)&&e.push({path:`$.dynamic[${s}].assertions[${a}].level`,message:"level must be one of: required, recommended, optional"})}):e.push({path:`$.dynamic[${s}].assertions`,message:"assertions is required and must be an array"})}):e.push({path:"$.dynamic",message:"dynamic must be an array"}),t.relationships!==void 0&&(Array.isArray(t.relationships)?t.relationships.forEach((r,s)=>{if(typeof r!="object"||r===null){e.push({path:`$.relationships[${s}]`,message:"relationship must be an object"});return}let i=r,n=i.type;["aria-reference","contains"].includes(n)||e.push({path:`$.relationships[${s}].type`,message:"type must be one of: aria-reference, contains"}),n==="aria-reference"?(typeof i.from!="string"&&e.push({path:`$.relationships[${s}].from`,message:"from is required for aria-reference and must be a string"}),typeof i.attribute!="string"&&e.push({path:`$.relationships[${s}].attribute`,message:"attribute is required for aria-reference and must be a string"}),typeof i.to!="string"&&e.push({path:`$.relationships[${s}].to`,message:"to is required for aria-reference and must be a string"})):n==="contains"&&(typeof i.parent!="string"&&e.push({path:`$.relationships[${s}].parent`,message:"parent is required for contains and must be a string"}),typeof i.child!="string"&&e.push({path:`$.relationships[${s}].child`,message:"child is required for contains and must be a string"}))}):e.push({path:"$.relationships",message:"relationships must be an array"})),{valid:e.length===0,errors:e}}function Xt(c,e){let t=[];if(!c||typeof c!="object")return t;let s=c.relationships;return Array.isArray(s)&&s.forEach((i,n)=>{let a=i.type;if(a==="aria-reference"){let l=i.from,u=i.to;l&&!e.has(l)&&t.push({path:`$.relationships[${n}].from`,message:`Selector '${l}' not found in selectors`}),u&&!e.has(u)&&t.push({path:`$.relationships[${n}].to`,message:`Selector '${u}' not found in selectors`})}else if(a==="contains"){let l=i.parent,u=i.child;l&&!e.has(l)&&t.push({path:`$.relationships[${n}].parent`,message:`Selector '${l}' not found in selectors`}),u&&!e.has(u)&&t.push({path:`$.relationships[${n}].child`,message:`Selector '${u}' not found in selectors`})}}),t}function Zt(c,e){let t=[];if(!c||typeof c!="object")return t;let r=c,s=r.static;Array.isArray(s)&&s.forEach((n,a)=>{let l=n.assertions;Array.isArray(l)&&l.forEach((u,f)=>{let h=u.target;h&&!e.has(h)&&t.push({path:`$.static[${a}].assertions[${f}].target`,message:`Selector '${h}' not found in selectors`})})});let i=r.dynamic;return Array.isArray(i)&&i.forEach((n,a)=>{let l=n.action;Array.isArray(l)&&l.forEach((f,h)=>{let y=f.target;y&&y!=="document"&&!e.has(y)&&t.push({path:`$.dynamic[${a}].action[${h}].target`,message:`Selector '${y}' not found in selectors (or use 'document')`})});let u=n.assertions;Array.isArray(u)&&u.forEach((f,h)=>{let y=f.target;y&&y!=="relative"&&!e.has(y)&&t.push({path:`$.dynamic[${a}].assertions[${h}].target`,message:`Selector '${y}' not found in selectors (or use 'relative')`})})}),t}var es=j(()=>{"use strict"});var ss={};X(ss,{buildContracts:()=>ks});async function ks(c,e){let t=[],r=[];if(!e.contracts||e.contracts.length===0)return console.log(V.default.yellow('\u2139\uFE0F No contracts configured. Add "contracts" array to ariaease.config.js')),{success:!0,built:r,errors:t};try{console.log(V.default.cyanBright(`
|
|
178
178
|
\u{1F3D7}\uFE0F Building contracts...
|
|
179
|
-
`));for(let s of e.contracts){let i=D.default.resolve(c,s.src),
|
|
179
|
+
`));for(let s of e.contracts){let i=D.default.resolve(c,s.src),n=s.out?D.default.resolve(c,s.out):void 0;console.log(V.default.gray(` Pattern: ${s.src}`)),console.log(n?V.default.gray(` Output: ${s.out}
|
|
180
180
|
`):V.default.gray(` Output: Same directory as source
|
|
181
|
-
`));let a=[];for await(let l of(0,ts.glob)(i,{cwd:c}))a.push(l);if(a.length===0){console.log(V.default.yellow(`\u26A0\uFE0F No contract files found matching pattern: ${s.src}`));continue}
|
|
182
|
-
${
|
|
183
|
-
`)}`;t.push(`${D.default.basename(l)}: ${
|
|
181
|
+
`));let a=[];for await(let l of(0,ts.glob)(i,{cwd:c}))a.push(l);if(a.length===0){console.log(V.default.yellow(`\u26A0\uFE0F No contract files found matching pattern: ${s.src}`));continue}n&&await ct.default.ensureDir(n);for(let l of a)try{let u=l.startsWith("/")?l:D.default.resolve(c,l),f=await import(`file://${u}`),h=f.default;if(!h){let G=Object.entries(f).find(([,Y])=>Y&&typeof Y=="object"&&"toJSON"in Y);G&&(h=G[1])}if(!h||typeof h.toJSON!="function"){t.push(`${D.default.basename(l)}: No contract with toJSON() method found`);continue}let y=h.toJSON(),L=Qt(y);if(!L.valid){let Y=`Schema validation failed:
|
|
182
|
+
${L.errors.map(v=>` ${V.default.red("\u2717")} ${v.path}: ${v.message}`).join(`
|
|
183
|
+
`)}`;t.push(`${D.default.basename(l)}: ${Y}`),console.log(V.default.red(`\u274C ${D.default.basename(l)}`)),console.log(V.default.red(` ${Y}`));continue}let H=new Set;if(y&&typeof y=="object"&&"selectors"in y){let G=y.selectors;Object.keys(G).forEach(Y=>H.add(Y))}let M=[...Xt(y,H),...Zt(y,H)];if(M.length>0){let Y=`Reference validation failed:
|
|
184
184
|
${M.map(v=>` ${V.default.red("\u2717")} ${v.path}: ${v.message}`).join(`
|
|
185
|
-
`)}`;t.push(`${D.default.basename(l)}: ${
|
|
186
|
-
`,"utf-8");let
|
|
185
|
+
`)}`;t.push(`${D.default.basename(l)}: ${Y}`),console.log(V.default.red(`\u274C ${D.default.basename(l)}`)),console.log(V.default.red(` ${Y}`));continue}let U=D.default.basename(l,D.default.extname(l)),W=n?D.default.join(n,`${U}.json`):D.default.join(D.default.dirname(u),`${U}.json`);await ct.default.writeFile(W,JSON.stringify(y,null,2)+`
|
|
186
|
+
`,"utf-8");let J=D.default.relative(c,W);r.push(J),console.log(V.default.green(`\u2705 ${D.default.basename(l)} \u2192 ${D.default.basename(W)}`))}catch(u){let f=u instanceof Error?u.message:String(u),h=D.default.basename(l);t.push(`${h}: ${f}`),console.log(V.default.red(`\u274C ${h}`)),console.log(V.default.red(` Error: ${f}`))}}return console.log(""),t.length===0?(console.log(V.default.green(`\u2705 Built ${r.length} contract${r.length!==1?"s":""} successfully
|
|
187
187
|
`)),{success:!0,built:r,errors:t}):(console.log(V.default.yellow(`\u26A0\uFE0F Built ${r.length} contracts with ${t.length} error${t.length!==1?"s":""}
|
|
188
|
-
`)),{success:!1,built:r,errors:t})}catch(s){let
|
|
189
|
-
`)),{success:!1,built:r,errors:t}}}var D,ct,ts,V,rs=
|
|
190
|
-
`));let{runAudit:e}=await Promise.resolve().then(()=>(Ze(),Xe)),{formatResults:t}=await Promise.resolve().then(()=>(St(),$t)),r=!c.url,{config:s,configPath:i,errors:
|
|
191
|
-
`)):
|
|
192
|
-
`)),
|
|
188
|
+
`)),{success:!1,built:r,errors:t})}catch(s){let n=`Failed to build contracts: ${s instanceof Error?s.message:String(s)}`;return t.push(n),console.log(V.default.red(`\u274C ${n}
|
|
189
|
+
`)),{success:!1,built:r,errors:t}}}var D,ct,ts,V,rs=j(()=>{"use strict";D=I(require("path"),1),ct=I(require("fs-extra"),1),ts=require("fs/promises"),V=I(require("chalk"),1);es()});var ut=require("commander"),$=I(require("chalk"),1),Ve=I(require("path"),1),lt=I(require("fs-extra"),1);Re();Ke();var de=new ut.Command;de.name("aria-ease").description("Run accessibility tests and audits").version("2.2.3");de.command("audit").description("Run axe-core powered accessibility audit on webpages").option("-u, --url <url>","Single URL to audit").option("-f, --format <format>","Output format for the audit report: json | csv | html | all","all").option("-o, --out <path>","Directory to save the audit report","./accessibility-reports/audit").action(async c=>{console.log($.default.cyanBright(`\u{1F680} Starting accessibility audit...
|
|
190
|
+
`));let{runAudit:e}=await Promise.resolve().then(()=>(Ze(),Xe)),{formatResults:t}=await Promise.resolve().then(()=>(St(),$t)),r=!c.url,{config:s,configPath:i,errors:n}=await Je(process.cwd());i?console.log($.default.green(`\u2705 Loaded config from ${Ve.default.basename(i)}
|
|
191
|
+
`)):n.length>0&&r?(console.log($.default.red(`\u274C Config file errors:
|
|
192
|
+
`)),n.forEach(M=>console.log($.default.red(` ${M}`))),console.log(""),process.exit(1)):n.length>0?console.log($.default.yellow(`\u26A0\uFE0F Config file has errors (ignored, using CLI options)
|
|
193
193
|
`)):!i&&r&&console.log($.default.yellow(`\u2139\uFE0F No config file found, using CLI options.
|
|
194
|
-
`));let a=[];c.url?a.push(c.url):s.audit?.urls&&Array.isArray(s.audit.urls)&&a.push(...s.audit.urls);let l=s.audit?.output&&s.audit.output.format||c.format;["json","csv","html","all"].includes(l)||(console.log($.default.red('\u274C Invalid format. Use "json", "csv", "html" or "all".')),process.exit(1)),a.length===0&&(console.log($.default.red('\u274C No URLs provided. Use --url option or add "urls" in config file')),process.exit(1));let
|
|
195
|
-
`))}catch(
|
|
194
|
+
`));let a=[];c.url?a.push(c.url):s.audit?.urls&&Array.isArray(s.audit.urls)&&a.push(...s.audit.urls);let l=s.audit?.output&&s.audit.output.format||c.format;["json","csv","html","all"].includes(l)||(console.log($.default.red('\u274C Invalid format. Use "json", "csv", "html" or "all".')),process.exit(1)),a.length===0&&(console.log($.default.red('\u274C No URLs provided. Use --url option or add "urls" in config file')),process.exit(1));let u=[],{createAuditBrowser:f}=await Promise.resolve().then(()=>(Ze(),Xe)),h=await f();try{let M={browser:h};for(let U of a){console.log($.default.yellow(`\u{1F50E} Auditing: ${U}`));try{let W=await e(U,M);u.push({url:U,result:W}),console.log($.default.green(`\u2705 Completed audit for ${U}
|
|
195
|
+
`))}catch(W){W instanceof Error&&W.message&&console.log($.default.red(`\u274C Failed auditing ${U}: ${W.message}`))}}}finally{await h.close()}if(!u.some(M=>M.result&&M.result.violations&&M.result.violations.length>0)){let M=u.filter(U=>U.result).length;M===0&&(console.log($.default.red("\u274C No pages were successfully audited.")),process.exit(1)),console.log($.default.green(`
|
|
196
196
|
\u{1F389} Great news! No static accessibility violations found!`)),console.log($.default.gray(` Audited ${M} page${M>1?"s":""} successfully.
|
|
197
197
|
`)),Ge("audit"),await Ye("audit",process.cwd()),console.log($.default.dim(`
|
|
198
198
|
`+"\u2500".repeat(60))),console.log($.default.cyan("\u{1F499} Found aria-ease helpful?")),console.log($.default.white(" \u2022 Star us on GitHub: ")+$.default.blue.underline("https://github.com/aria-ease/aria-ease")),console.log($.default.white(" \u2022 Share feedback: ")+$.default.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log($.default.dim("\u2500".repeat(60)+`
|
|
199
|
-
`)),process.exit(0)}async function
|
|
200
|
-
\u274C Accessibility violations found!`)),console.log($.default.yellow(` ${
|
|
199
|
+
`)),process.exit(0)}async function L(M){let U=t(u,M),W=s.audit?.output&&s.audit.output.out||c.out;await lt.default.ensureDir(W);let J=new Date,G=Ue=>String(Ue).padStart(2,"0"),v=`ariaease-report-${`${G(J.getDate())}-${G(J.getMonth()+1)}-${J.getFullYear()} ${G(J.getHours())}h ${G(J.getMinutes())}m ${G(J.getSeconds())}s`}.${M}`,Ce=Ve.default.join(W,v);await lt.default.writeFile(Ce,U,"utf-8"),console.log($.default.magentaBright(`\u{1F4C1} Report saved to ${Ce}`))}["json","csv","html"].includes(l)?await L(l):l==="all"&&await Promise.all(["json","csv","html"].map(M=>L(M)));let H=u.reduce((M,U)=>M+(U.result?.violations?.length||0),0);console.log($.default.red(`
|
|
200
|
+
\u274C Accessibility violations found!`)),console.log($.default.yellow(` ${H} violation${H!==1?"s":""} detected across ${u.length} page${u.length!==1?"s":""}.`)),console.log($.default.gray(` Review the generated report for details.
|
|
201
201
|
`)),console.log($.default.dim(`
|
|
202
202
|
`+"\u2500".repeat(60))),console.log($.default.cyan("\u{1F499} Found aria-ease helpful?")),console.log($.default.white(" \u2022 Star us on GitHub: ")+$.default.blue.underline("https://github.com/aria-ease/aria-ease")),console.log($.default.white(" \u2022 Share feedback: ")+$.default.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log($.default.dim("\u2500".repeat(60)+`
|
|
203
|
-
`)),process.exit(1)});
|
|
203
|
+
`)),process.exit(1)});de.command("test").description("Run core a11y accessibility standard tests on UI components").action(async()=>{let{runTest:c}=await Promise.resolve().then(()=>(Kt(),Yt));c()});de.command("build").description("Build accessibility artifacts").addCommand(new ut.Command("contracts").description("Build DSL contracts to JSON").action(async()=>{let{buildContracts:c}=await Promise.resolve().then(()=>(rs(),ss)),{loadConfig:e}=await Promise.resolve().then(()=>(Re(),_e)),t=process.cwd(),{config:r,configPath:s,errors:i}=await e(t);s?console.log($.default.green(`\u2705 Loaded config from ${Ve.default.basename(s)}
|
|
204
204
|
`)):i.length>0&&(console.log($.default.red(`\u274C Config file has errors:
|
|
205
|
-
`)),i.forEach(a=>console.log($.default.red(` ${a}`))),console.log(""),process.exit(1));let
|
|
206
|
-
`)),process.exit(1)),
|
|
207
|
-
`)),process.exit(1)),process.exit(0)}));
|
|
205
|
+
`)),i.forEach(a=>console.log($.default.red(` ${a}`))),console.log(""),process.exit(1));let n=await c(t,r);!n.success&&n.errors.length>0&&(console.log($.default.red(`\u274C ${n.errors.length} error${n.errors.length!==1?"s":""} occurred during build
|
|
206
|
+
`)),process.exit(1)),n.built.length===0&&(!r.contracts||r.contracts.length===0)&&process.exit(0),n.built.length===0&&(console.log($.default.yellow(`\u26A0\uFE0F No contracts were built
|
|
207
|
+
`)),process.exit(1)),process.exit(0)}));de.command("help").description("Display help information").action(()=>{de.outputHelp()});de.parse(process.argv);
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import{a as x}from"./chunk-ZNQ5BXVJ.js";import{c as R,d as C}from"./chunk-52I3IN
|
|
|
13
13
|
\u274C Accessibility violations found!`)),console.log(o.yellow(` ${$} violation${$!==1?"s":""} detected across ${r.length} page${r.length!==1?"s":""}.`)),console.log(o.gray(` Review the generated report for details.
|
|
14
14
|
`)),console.log(o.dim(`
|
|
15
15
|
`+"\u2500".repeat(60))),console.log(o.cyan("\u{1F499} Found aria-ease helpful?")),console.log(o.white(" \u2022 Star us on GitHub: ")+o.blue.underline("https://github.com/aria-ease/aria-ease")),console.log(o.white(" \u2022 Share feedback: ")+o.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log(o.dim("\u2500".repeat(60)+`
|
|
16
|
-
`)),process.exit(1)});l.command("test").description("Run core a11y accessibility standard tests on UI components").action(async()=>{let{runTest:n}=await import("./test-
|
|
16
|
+
`)),process.exit(1)});l.command("test").description("Run core a11y accessibility standard tests on UI components").action(async()=>{let{runTest:n}=await import("./test-PCRWMQUO.js");n()});l.command("build").description("Build accessibility artifacts").addCommand(new S("contracts").description("Build DSL contracts to JSON").action(async()=>{let{buildContracts:n}=await import("./buildContracts-T4XQZBDU.js"),{loadConfig:h}=await import("./configLoader-ZXTSCIP6.js"),f=process.cwd(),{config:c,configPath:s,errors:u}=await h(f);s?console.log(o.green(`\u2705 Loaded config from ${w.basename(s)}
|
|
17
17
|
`)):u.length>0&&(console.log(o.red(`\u274C Config file has errors:
|
|
18
18
|
`)),u.forEach(d=>console.log(o.red(` ${d}`))),console.log(""),process.exit(1));let i=await n(f,c);!i.success&&i.errors.length>0&&(console.log(o.red(`\u274C ${i.errors.length} error${i.errors.length!==1?"s":""} occurred during build
|
|
19
19
|
`)),process.exit(1)),i.built.length===0&&(!c.contracts||c.contracts.length===0)&&process.exit(0),i.built.length===0&&(console.log(o.yellow(`\u26A0\uFE0F No contracts were built
|