aria-ease 7.5.0 → 7.8.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.
Files changed (52) hide show
  1. package/README.md +60 -75
  2. package/dist/ToggleComponentStrategy-TMRNXFSL.js +1 -0
  3. package/dist/cli.cjs +34 -34
  4. package/dist/cli.js +1 -1
  5. package/dist/{contractTestRunnerPlaywright-75NI6SN7.js → contractTestRunnerPlaywright-CJFYO766.js} +1 -1
  6. package/dist/{contractTestRunnerPlaywright-VLOD5IB3.js → contractTestRunnerPlaywright-OB2GWGOA.js} +1 -1
  7. package/dist/index.cjs +33 -33
  8. package/dist/index.d.cts +18 -14
  9. package/dist/index.d.ts +18 -14
  10. package/dist/index.js +10 -10
  11. package/dist/src/{Types.d-D96FYkCN.d.cts → Types.d-BjBTlIzl.d.cts} +18 -8
  12. package/dist/src/{Types.d-D96FYkCN.d.ts → Types.d-BjBTlIzl.d.ts} +18 -8
  13. package/dist/src/accordion/index.cjs +1 -1
  14. package/dist/src/accordion/index.d.cts +1 -1
  15. package/dist/src/accordion/index.d.ts +1 -1
  16. package/dist/src/accordion/index.js +1 -1
  17. package/dist/src/block/index.d.cts +1 -1
  18. package/dist/src/block/index.d.ts +1 -1
  19. package/dist/src/checkbox/index.cjs +1 -1
  20. package/dist/src/checkbox/index.d.cts +1 -1
  21. package/dist/src/checkbox/index.d.ts +1 -1
  22. package/dist/src/checkbox/index.js +1 -1
  23. package/dist/src/combobox/index.cjs +1 -1
  24. package/dist/src/combobox/index.d.cts +1 -1
  25. package/dist/src/combobox/index.d.ts +1 -1
  26. package/dist/src/combobox/index.js +1 -1
  27. package/dist/src/menu/index.cjs +1 -1
  28. package/dist/src/menu/index.d.cts +1 -1
  29. package/dist/src/menu/index.d.ts +1 -1
  30. package/dist/src/menu/index.js +1 -1
  31. package/dist/src/radio/index.cjs +1 -1
  32. package/dist/src/radio/index.d.cts +1 -1
  33. package/dist/src/radio/index.d.ts +1 -1
  34. package/dist/src/radio/index.js +1 -1
  35. package/dist/src/tabs/index.cjs +1 -1
  36. package/dist/src/tabs/index.d.cts +1 -2
  37. package/dist/src/tabs/index.d.ts +1 -2
  38. package/dist/src/tabs/index.js +1 -1
  39. package/dist/src/toggle/index.cjs +1 -1
  40. package/dist/src/toggle/index.d.cts +2 -7
  41. package/dist/src/toggle/index.d.ts +2 -7
  42. package/dist/src/toggle/index.js +1 -1
  43. package/dist/src/utils/test/ToggleComponentStrategy-UOGYK2U4.js +1 -0
  44. package/dist/src/utils/test/{contractTestRunnerPlaywright-FSZDW7IR.js → contractTestRunnerPlaywright-ZKVK7KUM.js} +1 -1
  45. package/dist/src/utils/test/dsl/index.cjs +1 -1
  46. package/dist/src/utils/test/dsl/index.js +1 -1
  47. package/dist/src/utils/test/index.cjs +14 -14
  48. package/dist/src/utils/test/index.d.cts +1 -0
  49. package/dist/src/utils/test/index.d.ts +1 -0
  50. package/dist/src/utils/test/index.js +1 -1
  51. package/dist/{test-FURQN5KO.js → test-TZFBWFCP.js} +1 -1
  52. package/package.json +1 -1
@@ -1 +1 @@
1
- 'use strict';function l(e,t){return t==="first"?`first ${e}`:t==="last"?`last ${e}`:t==="next"?`next ${e}`:t==="previous"?`previous ${e}`:typeof t=="number"?`${e} at index ${t}`:`${t} ${e}`}var k={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:C},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[..._(),...T()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:R},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:V},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:I},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:B},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):e.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:e.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(e={})=>D(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:H},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:T},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>q(e.relativeTarget)}};function C(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function _(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function D(e){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first relative item."}]}function H(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function T(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function q(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${l("option",e)} to have aria-selected='true'.`}]}function R(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function V(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function I(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function B(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var x={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:F},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:P},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:$},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:O},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>z(e.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:K},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:L},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:j},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:U},"submenuitem.focused":{requires:["submenupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),e.relativeTarget==="first"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),e.relativeTarget==="last"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>J(e.relativeTarget)}};function F(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function P(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function $(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function O(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function z(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function K(){return [{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function L(){return [{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function j(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function U(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function J(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var A={"tab.active":{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>W(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>X(e.relativeTarget)}};function X(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have focus.`}]}function N(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have tabindex='0'.`}]}function W(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${l("tab",e)} to be visible.`},N(e)]}var w={"panel.expanded":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>G(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Q(e.relativeTarget)}};function G(e){return [{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected trigger to have aria-expanded='true' when panel expands."}]}function Q(e){return [{target:"panel",assertion:"notToBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger not to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected trigger to have aria-expanded='false' when panel collapses."}]}var S={"radio.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Y(e.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Z(e.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ee(e.relativeTarget)}};function Y(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function Z(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function ee(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("radio",e)} to have focus.`}]}var E={"checkbox.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>te(e.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>re(e.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ie(e.relativeTarget)}};function te(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function re(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function ie(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("checkbox",e)} to have focus.`}]}function ae(e,t){return t.some(c=>e.capabilities.includes(c))}function y(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let c of e)if(ae(t,c.when))return c.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var se={combobox:k,menu:x,tabs:A,accordion:w,radio:S,checkbox:E},m=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},h=class{constructor(t){this.componentName=t;this.statePack=se[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let c=this.statePack,p={capabilities:["keyboard"]},d=(o,i=new Set)=>{if(i.has(o))return [];i.add(o);let n=c[o];if(!n)return [];let r=[];if(Array.isArray(n.requires))for(let a of n.requires)r=r.concat(d(a,i));return n.setup&&(r=r.concat(y(n.setup,p))),r};return t({ariaReference:(o,i,n)=>({requires:r=>{let a=d(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required",setup:a}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional",setup:a}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended",setup:a})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended"})}),contains:(o,i)=>({requires:n=>{let r=d(n,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended"})})}),this}static(t){return t({target:p=>{let d=i=>{let n=this.statePack,r={capabilities:["keyboard"]},a=(s,u=new Set)=>{if(u.has(s))return [];u.add(s);let v=n[s];if(!v)return [];let b=[];if(Array.isArray(v.requires))for(let M of v.requires)b=b.concat(a(M,u));return v.setup&&(b=b.concat(y(v.setup,r))),b};return a(i,new Set)},g=i=>i==="role"?"toHaveRole":"toHaveAttribute",o=(i,n,r)=>{let a=g(i);return {required:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,n)=>({...o(i,n),requires:a=>{let s=d(a);return o(i,n,s)}})}}}),this}when(t){return new f(this,this.statePack,t)}addDynamicTest(t){this.dynamicTests.push(t);}build(){return {meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?this.staticAssertions:[],dynamic:this.dynamicTests}}},f=class{constructor(t,c,p){this.parent=t;this.statePack=c;this.event=p;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,c){return this._onTarget=t,this._onRelativeTarget=c,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return (Array.isArray(t)?t:[t]).flatMap(p=>typeof p=="string"?[p]:typeof p=="object"&&p!==null&&"type"in p&&"ref"in p?this._findStateKeyByTypeAndRef(p.type)?[{type:p.type,ref:p.ref}]:[]:[p])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}describe(t){return this._desc=t,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let p={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},d=(r,a=new Set)=>{if(a.has(r))return [];a.add(r);let s=this.statePack[r];if(!s)return [];let u=[];if(Array.isArray(s.requires))for(let v of s.requires)u=u.concat(d(v,a));return s.setup&&(u=u.concat(y(s.setup,p))),u},g=[];for(let r of this._given)if(typeof r=="string")g.push(...d(r));else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.setup)for(let u of s.setup)typeof u.steps=="function"?g.push(...u.steps({relativeTarget:r.ref})):Array.isArray(u.steps)&&g.push(...u.steps);}}let o=new Set;g=g.filter(r=>{let a=JSON.stringify(r);return o.has(a)?false:(o.add(a),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let a=this.statePack[r];if(a&&a.assertion!==void 0){let s=a.assertion;if(typeof s=="function")try{s=s();}catch(u){throw new Error(`Error calling assertion function for state '${r}': ${u.message}`)}Array.isArray(s)?i.push(...s):i.push(s);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.assertion!==void 0){let u=s.assertion;if(typeof u=="function")try{u=u({relativeTarget:r.ref});}catch(v){throw new Error(`Error calling assertion function for state '${a}': ${v.message}`)}Array.isArray(u)?i.push(...u):i.push(u);}}}let n=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:n,assertions:i,...g.length?{setup:g}:{}});}};function Ee(e,t){let c=new h(e);return t(c),new m(c.build())}exports.createContract=Ee;
1
+ 'use strict';function l(e,t){return t==="first"?`first ${e}`:t==="last"?`last ${e}`:t==="next"?`next ${e}`:t==="previous"?`previous ${e}`:typeof t=="number"?`${e} at index ${t}`:`${t} ${e}`}var k={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:C},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...D(),...T()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:q},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:I},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:B},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:F},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):e.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:e.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(e={})=>H(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:V},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:T},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>R(e.relativeTarget)}};function C(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function D(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function H(e){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first relative item."}]}function V(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function T(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function R(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${l("option",e)} to have aria-selected='true'.`}]}function q(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function I(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function B(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function F(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var x={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:P},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:$},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:O},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:z},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>L(e.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:K},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:U},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:j},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:J},"submenuitem.focused":{requires:["submenupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),e.relativeTarget==="first"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),e.relativeTarget==="last"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>G(e.relativeTarget)}};function P(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function $(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function O(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function z(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function L(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function K(){return [{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function U(){return [{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function j(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function J(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function G(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var A={"tab.active":{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>W(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>X(e.relativeTarget)}};function X(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have focus.`}]}function N(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have tabindex='0'.`}]}function W(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${l("tab",e)} to be visible.`},N(e)]}var w={"panel.expanded":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Q(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Y(e.relativeTarget)}};function Q(e){return [{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected trigger to have aria-expanded='true' when panel expands."}]}function Y(e){return [{target:"panel",assertion:"notToBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger not to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected trigger to have aria-expanded='false' when panel collapses."}]}var S={"radio.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Z(e.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ee(e.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>te(e.relativeTarget)}};function Z(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function ee(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function te(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("radio",e)} to have focus.`}]}var E={"checkbox.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>re(e.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ie(e.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ae(e.relativeTarget)}};function re(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function ie(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function ae(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("checkbox",e)} to have focus.`}]}var M={"toggle.pressed":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>se(e.relativeTarget)},"toggle.unpressed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ne(e.relativeTarget)},"toggle.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>oe(e.relativeTarget)}};function se(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"true",failureMessage:"Expected toggle to have aria-pressed='true' when pressed."}]}function ne(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"false",failureMessage:"Expected toggle to have aria-pressed='false' when unpressed."}]}function oe(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("toggle",e)} to have focus.`}]}function ue(e,t){return t.some(c=>e.capabilities.includes(c))}function m(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let c of e)if(ue(t,c.when))return c.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var pe={combobox:k,menu:x,tabs:A,accordion:w,radio:S,checkbox:E,toggle:M},y=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},f=class{constructor(t){this.componentName=t;this.statePack=pe[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let c=this.statePack,p={capabilities:["keyboard"]},d=(o,i=new Set)=>{if(i.has(o))return [];i.add(o);let n=c[o];if(!n)return [];let r=[];if(Array.isArray(n.requires))for(let a of n.requires)r=r.concat(d(a,i));return n.setup&&(r=r.concat(m(n.setup,p))),r};return t({ariaReference:(o,i,n)=>({requires:r=>{let a=d(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required",setup:a}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional",setup:a}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended",setup:a})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended"})}),contains:(o,i)=>({requires:n=>{let r=d(n,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended"})})}),this}static(t){return t({target:p=>{let d=i=>{let n=this.statePack,r={capabilities:["keyboard"]},a=(s,u=new Set)=>{if(u.has(s))return [];u.add(s);let v=n[s];if(!v)return [];let b=[];if(Array.isArray(v.requires))for(let _ of v.requires)b=b.concat(a(_,u));return v.setup&&(b=b.concat(m(v.setup,r))),b};return a(i,new Set)},g=i=>i==="role"?"toHaveRole":"toHaveAttribute",o=(i,n,r)=>{let a=g(i);return {required:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,n)=>({...o(i,n),requires:a=>{let s=d(a);return o(i,n,s)}})}}}),this}when(t){return new h(this,this.statePack,t)}addDynamicTest(t){this.dynamicTests.push(t);}build(){return {meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?this.staticAssertions:[],dynamic:this.dynamicTests}}},h=class{constructor(t,c,p){this.parent=t;this.statePack=c;this.event=p;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,c){return this._onTarget=t,this._onRelativeTarget=c,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return (Array.isArray(t)?t:[t]).flatMap(p=>typeof p=="string"?[p]:typeof p=="object"&&p!==null&&"type"in p&&"ref"in p?this._findStateKeyByTypeAndRef(p.type)?[{type:p.type,ref:p.ref}]:[]:[p])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}describe(t){return this._desc=t,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let p={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},d=(r,a=new Set)=>{if(a.has(r))return [];a.add(r);let s=this.statePack[r];if(!s)return [];let u=[];if(Array.isArray(s.requires))for(let v of s.requires)u=u.concat(d(v,a));return s.setup&&(u=u.concat(m(s.setup,p))),u},g=[];for(let r of this._given)if(typeof r=="string")g.push(...d(r));else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.setup)for(let u of s.setup)typeof u.steps=="function"?g.push(...u.steps({relativeTarget:r.ref})):Array.isArray(u.steps)&&g.push(...u.steps);}}let o=new Set;g=g.filter(r=>{let a=JSON.stringify(r);return o.has(a)?false:(o.add(a),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let a=this.statePack[r];if(a&&a.assertion!==void 0){let s=a.assertion;if(typeof s=="function")try{s=s();}catch(u){throw new Error(`Error calling assertion function for state '${r}': ${u.message}`)}Array.isArray(s)?i.push(...s):i.push(s);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.assertion!==void 0){let u=s.assertion;if(typeof u=="function")try{u=u({relativeTarget:r.ref});}catch(v){throw new Error(`Error calling assertion function for state '${a}': ${v.message}`)}Array.isArray(u)?i.push(...u):i.push(u);}}}let n=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:n,assertions:i,...g.length?{setup:g}:{}});}};function Re(e,t){let c=new f(e);return t(c),new y(c.build())}exports.createContract=Re;
@@ -1 +1 @@
1
- function l(e,t){return t==="first"?`first ${e}`:t==="last"?`last ${e}`:t==="next"?`next ${e}`:t==="previous"?`previous ${e}`:typeof t=="number"?`${e} at index ${t}`:`${t} ${e}`}var k={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:C},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[..._(),...T()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:R},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:V},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:I},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:B},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):e.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:e.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(e={})=>D(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:H},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:T},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>q(e.relativeTarget)}};function C(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function _(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function D(e){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first relative item."}]}function H(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function T(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function q(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${l("option",e)} to have aria-selected='true'.`}]}function R(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function V(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function I(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function B(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var x={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:F},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:P},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:$},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:O},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>z(e.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:K},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:L},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:j},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:U},"submenuitem.focused":{requires:["submenupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),e.relativeTarget==="first"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),e.relativeTarget==="last"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>J(e.relativeTarget)}};function F(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function P(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function $(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function O(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function z(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function K(){return [{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function L(){return [{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function j(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function U(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function J(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var A={"tab.active":{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>W(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>X(e.relativeTarget)}};function X(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have focus.`}]}function N(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have tabindex='0'.`}]}function W(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${l("tab",e)} to be visible.`},N(e)]}var w={"panel.expanded":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>G(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Q(e.relativeTarget)}};function G(e){return [{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected trigger to have aria-expanded='true' when panel expands."}]}function Q(e){return [{target:"panel",assertion:"notToBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger not to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected trigger to have aria-expanded='false' when panel collapses."}]}var S={"radio.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Y(e.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Z(e.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ee(e.relativeTarget)}};function Y(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function Z(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function ee(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("radio",e)} to have focus.`}]}var E={"checkbox.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>te(e.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>re(e.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ie(e.relativeTarget)}};function te(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function re(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function ie(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("checkbox",e)} to have focus.`}]}function ae(e,t){return t.some(c=>e.capabilities.includes(c))}function y(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let c of e)if(ae(t,c.when))return c.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var se={combobox:k,menu:x,tabs:A,accordion:w,radio:S,checkbox:E},m=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},h=class{constructor(t){this.componentName=t;this.statePack=se[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let c=this.statePack,p={capabilities:["keyboard"]},d=(o,i=new Set)=>{if(i.has(o))return [];i.add(o);let n=c[o];if(!n)return [];let r=[];if(Array.isArray(n.requires))for(let a of n.requires)r=r.concat(d(a,i));return n.setup&&(r=r.concat(y(n.setup,p))),r};return t({ariaReference:(o,i,n)=>({requires:r=>{let a=d(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required",setup:a}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional",setup:a}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended",setup:a})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended"})}),contains:(o,i)=>({requires:n=>{let r=d(n,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended"})})}),this}static(t){return t({target:p=>{let d=i=>{let n=this.statePack,r={capabilities:["keyboard"]},a=(s,u=new Set)=>{if(u.has(s))return [];u.add(s);let v=n[s];if(!v)return [];let b=[];if(Array.isArray(v.requires))for(let M of v.requires)b=b.concat(a(M,u));return v.setup&&(b=b.concat(y(v.setup,r))),b};return a(i,new Set)},g=i=>i==="role"?"toHaveRole":"toHaveAttribute",o=(i,n,r)=>{let a=g(i);return {required:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,n)=>({...o(i,n),requires:a=>{let s=d(a);return o(i,n,s)}})}}}),this}when(t){return new f(this,this.statePack,t)}addDynamicTest(t){this.dynamicTests.push(t);}build(){return {meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?this.staticAssertions:[],dynamic:this.dynamicTests}}},f=class{constructor(t,c,p){this.parent=t;this.statePack=c;this.event=p;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,c){return this._onTarget=t,this._onRelativeTarget=c,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return (Array.isArray(t)?t:[t]).flatMap(p=>typeof p=="string"?[p]:typeof p=="object"&&p!==null&&"type"in p&&"ref"in p?this._findStateKeyByTypeAndRef(p.type)?[{type:p.type,ref:p.ref}]:[]:[p])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}describe(t){return this._desc=t,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let p={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},d=(r,a=new Set)=>{if(a.has(r))return [];a.add(r);let s=this.statePack[r];if(!s)return [];let u=[];if(Array.isArray(s.requires))for(let v of s.requires)u=u.concat(d(v,a));return s.setup&&(u=u.concat(y(s.setup,p))),u},g=[];for(let r of this._given)if(typeof r=="string")g.push(...d(r));else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.setup)for(let u of s.setup)typeof u.steps=="function"?g.push(...u.steps({relativeTarget:r.ref})):Array.isArray(u.steps)&&g.push(...u.steps);}}let o=new Set;g=g.filter(r=>{let a=JSON.stringify(r);return o.has(a)?false:(o.add(a),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let a=this.statePack[r];if(a&&a.assertion!==void 0){let s=a.assertion;if(typeof s=="function")try{s=s();}catch(u){throw new Error(`Error calling assertion function for state '${r}': ${u.message}`)}Array.isArray(s)?i.push(...s):i.push(s);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.assertion!==void 0){let u=s.assertion;if(typeof u=="function")try{u=u({relativeTarget:r.ref});}catch(v){throw new Error(`Error calling assertion function for state '${a}': ${v.message}`)}Array.isArray(u)?i.push(...u):i.push(u);}}}let n=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:n,assertions:i,...g.length?{setup:g}:{}});}};function Ee(e,t){let c=new h(e);return t(c),new m(c.build())}export{Ee as createContract};
1
+ function l(e,t){return t==="first"?`first ${e}`:t==="last"?`last ${e}`:t==="next"?`next ${e}`:t==="previous"?`previous ${e}`:typeof t=="number"?`${e} at index ${t}`:`${t} ${e}`}var k={"comboboxpopup.open":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:C},"comboboxpopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:[...D(),...T()]},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:q},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:I},"input.filled":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:B},"input.empty":{setup:[{when:["keyboard","textInput","pointer"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:F},"option.active":{requires:["comboboxpopup.open"],setup:[{when:["keyboard","pointer"],steps:(e={})=>typeof e.relativeTarget=="number"?Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"main",key:"ArrowDown"})):e.relativeTarget==="first"?[{type:"keypress",target:"main",key:"ArrowDown"}]:e.relativeTarget==="last"?[{type:"keypress",target:"main",key:"ArrowDown"},{type:"keypress",target:"main",key:"ArrowUp"}]:[]}],assertion:(e={})=>H(e.relativeTarget)},"activedescendant.set":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:V},"activedescendant.unset":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:T},"option.selected":{requires:["comboboxpopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",key:"Enter",relativeTarget:e.relativeTarget}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>R(e.relativeTarget)}};function C(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected combobox main to have aria-expanded='true'."}]}function D(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected combobox main to have aria-expanded='false'."}]}function H(e){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:e,property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first relative item."}]}function V(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function T(){return [{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function R(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${l("option",e)} to have aria-selected='true'.`}]}function q(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function I(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function B(){return [{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function F(){return [{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var x={"menupopup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:P},"menupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:$},"main.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"main"}]}],assertion:O},"main.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:z},"menuitem.focused":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>L(e.relativeTarget)},"submenupopup.open":{requires:["menupopup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:K},"submenupopup.closed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:U},"submenutrigger.focused":{setup:[{when:["keyboard","pointer"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:j},"submenutrigger.blurred":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:J},"submenuitem.focused":{requires:["submenupopup.open"],setup:[{when:["keyboard"],steps:(e={})=>{let t=[{type:"focus",target:"submenuTrigger"},{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}];return typeof e.relativeTarget=="number"&&(t=t.concat(Array.from({length:e.relativeTarget},()=>({type:"keypress",target:"submenuItems",key:"ArrowDown"})))),e.relativeTarget==="first"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowDown"})),e.relativeTarget==="last"&&(t=t.concat({type:"keypress",target:"submenuItems",key:"ArrowUp"})),t}},{when:["pointer"],steps:(e={})=>[{type:"click",target:"submenuTrigger"},{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>G(e.relativeTarget)}};function P(){return [{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected menu main to have aria-expanded='true'."}]}function $(){return [{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected menu main to have aria-expanded='false'."}]}function O(){return [{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function z(){return [{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function L(e){return [{target:"relative",assertion:"toHaveFocus",expectedValue:e,failureMessage:`${e} menu item should have focus.`}]}function K(){return [{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected submenu trigger to have aria-expanded='true'."}]}function U(){return [{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected submenu trigger to have aria-expanded='false'."}]}function j(){return [{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function J(){return [{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function G(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveFocus",failureMessage:`Expected submenu item ${e} to have focus.`}]}var A={"tab.active":{setup:[{when:["keyboard"],steps:(e={})=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"ArrowLeft"}]},{when:["pointer"],steps:(e={})=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>W(e.relativeTarget)},"tab.focused":{setup:[{when:["keyboard","pointer"],steps:(e={})=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>X(e.relativeTarget)}};function X(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have focus.`}]}function N(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have tabindex='0'.`}]}function W(e){return [{target:"relative",assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",relativeTarget:e,failureMessage:`Expected ${l("tab",e)} to have aria-selected='true'.`},{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${l("tab",e)} to be visible.`},N(e)]}var w={"panel.expanded":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Q(e.relativeTarget)},"panel.collapsed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>Y(e.relativeTarget)}};function Q(e){return [{target:"panel",assertion:"toBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expected trigger to have aria-expanded='true' when panel expands."}]}function Y(e){return [{target:"panel",assertion:"notToBeVisible",controlledBy:{target:"relative",relativeTarget:e},failureMessage:`Expected panel controlled by the ${e} trigger not to be visible.`},{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expected trigger to have aria-expanded='false' when panel collapses."}]}var S={"radio.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>Z(e.relativeTarget)},"radio.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ee(e.relativeTarget)},"radio.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>te(e.relativeTarget)}};function Z(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected radio to have aria-checked='true' when checked."}]}function ee(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected radio to have aria-checked='false' when unchecked."}]}function te(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("radio",e)} to have focus.`}]}var E={"checkbox.checked":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Space"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>re(e.relativeTarget)},"checkbox.unchecked":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ie(e.relativeTarget)},"checkbox.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>ae(e.relativeTarget)}};function re(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"true",failureMessage:"Expected checkbox to have aria-checked='true' when checked."}]}function ie(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-checked",expectedValue:"false",failureMessage:"Expected checkbox to have aria-checked='false' when unchecked."}]}function ae(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("checkbox",e)} to have focus.`}]}var M={"toggle.pressed":{setup:[{when:["keyboard"],steps:e=>[{type:"keypress",target:"relative",relativeTarget:e.relativeTarget,key:"Enter"}]},{when:["pointer"],steps:e=>[{type:"click",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>se(e.relativeTarget)},"toggle.unpressed":{setup:[{when:["keyboard","pointer"],steps:()=>[]}],assertion:(e={})=>ne(e.relativeTarget)},"toggle.focused":{setup:[{when:["keyboard","pointer"],steps:e=>[{type:"focus",target:"relative",relativeTarget:e.relativeTarget}]}],assertion:(e={})=>oe(e.relativeTarget)}};function se(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"true",failureMessage:"Expected toggle to have aria-pressed='true' when pressed."}]}function ne(e){return [{target:"relative",relativeTarget:e,assertion:"toHaveAttribute",attribute:"aria-pressed",expectedValue:"false",failureMessage:"Expected toggle to have aria-pressed='false' when unpressed."}]}function oe(e){return [{target:"relative",assertion:"toHaveFocus",relativeTarget:e,failureMessage:`Expected ${l("toggle",e)} to have focus.`}]}function ue(e,t){return t.some(c=>e.capabilities.includes(c))}function m(e,t){Array.isArray(e)&&e.length&&!e[0].when&&(e=[{when:["keyboard"],steps:()=>e}]);for(let c of e)if(ue(t,c.when))return c.steps(t);throw new Error(`No setup strategy matches capabilities: ${t.capabilities.join(", ")}`)}var pe={combobox:k,menu:x,tabs:A,accordion:w,radio:S,checkbox:E,toggle:M},y=class{constructor(t){this.jsonContract=t;}toJSON(){return this.jsonContract}},f=class{constructor(t){this.componentName=t;this.statePack=pe[t]||{};}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(t){return this.metaValue=t,this}selectors(t){return this.selectorsValue=t,this}relationships(t){let c=this.statePack,p={capabilities:["keyboard"]},d=(o,i=new Set)=>{if(i.has(o))return [];i.add(o);let n=c[o];if(!n)return [];let r=[];if(Array.isArray(n.requires))for(let a of n.requires)r=r.concat(d(a,i));return n.setup&&(r=r.concat(m(n.setup,p))),r};return t({ariaReference:(o,i,n)=>({requires:r=>{let a=d(r,new Set);return {required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required",setup:a}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional",setup:a}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended",setup:a})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:o,attribute:i,to:n,level:"recommended"})}),contains:(o,i)=>({requires:n=>{let r=d(n,new Set);return {required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required",setup:r}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional",setup:r}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended",setup:r})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:o,child:i,level:"recommended"})})}),this}static(t){return t({target:p=>{let d=i=>{let n=this.statePack,r={capabilities:["keyboard"]},a=(s,u=new Set)=>{if(u.has(s))return [];u.add(s);let v=n[s];if(!v)return [];let b=[];if(Array.isArray(v.requires))for(let _ of v.requires)b=b.concat(a(_,u));return v.setup&&(b=b.concat(m(v.setup,r))),b};return a(i,new Set)},g=i=>i==="role"?"toHaveRole":"toHaveAttribute",o=(i,n,r)=>{let a=g(i);return {required:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"required",setup:r}),optional:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"optional",setup:r}),recommended:()=>this.staticAssertions.push({target:p,assertion:a,attribute:i,expectedValue:n,failureMessage:"",level:"recommended",setup:r})}};return {has:(i,n)=>({...o(i,n),requires:a=>{let s=d(a);return o(i,n,s)}})}}}),this}when(t){return new h(this,this.statePack,t)}addDynamicTest(t){this.dynamicTests.push(t);}build(){return {meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?this.staticAssertions:[],dynamic:this.dynamicTests}}},h=class{constructor(t,c,p){this.parent=t;this.statePack=c;this.event=p;}_as;_onTarget;_onRelativeTarget;_given=[];_then=[];_desc="";_level="required";_orientation;as(t){return this._as=t,this}on(t,c){return this._onTarget=t,this._onRelativeTarget=c,this}given(t){return this._given=this._normalizeStates(t),this}then(t){return this._then=this._normalizeStates(t),this}orientation(t){return this._orientation=t,this}_normalizeStates(t){return (Array.isArray(t)?t:[t]).flatMap(p=>typeof p=="string"?[p]:typeof p=="object"&&p!==null&&"type"in p&&"ref"in p?this._findStateKeyByTypeAndRef(p.type)?[{type:p.type,ref:p.ref}]:[]:[p])}_findStateKeyByTypeAndRef(t){if(Object.keys(this.statePack).includes(t))return t}describe(t){return this._desc=t,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let p={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},d=(r,a=new Set)=>{if(a.has(r))return [];a.add(r);let s=this.statePack[r];if(!s)return [];let u=[];if(Array.isArray(s.requires))for(let v of s.requires)u=u.concat(d(v,a));return s.setup&&(u=u.concat(m(s.setup,p))),u},g=[];for(let r of this._given)if(typeof r=="string")g.push(...d(r));else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.setup)for(let u of s.setup)typeof u.steps=="function"?g.push(...u.steps({relativeTarget:r.ref})):Array.isArray(u.steps)&&g.push(...u.steps);}}let o=new Set;g=g.filter(r=>{let a=JSON.stringify(r);return o.has(a)?false:(o.add(a),true)});let i=[];for(let r of this._then)if(typeof r=="string"){let a=this.statePack[r];if(a&&a.assertion!==void 0){let s=a.assertion;if(typeof s=="function")try{s=s();}catch(u){throw new Error(`Error calling assertion function for state '${r}': ${u.message}`)}Array.isArray(s)?i.push(...s):i.push(s);}}else if(typeof r=="object"&&r!==null&&"type"in r&&"ref"in r){let a=this._findStateKeyByTypeAndRef(r.type);if(a){let s=this.statePack[a];if(s&&s.assertion!==void 0){let u=s.assertion;if(typeof u=="function")try{u=u({relativeTarget:r.ref});}catch(v){throw new Error(`Error calling assertion function for state '${a}': ${v.message}`)}Array.isArray(u)?i.push(...u):i.push(u);}}}let n=[{type:this._as,target:this._onTarget,key:this._as==="keypress"?this.event:void 0,relativeTarget:this._onRelativeTarget}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,orientation:this._orientation||"horizontal",action:n,assertions:i,...g.length?{setup:g}:{}});}};function Re(e,t){let c=new f(e);return t(c),new y(c.build())}export{Re as createContract};
@@ -1,12 +1,12 @@
1
- 'use strict';var playwright=require('playwright'),Pe=require('path'),Le=require('fs-extra'),test=require('@playwright/test'),url=require('url'),fs=require('fs'),L=require('chalk'),jt=require('readline');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Pe__default=/*#__PURE__*/_interopDefault(Pe);var Le__default=/*#__PURE__*/_interopDefault(Le);var L__default=/*#__PURE__*/_interopDefault(L);var jt__default=/*#__PURE__*/_interopDefault(jt);var Ct=Object.defineProperty;var E=(c,e)=>()=>(c&&(e=c(c=0)),e);var z=(c,e)=>{for(var t in e)Ct(c,t,{get:e[t],enumerable:true});};async function At(){return re||(re=await playwright.chromium.launch({headless:true,args:["--disable-extensions","--disable-blink-features=AutomationControlled"]})),re}async function Rt(){return ie||(ie=await(await At()).newContext({permissions:[],ignoreHTTPSErrors:true})),ie}async function Oe(){return await(await Rt()).newPage()}async function qe(){ie&&(await ie.close(),ie=null),re&&(await re.close(),re=null);}var re,ie,be=E(()=>{re=null,ie=null;});function Z(c){return c==="required"||c==="recommended"||c==="optional"?c:xt}function ce(c){return c==="minimal"||c==="balanced"||c==="strict"||c==="paranoid"?c:"balanced"}function _e(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 xt,Te=E(()=>{xt="required";});var ze={};z(ze,{loadConfig:()=>Pt});function Mt(c){let e=[];if(!c||typeof c!="object")return e.push("Config must be an object"),{valid:false,errors:e};let t=c;if(t.audit!==void 0){if(typeof t.audit!="object"||t.audit===null)e.push("audit must be an object");else if(t.audit.urls!==void 0&&(Array.isArray(t.audit.urls)?t.audit.urls.some(r=>typeof r!="string")&&e.push("audit.urls must contain only strings"):e.push("audit.urls must be an array")),t.audit.output!==void 0)if(typeof t.audit.output!="object")e.push("audit.output must be an object");else {let r=t.audit.output;r.format!==void 0&&(["json","csv","html","all"].includes(r.format)||e.push("audit.output.format must be one of: json, csv, html, all")),r.out!==void 0&&typeof r.out!="string"&&e.push("audit.output.out must be a string");}}if(t.test!==void 0)if(typeof t.test!="object"||t.test===null)e.push("test must be an object");else {t.test.disableTimeouts!==void 0&&typeof t.test.disableTimeouts!="boolean"&&e.push("test.disableTimeouts must be a boolean when provided");let r=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let i of r){let n=t.test[i];n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&e.push(`test.${i} must be a non-negative number when provided`);}t.test.components!==void 0&&(Array.isArray(t.test.components)?t.test.components.forEach((i,n)=>{if(typeof i!="object"||i===null)e.push(`test.components[${n}] must be an object`);else {typeof i.name!="string"&&e.push(`test.components[${n}].name must be a string`),i.contractPath!==void 0&&typeof i.contractPath!="string"&&e.push(`test.components[${n}].contractPath must be a string when provided`),i.strategyPath!==void 0&&typeof i.strategyPath!="string"&&e.push(`test.components[${n}].strategyPath must be a string when provided`),i.strictness!==void 0&&!["minimal","balanced","strict","paranoid"].includes(i.strictness)&&e.push(`test.components[${n}].strictness must be one of: minimal, balanced, strict, paranoid`),i.disableTimeouts!==void 0&&typeof i.disableTimeouts!="boolean"&&e.push(`test.components[${n}].disableTimeouts must be a boolean when provided`);let a=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let o of a){let f=i[o];f!==void 0&&(typeof f!="number"||!Number.isFinite(f)||f<0)&&e.push(`test.components[${n}].${o} must be a non-negative number when provided`);}}}):e.push("test.components must be an array")),t.test.strictness!==void 0&&(["minimal","balanced","strict","paranoid"].includes(t.test.strictness)||e.push("test.strictness must be one of: minimal, balanced, strict, paranoid"));}return t.contracts!==void 0&&(Array.isArray(t.contracts)?t.contracts.forEach((r,i)=>{typeof r!="object"||r===null?e.push(`contracts[${i}] must be an object`):(typeof r.src!="string"&&e.push(`contracts[${i}].src is required and must be a string`),r.out!==void 0&&typeof r.out!="string"&&e.push(`contracts[${i}].out must be a string`));}):e.push("contracts must be an array")),{valid:e.length===0,errors:e}}async function Et(c){try{let e=Pe__default.default.extname(c);if(e===".json"){let t=await Le__default.default.readFile(c,"utf-8");return JSON.parse(t)}else if([".js",".mjs",".cjs",".ts"].includes(e)){let t=await import(c);return t.default||t}return null}catch{return null}}async function Pt(c=process.cwd()){let e=["ariaease.config.js","ariaease.config.mjs","ariaease.config.cjs","ariaease.config.json","ariaease.config.ts"],t=null,r=null,i=[];for(let n of e){let a=Pe__default.default.resolve(c,n);if(await Le__default.default.pathExists(a)){if(r=a,t=await Et(a),t===null){i.push(`Found config at ${n} but failed to load it. Check for syntax errors.`);continue}let o=Mt(t);if(!o.valid){i.push(`Config validation failed in ${n}:`),i.push(...o.errors.map(f=>` - ${f}`)),t=null;continue}break}}return {config:t||{},configPath:t?r:null,errors:i}}var Ge=E(()=>{});var Ne={};z(Ne,{MenuComponentStrategy:()=>$e});var $e,Ye=E(()=>{$e=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>false))return;let n=false,a=this.selectors.main;if(a&&(await e.locator(a).first().focus(),await e.keyboard.press("Escape"),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n&&this.selectors.main&&(await e.locator(this.selectors.main).first().click({timeout:this.actionTimeoutMs}),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),n||(await e.mouse.click(10,10),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n)throw new Error(`\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
1
+ 'use strict';var playwright=require('playwright'),Be=require('path'),Fe=require('fs-extra'),test=require('@playwright/test'),url=require('url'),fs=require('fs'),L=require('chalk'),Ot=require('readline');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Be__default=/*#__PURE__*/_interopDefault(Be);var Fe__default=/*#__PURE__*/_interopDefault(Fe);var L__default=/*#__PURE__*/_interopDefault(L);var Ot__default=/*#__PURE__*/_interopDefault(Ot);var Rt=Object.defineProperty;var x=(c,e)=>()=>(c&&(e=c(c=0)),e);var _=(c,e)=>{for(var t in e)Rt(c,t,{get:e[t],enumerable:true});};async function xt(){return re||(re=await playwright.chromium.launch({headless:true,args:["--disable-extensions","--disable-blink-features=AutomationControlled"]})),re}async function Et(){return ie||(ie=await(await xt()).newContext({permissions:[],ignoreHTTPSErrors:true})),ie}async function qe(){return await(await Et()).newPage()}async function _e(){ie&&(await ie.close(),ie=null),re&&(await re.close(),re=null);}var re,ie,be=x(()=>{re=null,ie=null;});function Z(c){return c==="required"||c==="recommended"||c==="optional"?c:Pt}function ce(c){return c==="minimal"||c==="balanced"||c==="strict"||c==="paranoid"?c:"balanced"}function Je(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 Pt,Te=x(()=>{Pt="required";});var Ge={};_(Ge,{loadConfig:()=>Lt});function Bt(c){let e=[];if(!c||typeof c!="object")return e.push("Config must be an object"),{valid:false,errors:e};let t=c;if(t.audit!==void 0){if(typeof t.audit!="object"||t.audit===null)e.push("audit must be an object");else if(t.audit.urls!==void 0&&(Array.isArray(t.audit.urls)?t.audit.urls.some(r=>typeof r!="string")&&e.push("audit.urls must contain only strings"):e.push("audit.urls must be an array")),t.audit.output!==void 0)if(typeof t.audit.output!="object")e.push("audit.output must be an object");else {let r=t.audit.output;r.format!==void 0&&(["json","csv","html","all"].includes(r.format)||e.push("audit.output.format must be one of: json, csv, html, all")),r.out!==void 0&&typeof r.out!="string"&&e.push("audit.output.out must be a string");}}if(t.test!==void 0)if(typeof t.test!="object"||t.test===null)e.push("test must be an object");else {t.test.disableTimeouts!==void 0&&typeof t.test.disableTimeouts!="boolean"&&e.push("test.disableTimeouts must be a boolean when provided");let r=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let i of r){let n=t.test[i];n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&e.push(`test.${i} must be a non-negative number when provided`);}t.test.components!==void 0&&(Array.isArray(t.test.components)?t.test.components.forEach((i,n)=>{if(typeof i!="object"||i===null)e.push(`test.components[${n}] must be an object`);else {typeof i.name!="string"&&e.push(`test.components[${n}].name must be a string`),i.contractPath!==void 0&&typeof i.contractPath!="string"&&e.push(`test.components[${n}].contractPath must be a string when provided`),i.strategyPath!==void 0&&typeof i.strategyPath!="string"&&e.push(`test.components[${n}].strategyPath must be a string when provided`),i.strictness!==void 0&&!["minimal","balanced","strict","paranoid"].includes(i.strictness)&&e.push(`test.components[${n}].strictness must be one of: minimal, balanced, strict, paranoid`),i.disableTimeouts!==void 0&&typeof i.disableTimeouts!="boolean"&&e.push(`test.components[${n}].disableTimeouts must be a boolean when provided`);let a=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let o of a){let f=i[o];f!==void 0&&(typeof f!="number"||!Number.isFinite(f)||f<0)&&e.push(`test.components[${n}].${o} must be a non-negative number when provided`);}}}):e.push("test.components must be an array")),t.test.strictness!==void 0&&(["minimal","balanced","strict","paranoid"].includes(t.test.strictness)||e.push("test.strictness must be one of: minimal, balanced, strict, paranoid"));}return t.contracts!==void 0&&(Array.isArray(t.contracts)?t.contracts.forEach((r,i)=>{typeof r!="object"||r===null?e.push(`contracts[${i}] must be an object`):(typeof r.src!="string"&&e.push(`contracts[${i}].src is required and must be a string`),r.out!==void 0&&typeof r.out!="string"&&e.push(`contracts[${i}].out must be a string`));}):e.push("contracts must be an array")),{valid:e.length===0,errors:e}}async function It(c){try{let e=Be__default.default.extname(c);if(e===".json"){let t=await Fe__default.default.readFile(c,"utf-8");return JSON.parse(t)}else if([".js",".mjs",".cjs",".ts"].includes(e)){let t=await import(c);return t.default||t}return null}catch{return null}}async function Lt(c=process.cwd()){let e=["ariaease.config.js","ariaease.config.mjs","ariaease.config.cjs","ariaease.config.json","ariaease.config.ts"],t=null,r=null,i=[];for(let n of e){let a=Be__default.default.resolve(c,n);if(await Fe__default.default.pathExists(a)){if(r=a,t=await It(a),t===null){i.push(`Found config at ${n} but failed to load it. Check for syntax errors.`);continue}let o=Bt(t);if(!o.valid){i.push(`Config validation failed in ${n}:`),i.push(...o.errors.map(f=>` - ${f}`)),t=null;continue}break}}return {config:t||{},configPath:t?r:null,errors:i}}var Ne=x(()=>{});var Ye={};_(Ye,{MenuComponentStrategy:()=>$e});var $e,Qe=x(()=>{$e=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>false))return;let n=false,a=this.selectors.main;if(a&&(await e.locator(a).first().focus(),await e.keyboard.press("Escape"),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n&&this.selectors.main&&(await e.locator(this.selectors.main).first().click({timeout:this.actionTimeoutMs}),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),n||(await e.mouse.click(10,10),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n)throw new Error(`\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
2
2
  1. Escape key
3
3
  2. Clicking trigger
4
4
  3. Clicking outside
5
- This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus();}async shouldSkipTest(e,t){if(!(e.action.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")||e.assertions.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")))return false;let i=this.selectors.submenuTrigger;return i?await t.locator(i).count()===0:true}getMainSelector(){return this.mainSelector}};});var Qe={};z(Qe,{AccordionComponentStrategy:()=>Ce});var Ce,Xe=E(()=>{Ce=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.panel||!this.selectors.trigger)return;let t=this.selectors.trigger,r=this.selectors.panel;if(!t||!r)return;let i=await e.locator(t).all();for(let n of i){let a=await n.getAttribute("aria-expanded")==="true",o=await n.getAttribute("aria-controls");if(a&&o){await n.click({timeout:this.actionTimeoutMs});let f=e.locator(`#${o}`);await test.expect(f).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{});}}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var Ze={};z(Ze,{ComboboxComponentStrategy:()=>Ae});var Ae,et=E(()=>{Ae=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>false))return;let n=false,a=this.selectors.main;if(a&&(await e.locator(a).first().focus(),await e.keyboard.press("Escape"),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n&&this.selectors.button&&(await e.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),n||(await e.mouse.click(10,10),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
5
+ This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus();}async shouldSkipTest(e,t){if(!(e.action.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")||e.assertions.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")))return false;let i=this.selectors.submenuTrigger;return i?await t.locator(i).count()===0:true}getMainSelector(){return this.mainSelector}};});var Xe={};_(Xe,{AccordionComponentStrategy:()=>Ce});var Ce,Ze=x(()=>{Ce=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.panel||!this.selectors.trigger)return;let t=this.selectors.trigger,r=this.selectors.panel;if(!t||!r)return;let i=await e.locator(t).all();for(let n of i){let a=await n.getAttribute("aria-expanded")==="true",o=await n.getAttribute("aria-controls");if(a&&o){await n.click({timeout:this.actionTimeoutMs});let f=e.locator(`#${o}`);await test.expect(f).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{});}}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var et={};_(et,{ComboboxComponentStrategy:()=>Ae});var Ae,tt=x(()=>{Ae=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>false))return;let n=false,a=this.selectors.main;if(a&&(await e.locator(a).first().focus(),await e.keyboard.press("Escape"),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n&&this.selectors.button&&(await e.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),n||(await e.mouse.click(10,10),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
6
6
  1. Escape key
7
7
  2. Clicking button
8
8
  3. Clicking outside
9
- 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 false}getMainSelector(){return this.mainSelector}};});var tt={};z(tt,{TabsComponentStrategy:()=>Re});var Re,st=E(()=>{Re=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,n=await t.locator(r).first().getAttribute("aria-orientation");if(e.orientation!==n)return true}return false}getMainSelector(){return this.mainSelector}};});var rt={};z(rt,{RadioComponentStrategy:()=>xe});var xe,it=E(()=>{xe=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.radio||!this.selectors.relative)return;let t=this.selectors.radio;if(!t)return;let r=await e.locator(t).all();for(let i of r)if(await i.getAttribute("aria-checked")==="true"){await i.evaluate(o=>o.setAttribute("aria-checked","false"),{timeout:this.actionTimeoutMs});let a=e.locator(`#${i}`);await test.expect(a).toHaveAttribute("aria-checked","false",{timeout:this.assertionTimeoutMs}).catch(()=>{});}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var nt={};z(nt,{CheckboxComponentStrategy:()=>Me});var Me,ot=E(()=>{Me=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.checkbox||!this.selectors.relative)return;let t=this.selectors.checkbox;if(!t)return;let r=await e.locator(t).all();for(let i of r)if(await i.getAttribute("aria-checked")==="true"){await i.click({timeout:this.actionTimeoutMs});let a=e.locator(`#${i}`);await test.expect(a).toHaveAttribute("aria-checked","false",{timeout:this.assertionTimeoutMs}).catch(()=>{});}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var fe,ct=E(()=>{fe=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies();}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>Promise.resolve().then(()=>(Ye(),Ne)).then(e=>e.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>Promise.resolve().then(()=>(Xe(),Qe)).then(e=>e.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>Promise.resolve().then(()=>(et(),Ze)).then(e=>e.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>Promise.resolve().then(()=>(st(),tt)).then(e=>e.TabsComponentStrategy)),this.builtInStrategies.set("radio",()=>Promise.resolve().then(()=>(it(),rt)).then(e=>e.RadioComponentStrategy)),this.builtInStrategies.set("checkbox",()=>Promise.resolve().then(()=>(ot(),nt)).then(e=>e.CheckboxComponentStrategy));}async loadStrategy(e,t,r){try{if(t)try{let n=Pe__default.default.isAbsolute(t)?t:Pe__default.default.resolve(r||process.cwd(),t),a=await import(url.pathToFileURL(n).href),o=a.default||a;if(!o)throw new Error(`No default export found in ${t}`);return o}catch(n){throw new Error(`Failed to load custom strategy from ${t}: ${n instanceof Error?n.message:String(n)}`)}let i=this.builtInStrategies.get(e);return i?i():null}catch(i){throw new Error(`Strategy loading failed for ${e}: ${i instanceof Error?i.message:String(i)}`)}}has(e,t){return !!t||this.builtInStrategies.has(e)}};});var ge,lt=E(()=>{ct();ge=class{static strategyRegistry=new fe;static isComponentConfig(e){return typeof e=="object"&&e!==null}static async detect(e,t,r=400,i=400,n){let a=this.isComponentConfig(t)?t:void 0,o=a?.contractPath;if(!o)throw new Error(`Contract path not found for component: ${e}`);let f=(()=>{if(Pe__default.default.isAbsolute(o))return o;if(n){let ue=Pe__default.default.resolve(n,o);try{return fs.readFileSync(ue,"utf-8"),ue}catch{}}let ee=Pe__default.default.resolve(process.cwd(),o);try{return fs.readFileSync(ee,"utf-8"),ee}catch{return new URL(o,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname}})(),$=fs.readFileSync(f,"utf-8"),P=JSON.parse($).selectors,B=await this.strategyRegistry.loadStrategy(e,a?.strategyPath,n);if(!B)return null;let G=P.main;return e==="tabs"?new B(G,P):new B(G,P,r,i)}};});var de,ut=E(()=>{de=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=false;isCustomContract=false;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=false;hasPrintedDynamicSection=false;constructor(e=false,t=false){this.isPlaywright=e,this.isCustomContract=t;}log(e){process.stderr.write(e+`
9
+ 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 false}getMainSelector(){return this.mainSelector}};});var st={};_(st,{TabsComponentStrategy:()=>Re});var Re,rt=x(()=>{Re=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,n=await t.locator(r).first().getAttribute("aria-orientation");if(e.orientation!==n)return true}return false}getMainSelector(){return this.mainSelector}};});var it={};_(it,{RadioComponentStrategy:()=>Me});var Me,nt=x(()=>{Me=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.radio||!this.selectors.relative)return;let t=this.selectors.radio;if(!t)return;let r=await e.locator(t).all();for(let i of r)if(await i.getAttribute("aria-checked")==="true"){await i.evaluate(o=>o.setAttribute("aria-checked","false"),{timeout:this.actionTimeoutMs});let a=e.locator(`#${i}`);await test.expect(a).toHaveAttribute("aria-checked","false",{timeout:this.assertionTimeoutMs}).catch(()=>{});}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var ot={};_(ot,{CheckboxComponentStrategy:()=>xe});var xe,at=x(()=>{xe=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.checkbox||!this.selectors.relative)return;let t=this.selectors.checkbox;if(!t)return;let r=await e.locator(t).all();for(let i of r)if(await i.getAttribute("aria-checked")==="true"){await i.click({timeout:this.actionTimeoutMs});let a=e.locator(`#${i}`);await test.expect(a).toHaveAttribute("aria-checked","false",{timeout:this.assertionTimeoutMs}).catch(()=>{});}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var ct={};_(ct,{ToggleComponentStrategy:()=>Ee});var Ee,lt=x(()=>{Ee=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.toggle||!this.selectors.relative)return;let t=this.selectors.toggle;if(!t)return;let r=await e.locator(t).all();for(let i of r)if(await i.getAttribute("aria-pressed")==="true"){await i.click({timeout:this.actionTimeoutMs});let a=e.locator(`#${i}`);await test.expect(a).toHaveAttribute("aria-pressed","false",{timeout:this.assertionTimeoutMs}).catch(()=>{});}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var fe,pt=x(()=>{fe=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies();}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>Promise.resolve().then(()=>(Qe(),Ye)).then(e=>e.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>Promise.resolve().then(()=>(Ze(),Xe)).then(e=>e.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>Promise.resolve().then(()=>(tt(),et)).then(e=>e.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>Promise.resolve().then(()=>(rt(),st)).then(e=>e.TabsComponentStrategy)),this.builtInStrategies.set("radio",()=>Promise.resolve().then(()=>(nt(),it)).then(e=>e.RadioComponentStrategy)),this.builtInStrategies.set("checkbox",()=>Promise.resolve().then(()=>(at(),ot)).then(e=>e.CheckboxComponentStrategy)),this.builtInStrategies.set("toggle",()=>Promise.resolve().then(()=>(lt(),ct)).then(e=>e.ToggleComponentStrategy));}async loadStrategy(e,t,r){try{if(t)try{let n=Be__default.default.isAbsolute(t)?t:Be__default.default.resolve(r||process.cwd(),t),a=await import(url.pathToFileURL(n).href),o=a.default||a;if(!o)throw new Error(`No default export found in ${t}`);return o}catch(n){throw new Error(`Failed to load custom strategy from ${t}: ${n instanceof Error?n.message:String(n)}`)}let i=this.builtInStrategies.get(e);return i?i():null}catch(i){throw new Error(`Strategy loading failed for ${e}: ${i instanceof Error?i.message:String(i)}`)}}has(e,t){return !!t||this.builtInStrategies.has(e)}};});var ge,ft=x(()=>{pt();ge=class{static strategyRegistry=new fe;static isComponentConfig(e){return typeof e=="object"&&e!==null}static async detect(e,t,r=400,i=400,n){let a=this.isComponentConfig(t)?t:void 0,o=a?.contractPath;if(!o)throw new Error(`Contract path not found for component: ${e}`);let f=(()=>{if(Be__default.default.isAbsolute(o))return o;if(n){let ue=Be__default.default.resolve(n,o);try{return fs.readFileSync(ue,"utf-8"),ue}catch{}}let ee=Be__default.default.resolve(process.cwd(),o);try{return fs.readFileSync(ee,"utf-8"),ee}catch{return new URL(o,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname}})(),$=fs.readFileSync(f,"utf-8"),P=JSON.parse($).selectors,B=await this.strategyRegistry.loadStrategy(e,a?.strategyPath,n);if(!B)return null;let G=P.main;return e==="tabs"?new B(G,P):new B(G,P,r,i)}};});var de,gt=x(()=>{de=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=false;isCustomContract=false;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=false;hasPrintedDynamicSection=false;constructor(e=false,t=false){this.isPlaywright=e,this.isCustomContract=t;}log(e){process.stderr.write(e+`
10
10
  `);}start(e,t,r){this.startTime=Date.now(),this.componentName=e,this.totalTests=t,this.hasPrintedStaticSection=false,this.hasPrintedDynamicSection=false,r&&(this.apgUrl=r);let i="Playwright (Real Browser)";this.log(`
11
11
  ${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${e.charAt(0).toUpperCase()+e.slice(1)} Component - ${i}`),this.log(`${"\u2550".repeat(60)}
12
12
  `);}reportStatic(e,t,r=0){this.staticPasses=e,this.staticFailures=t,this.staticWarnings=r;}reportStaticTest(e,t,r,i){this.hasPrintedStaticSection||(this.log(`${"\u2500".repeat(60)}`),this.log("\u{1F9EA} Static Assertions"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedStaticSection=true);let n=t==="pass"?"\u2713":t==="warn"?"\u26A0":t==="skip"?"\u25CB":"\u2717";this.log(` ${n} ${e}`),i&&this.log(` \u21B3 level=${i}`),(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=true);let i={description:e.description,status:t,failureMessage:r,level:e.level};t==="skip"&&(i.skipReason="Requires real browser (addEventListener events)"),this.dynamicResults.push(i);let n={pass:"\u2713",fail:"\u2717",warn:"\u26A0",skip:"\u25CB"},a=e.level?`[${e.level.toUpperCase()}] `:"";this.log(` ${n[t]} ${a}${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(`
@@ -27,15 +27,15 @@ ${"\u2550".repeat(60)}`),this.log(`\u{1F4CA} Summary
27
27
  `),o>0?(this.log("\u{1F527} Next Steps:"),this.log(" 1. Review the failures above"),this.log(" 2. Fix ARIA attributes and keyboard handlers"),this.log(` 3. Re-run tests to verify fixes
28
28
  `)):!this.isPlaywright&&this.skipped>0&&this.log(`\u2728 Optional: Run Playwright tests for complete validation
29
29
  `),{passes:a,failures:o,skipped:this.skipped,duration:t}}error(e,t){this.log(`
30
- \u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("");}};});var pt={};z(pt,{RelativeTargetResolver:()=>O});var O,me=E(()=>{O=class{static async resolve(e,t,r){let i=await e.locator(t).all();if(typeof r=="number")return i[r-1];switch(r){case "first":return i[0];case "second":return i[1];case "last":return i[i.length-1];case "next":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])+1)%i.length;return i[a]}case "previous":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])-1+i.length)%i.length;return i[a]}default:return null}}};});var ne,ft=E(()=>{me();ne=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,t,r){try{if(e==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let a=this.page.locator(n).first();return await a.count()?(await a.evaluate((f,$)=>{f.setAttribute("aria-activedescendant",$);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let a=await O.resolve(this.page,n,t);return a?(await a.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let i=this.selectors[e];return i?(await this.page.locator(i).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${e}: ${i instanceof Error?i.message:String(i)}`}}}async type(e,t){try{let r=this.selectors[e];return r?(await this.page.locator(r).first().fill(t,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${e}: ${r instanceof Error?r.message:String(r)}`}}}async click(e,t){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for click action."};let n=await O.resolve(this.page,i,t);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for click.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${e}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(e,t,r){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[t]||t;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),e==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let $=this.selectors.relative;if(!$)return {success:!1,error:"Relative selector not defined for keypress action."};let y=await O.resolve(this.page,$,r);return y?(await y.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let a=this.selectors[e];if(!a)return {success:!1,error:`Selector for keypress target ${e} not found.`};let o=this.page.locator(a).first();return await o.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await o.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${t} on ${e}: ${i instanceof Error?i.message:String(i)}`}}}async hover(e,t){try{if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for hover action."};let n=await O.resolve(this.page,i,t);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for hover.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${e}: ${r instanceof Error?r.message:String(r)}`}}}};});var le,gt=E(()=>{me();le=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}async resolveTarget(e,t,r){try{if(e==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!t)return {target:null,error:"Relative target or expected value is not defined."};let a=await O.resolve(this.page,n,t);return a?{target:a}:{target:null,error:`Target ${e} not found.`}}let i=this.selectors[e];return i?{target:this.page.locator(i).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(i){return {target:null,error:`Failed to resolve target ${e}: ${i instanceof Error?i.message:String(i)}`}}}async validateVisibility(e,t,r,i,n){try{return r?(await test.expect(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${n}".`}):(await test.expect(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${n}".`})}catch{let a=this.selectors[t]||"",o=await this.page.evaluate(f=>{let $=f?document.querySelector(f):null;if(!$)return "element not found";let y=window.getComputedStyle($);return `display:${y.display}, visibility:${y.visibility}, opacity:${y.opacity}`},a);return r?{success:false,failMessage:`${i} (actual: ${o})`}:{success:false,failMessage:`${i} ${t} is still visible (actual: ${o}).`}}}async validateAttribute(e,t,r,i,n,a){if(i==="!empty"){let $=await e.getAttribute(r);return $&&$.trim()!==""?{success:true,passMessage:`${t} has non-empty "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should not be empty, found "${$}".`}}if(typeof i!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",i),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(i)}`);let o=i.split(" | ").map($=>$.trim()),f=await e.getAttribute(r);return f!==null&&o.includes(f)?{success:true,passMessage:`${t} has expected "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should be "${i}", found "${f}".`}}async validateValue(e,t,r,i,n){let a=await e.inputValue().catch(()=>"");return r==="!empty"?a&&a.trim()!==""?{success:true,passMessage:`${t} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should not be empty, found "${a}".`}:r===""?a===""?{success:true,passMessage:`${t} has empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be empty, found "${a}".`}:a===r?{success:true,passMessage:`${t} has expected value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be "${r}", found "${a}".`}}async validateFocus(e,t,r,i,n){try{return r?(await test.expect(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${n}".`}):(await test.expect(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${n}".`})}catch{let a=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${i} (actual focus: ${a})`}}}async validateRole(e,t,r,i,n){let a=await e.getAttribute("role");return a===r?{success:true,passMessage:`${t} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${i} Expected role "${r}", found "${a}".`}}async validate(e,t){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,i;if(e.controlledBy){let n=e.controlledBy,a=this.selectors[n.target];if(!a)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let o=null;if(n.relativeTarget?o=await O.resolve(this.page,a,n.relativeTarget):o=this.page.locator(a).first(),!o)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let f=n.attribute||"aria-controls",$=await o.getAttribute(f);if(!$)return {success:false,failMessage:`Controlling element does not have attribute '${f}'.`,target:null};if(r=this.page.locator(`#${$}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${$}' not found.`,target:null}}else {let n=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(r=n.target,i=n.error,i||!r)return {success:false,failMessage:i||`Target ${e.target} not found.`,target:null}}if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let n=await O.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),a=n?await n.getAttribute("id"):null,o=await r.getAttribute("aria-activedescendant");return a&&o===a?{success:true,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case "toBeVisible":return this.validateVisibility(r,e.target,true,e.failureMessage||"",t);case "notToBeVisible":return this.validateVisibility(r,e.target,false,e.failureMessage||"",t);case "toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(r,e.target,e.attribute,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return e.expectedValue!==void 0?this.validateValue(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,e.target,true,e.failureMessage||"",t);case "notToHaveFocus":return this.validateFocus(r,e.target,false,e.failureMessage||"",t);case "toHaveRole":return e.expectedValue!==void 0?this.validateRole(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${e.assertion}`}}}};});var dt={};z(dt,{runContractTestsPlaywright:()=>Vt});async function Vt(c,e,t,r,i){let n=r?.test?.components?.find(h=>h.name===c),a=!!n?.contractPath,o=new de(true,a),f={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},$=r?.test?.disableTimeouts===true,P=n?.disableTimeouts===true||$,B=(h,_,J)=>{if(P)return 0;let D=h??_;return typeof D!="number"||!Number.isFinite(D)||D<0?J:D},G=B(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,f.actionTimeoutMs),ee=B(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,f.assertionTimeoutMs),ue=B(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,f.navigationTimeoutMs),ye=B(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,f.componentReadyTimeoutMs),Ve=ce(t),te=n?.contractPath;if(!te)throw new Error(`Contract path not found for component: ${c}`);let wt=(()=>{if(Pe__default.default.isAbsolute(te))return te;if(i){let _=Pe__default.default.resolve(i,te);try{return fs.readFileSync(_,"utf-8"),_}catch{}}let h=Pe__default.default.resolve(process.cwd(),te);try{return fs.readFileSync(h,"utf-8"),h}catch{return new URL(te,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname}})(),bt=fs.readFileSync(wt,"utf-8"),C=JSON.parse(bt),Tt=(C.relationships?.length||0)+(C.static.length||0)+C.dynamic.length,St=C.meta?.source?.apg,H=[],N=[],Y=[],I=[],T=null,M=(h,_)=>{let J=Z(_),D=_e(J,Ve);if(D==="error")return H.push(h),{status:"fail",level:J,detail:h};if(D==="warning")return N.push(h),{status:"warn",level:J,detail:h};let K=`${h} (ignored by strictness=${Ve}, level=${J})`;return I.push(K),{status:"skip",level:J,detail:K}};try{if(T=await Oe(),e){try{await T.goto(e,{waitUntil:"domcontentloaded",timeout:ue});}catch(s){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${s instanceof Error?s.message:String(s)}`)}await T.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let h=await ge.detect(c,n,G,ee,i);if(!h)throw new Error(`Unsupported component: ${c}`);let _=h.getMainSelector();if(!_)throw new Error(`CRITICAL: No selector found in contract for ${c}`);try{await T.locator(_).first().waitFor({state:"attached",timeout:ye});}catch(s){throw new Error(`
30
+ \u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("");}};});var dt={};_(dt,{RelativeTargetResolver:()=>O});var O,me=x(()=>{O=class{static async resolve(e,t,r){let i=await e.locator(t).all();if(typeof r=="number")return i[r-1];switch(r){case "first":return i[0];case "second":return i[1];case "last":return i[i.length-1];case "next":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])+1)%i.length;return i[a]}case "previous":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])-1+i.length)%i.length;return i[a]}default:return null}}};});var ne,mt=x(()=>{me();ne=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,t,r){try{if(e==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let a=this.page.locator(n).first();return await a.count()?(await a.evaluate((f,$)=>{f.setAttribute("aria-activedescendant",$);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let a=await O.resolve(this.page,n,t);return a?(await a.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let i=this.selectors[e];return i?(await this.page.locator(i).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${e}: ${i instanceof Error?i.message:String(i)}`}}}async type(e,t){try{let r=this.selectors[e];return r?(await this.page.locator(r).first().fill(t,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${e}: ${r instanceof Error?r.message:String(r)}`}}}async click(e,t){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for click action."};let n=await O.resolve(this.page,i,t);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for click.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${e}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(e,t,r){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[t]||t;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),e==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let $=this.selectors.relative;if(!$)return {success:!1,error:"Relative selector not defined for keypress action."};let y=await O.resolve(this.page,$,r);return y?(await y.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let a=this.selectors[e];if(!a)return {success:!1,error:`Selector for keypress target ${e} not found.`};let o=this.page.locator(a).first();return await o.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await o.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${t} on ${e}: ${i instanceof Error?i.message:String(i)}`}}}async hover(e,t){try{if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for hover action."};let n=await O.resolve(this.page,i,t);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for hover.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${e}: ${r instanceof Error?r.message:String(r)}`}}}};});var le,ht=x(()=>{me();le=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}async resolveTarget(e,t,r){try{if(e==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!t)return {target:null,error:"Relative target or expected value is not defined."};let a=await O.resolve(this.page,n,t);return a?{target:a}:{target:null,error:`Target ${e} not found.`}}let i=this.selectors[e];return i?{target:this.page.locator(i).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(i){return {target:null,error:`Failed to resolve target ${e}: ${i instanceof Error?i.message:String(i)}`}}}async validateVisibility(e,t,r,i,n){try{return r?(await test.expect(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${n}".`}):(await test.expect(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${n}".`})}catch{let a=this.selectors[t]||"",o=await this.page.evaluate(f=>{let $=f?document.querySelector(f):null;if(!$)return "element not found";let y=window.getComputedStyle($);return `display:${y.display}, visibility:${y.visibility}, opacity:${y.opacity}`},a);return r?{success:false,failMessage:`${i} (actual: ${o})`}:{success:false,failMessage:`${i} ${t} is still visible (actual: ${o}).`}}}async validateAttribute(e,t,r,i,n,a){if(i==="!empty"){let $=await e.getAttribute(r);return $&&$.trim()!==""?{success:true,passMessage:`${t} has non-empty "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should not be empty, found "${$}".`}}if(typeof i!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",i),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(i)}`);let o=i.split(" | ").map($=>$.trim()),f=await e.getAttribute(r);return f!==null&&o.includes(f)?{success:true,passMessage:`${t} has expected "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should be "${i}", found "${f}".`}}async validateValue(e,t,r,i,n){let a=await e.inputValue().catch(()=>"");return r==="!empty"?a&&a.trim()!==""?{success:true,passMessage:`${t} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should not be empty, found "${a}".`}:r===""?a===""?{success:true,passMessage:`${t} has empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be empty, found "${a}".`}:a===r?{success:true,passMessage:`${t} has expected value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be "${r}", found "${a}".`}}async validateFocus(e,t,r,i,n){try{return r?(await test.expect(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${n}".`}):(await test.expect(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${n}".`})}catch{let a=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${i} (actual focus: ${a})`}}}async validateRole(e,t,r,i,n){let a=await e.getAttribute("role");return a===r?{success:true,passMessage:`${t} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${i} Expected role "${r}", found "${a}".`}}async validate(e,t){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,i;if(e.controlledBy){let n=e.controlledBy,a=this.selectors[n.target];if(!a)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let o=null;if(n.relativeTarget?o=await O.resolve(this.page,a,n.relativeTarget):o=this.page.locator(a).first(),!o)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let f=n.attribute||"aria-controls",$=await o.getAttribute(f);if(!$)return {success:false,failMessage:`Controlling element does not have attribute '${f}'.`,target:null};if(r=this.page.locator(`#${$}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${$}' not found.`,target:null}}else {let n=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(r=n.target,i=n.error,i||!r)return {success:false,failMessage:i||`Target ${e.target} not found.`,target:null}}if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let n=await O.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),a=n?await n.getAttribute("id"):null,o=await r.getAttribute("aria-activedescendant");return a&&o===a?{success:true,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case "toBeVisible":return this.validateVisibility(r,e.target,true,e.failureMessage||"",t);case "notToBeVisible":return this.validateVisibility(r,e.target,false,e.failureMessage||"",t);case "toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(r,e.target,e.attribute,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return e.expectedValue!==void 0?this.validateValue(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,e.target,true,e.failureMessage||"",t);case "notToHaveFocus":return this.validateFocus(r,e.target,false,e.failureMessage||"",t);case "toHaveRole":return e.expectedValue!==void 0?this.validateRole(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${e.assertion}`}}}};});var yt={};_(yt,{runContractTestsPlaywright:()=>Dt});async function Dt(c,e,t,r,i){let n=r?.test?.components?.find(h=>h.name===c),a=!!n?.contractPath,o=new de(true,a),f={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},$=r?.test?.disableTimeouts===true,P=n?.disableTimeouts===true||$,B=(h,J,K)=>{if(P)return 0;let D=h??J;return typeof D!="number"||!Number.isFinite(D)||D<0?K:D},G=B(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,f.actionTimeoutMs),ee=B(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,f.assertionTimeoutMs),ue=B(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,f.navigationTimeoutMs),ye=B(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,f.componentReadyTimeoutMs),Ue=ce(t),te=n?.contractPath;if(!te)throw new Error(`Contract path not found for component: ${c}`);let St=(()=>{if(Be__default.default.isAbsolute(te))return te;if(i){let J=Be__default.default.resolve(i,te);try{return fs.readFileSync(J,"utf-8"),J}catch{}}let h=Be__default.default.resolve(process.cwd(),te);try{return fs.readFileSync(h,"utf-8"),h}catch{return new URL(te,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname}})(),$t=fs.readFileSync(St,"utf-8"),C=JSON.parse($t),Ct=(C.relationships?.length||0)+(C.static.length||0)+C.dynamic.length,kt=C.meta?.source?.apg,H=[],N=[],Y=[],I=[],T=null,E=(h,J)=>{let K=Z(J),D=Je(K,Ue);if(D==="error")return H.push(h),{status:"fail",level:K,detail:h};if(D==="warning")return N.push(h),{status:"warn",level:K,detail:h};let z=`${h} (ignored by strictness=${Ue}, level=${K})`;return I.push(z),{status:"skip",level:K,detail:z}};try{if(T=await qe(),e){try{await T.goto(e,{waitUntil:"domcontentloaded",timeout:ue});}catch(s){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${s instanceof Error?s.message:String(s)}`)}await T.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let h=await ge.detect(c,n,G,ee,i);if(!h)throw new Error(`Unsupported component: ${c}`);let J=h.getMainSelector();if(!J)throw new Error(`CRITICAL: No selector found in contract for ${c}`);try{await T.locator(J).first().waitFor({state:"attached",timeout:ye});}catch(s){throw new Error(`
31
31
  \u274C CRITICAL: Component not found on page!
32
32
  This usually means:
33
33
  - The component didn't render
34
34
  - The URL is incorrect
35
- - The component selector '${_}' in the contract is wrong
36
- - Original error: ${s}`)}o.start(c,Tt,St),c==="menu"&&C.selectors.main&&await T.locator(C.selectors.main).first().waitFor({state:"visible",timeout:ye}).catch(()=>{});let J=c==="menu"&&C.selectors.submenuTrigger?await T.locator(C.selectors.submenuTrigger).count()>0:!1,D=s=>s.type==="aria-reference"&&[s.from,s.to].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||""))||s.type==="contains"&&[s.parent,s.child].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||"")),K=0,F=0,V=0;for(let s of C.relationships||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(m){N.push(`Warning: resetState failed before relationship test: ${m instanceof Error?m.message:String(m)}`);}let g=Z(s.level);if(Array.isArray(s.setup)&&s.setup.length>0){let S=function(p){return v.includes(p)};var Ue=S;let m=new ne(T,C.selectors,G),R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v=["focus","type","click","keypress","hover"],w=p=>({...p,type:S(p.type)?p.type:"click"}),k=s.setup.map(w),x=await ve(k,m,h,T,R,["submenu","submenuTrigger","submenuItems"]);if(x.skip){I.push(x.message||"Setup action skipped"),o.reportStaticTest(R,"skip",x.message,g);continue}if(!x.success){let p=`Relationship setup failed: ${x.error}`,u=M(p,s.level);u.status==="fail"&&(F+=1),u.status==="warn"&&(V+=1),o.reportStaticTest(R,u.status,u.detail,u.level);continue}}if(c==="menu"&&!J&&D(s)){let R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";I.push(v),o.reportStaticTest(R,"skip",v,g);continue}if(s.type==="aria-reference"){let m=`${s.from}.${s.attribute} references ${s.to}`,R=C.selectors[s.from],v=C.selectors[s.to];if(!R||!v){let d=M(`Relationship selector missing: from="${s.from}" or to="${s.to}" not found in selectors.`,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let S=T.locator(R).first(),w=T.locator(v).first(),k=await S.count()>0,x=await w.count()>0;if(!k||!x){if(c==="menu"&&D(s)){let U="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";I.push(U),o.reportStaticTest(m,"skip",U,g);continue}let d=M(`Relationship target not found: ${k?s.to:s.from}.`,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let p=await S.getAttribute(s.attribute),u=await w.getAttribute("id");if(!u){let d=M(`Relationship target "${s.to}" must have an id for ${s.attribute} validation.`,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}if(!(p||"").split(/\s+/).filter(Boolean).includes(u)){let d=M(`Expected ${s.from} ${s.attribute} to reference id "${u}", found "${p||""}".`,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}Y.push(`Relationship valid: ${s.from}.${s.attribute} -> ${s.to} (id=${u}).`),K+=1,o.reportStaticTest(m,"pass",void 0,g);continue}if(s.type==="contains"){let m=`${s.parent} contains ${s.child}`,R=C.selectors[s.parent],v=C.selectors[s.child];if(!R||!v){let p=M(`Relationship selector missing: parent="${s.parent}" or child="${s.child}" not found in selectors.`,s.level);p.status==="fail"&&(F+=1),p.status==="warn"&&(V+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}let S=T.locator(R).first();if(!(await S.count()>0)){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";I.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Relationship parent target not found: ${s.parent}.`,s.level);p.status==="fail"&&(F+=1),p.status==="warn"&&(V+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}if(await S.locator(v).count()<1){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";I.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Expected ${s.parent} to contain descendant matching selector for ${s.child}.`,s.level);p.status==="fail"&&(F+=1),p.status==="warn"&&(V+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}Y.push(`Relationship valid: ${s.parent} contains ${s.child}.`),K+=1,o.reportStaticTest(m,"pass",void 0,g);}}async function je(s,g,m,R={}){if(!s||typeof s!="object"||!("ref"in s))return s;let v;if(s.ref==="relative"){if(!s.relativeTarget||!R.relativeBaseSelector)return;let S=m.locator(R.relativeBaseSelector),w=await S.count(),k=0;if(s.relativeTarget==="first"?k=0:s.relativeTarget==="second"?k=1:s.relativeTarget==="last"?k=w-1:isNaN(Number(s.relativeTarget))?k=0:k=Number(s.relativeTarget),k<0||k>=w)return;let x=S.nth(k);return await He(x,s.property||s.attribute)}else {if(v=g[s.ref],!v)throw new Error(`Selector for ref '${s.ref}' not found in contract selectors.`);let S=m.locator(v).first();return await He(S,s.property||s.attribute)}}async function He(s,g){if(s)return !g||g==="id"?await s.getAttribute("id")??void 0:g==="class"?await s.getAttribute("class")??void 0:g==="textContent"?await s.evaluate(m=>m.textContent??void 0):g.startsWith("aria-")?await s.getAttribute(g)??void 0:g.endsWith("*")?await s.evaluate(R=>{let v=[];for(let S of Array.from(R.attributes))S.name.startsWith("aria-")&&v.push(`${S.name}=${S.value}`);return v.join(";")}):await s.getAttribute(g)??void 0}let $t=new le(T,C.selectors,ee);async function ve(s,g,m,R,v,S=[]){if(!Array.isArray(s)||s.length===0)return {success:!0};m&&typeof m.resetState=="function"&&await m.resetState(R);for(let w of s){let k={success:!0};try{if(w.type==="focus")w.target==="relative"&&w.relativeTarget?k=await g.focus("relative",w.relativeTarget):k=await g.focus(w.target);else if(w.type==="type"&&w.value)k=await g.type(w.target,w.value);else if(w.type==="click")k=await g.click(w.target,w.relativeTarget);else if(w.type==="keypress"&&w.key)k=await g.keypress(w.target,w.key,w.relativeTarget);else if(w.type==="hover")k=await g.hover(w.target,w.relativeTarget);else continue}catch(x){k={success:!1,error:x instanceof Error?x.message:String(x)};}if(!k.success){let x=k.error||"Setup action failed";return S.some(u=>v.includes(u)||x.includes(u))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${x}`}:{success:!1,error:x}}}return {success:!0}}for(let s of C.static||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(p){N.push(`Warning: resetState failed before static test: ${p instanceof Error?p.message:String(p)}`);}if(s.target==="relative")continue;let g=`${s.target}${s.attribute?` (${s.attribute})`:""}`,m=Z(s.level);if(c==="menu"&&s.target==="submenuTrigger"&&!J){let p=`Skipping submenu static assertion for ${s.target}: no submenu capability detected in rendered component.`;I.push(p),o.reportStaticTest(g,"skip",p,m);continue}let R=[];if(s.target||R.push("target"),s.attribute||R.push("attribute"),typeof s.expectedValue>"u"&&R.push("expectedValue"),R.length>0){let p=`${s.target||""}${s.attribute?` (${s.attribute})`:""}`,u=`Static assertion missing required field(s): ${R.join(", ")}`,b=M(u,s.level);b.status==="fail"&&(F+=1),b.status==="warn"&&(V+=1),o.reportStaticTest(p,b.status,b.detail,b.level);continue}if(Array.isArray(s.setup)&&s.setup.length>0){let b=function(l){return u.includes(l)};var Ue=b;let p=new ne(T,C.selectors,G),u=["focus","type","click","keypress","hover"],W=l=>({...l,type:b(l.type)?l.type:"click"}),d=s.setup.map(W),U=await ve(d,p,h,T,g,["submenu","submenuTrigger","submenuItems"]);if(U.skip){I.push(U.message||"Setup action skipped"),o.reportStaticTest(g,"skip",U.message,m);continue}if(!U.success){let l=`Static setup failed: ${U.error}`,A=M(l,s.level);A.status==="fail"&&(F+=1),A.status==="warn"&&(V+=1),o.reportStaticTest(g,A.status,A.detail,A.level);continue}}let v=C.selectors[s.target];if(!v){let p=`Selector for target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(F+=1),u.status==="warn"&&(V+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let S=T.locator(v).first();if(!(await S.count()>0)){let p=`Target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(F+=1),u.status==="warn"&&(V+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let k=(p,u,b)=>{let W=new RegExp(`\\[${u}(?:=["']?([^\\]"']+)["']?)?\\]`),d=p.match(W);if(!d)return !1;if(!b)return !0;let U=d[1];return U?b.split(" | ").includes(U):!1},x=s.expectedValue;if(s.expectedValue&&typeof s.expectedValue=="object"&&"ref"in s.expectedValue){let p={},u=s.relativeTarget;if(s.expectedValue.ref==="relative"&&s.target==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}else if(s.expectedValue.ref==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}x=await je(s.expectedValue,C.selectors,T,p);}if(s.expectedValue)if(k(v,s.attribute,typeof x=="string"?x:void 0))Y.push(`${s.attribute}="${x}" on ${s.target} verified by selector (already present in: ${v}).`),K+=1,o.reportStaticTest(g,"pass",void 0,m);else {let p=x??"",u=await $t.validateAttribute(S,s.target,s.attribute,p,s.failureMessage,"Static ARIA Test");if(u.success&&u.passMessage)Y.push(u.passMessage),K+=1,o.reportStaticTest(g,"pass",void 0,m);else if(!u.success&&u.failMessage){let b=M(u.failMessage,s.level);b.status==="fail"&&(F+=1),b.status==="warn"&&(V+=1),o.reportStaticTest(g,b.status,b.detail,b.level);}}else {let p=s.attribute.split(" | "),u=!1,b=!0;for(let W of p){let d=W.trim();if(k(v,d)){Y.push(`${d} on ${s.target} verified by selector (already present in: ${v}).`),u=!0;continue}if(b=!1,await S.getAttribute(d)!==null){u=!0;break}}if(!u&&!b){let W=s.failureMessage+` None of the attributes "${s.attribute}" are present.`,d=M(W,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(g,d.status,d.detail,d.level);}else !b&&u?(Y.push(`At least one of the attributes "${s.attribute}" exists on the element.`),K+=1,o.reportStaticTest(g,"pass",void 0,m)):(K+=1,o.reportStaticTest(g,"pass",void 0,m));}}for(let s of C.dynamic||[]){if(!s.assertions||s.assertions.length===0){let l="Skipping test - no assertions found for this dynamic test.";I.push(l),o.reportTest({description:s.description,level:Z(s.level)},"skip",l);continue}if(!T||T.isClosed()){console.warn(`
35
+ - The component selector '${J}' in the contract is wrong
36
+ - Original error: ${s}`)}o.start(c,Ct,kt),c==="menu"&&C.selectors.main&&await T.locator(C.selectors.main).first().waitFor({state:"visible",timeout:ye}).catch(()=>{});let K=c==="menu"&&C.selectors.submenuTrigger?await T.locator(C.selectors.submenuTrigger).count()>0:!1,D=s=>s.type==="aria-reference"&&[s.from,s.to].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||""))||s.type==="contains"&&[s.parent,s.child].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||"")),z=0,F=0,V=0;for(let s of C.relationships||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(m){N.push(`Warning: resetState failed before relationship test: ${m instanceof Error?m.message:String(m)}`);}let g=Z(s.level);if(Array.isArray(s.setup)&&s.setup.length>0){let S=function(p){return v.includes(p)};var je=S;let m=new ne(T,C.selectors,G),R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v=["focus","type","click","keypress","hover"],w=p=>({...p,type:S(p.type)?p.type:"click"}),k=s.setup.map(w),M=await ve(k,m,h,T,R,["submenu","submenuTrigger","submenuItems"]);if(M.skip){I.push(M.message||"Setup action skipped"),o.reportStaticTest(R,"skip",M.message,g);continue}if(!M.success){let p=`Relationship setup failed: ${M.error}`,u=E(p,s.level);u.status==="fail"&&(F+=1),u.status==="warn"&&(V+=1),o.reportStaticTest(R,u.status,u.detail,u.level);continue}}if(c==="menu"&&!K&&D(s)){let R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";I.push(v),o.reportStaticTest(R,"skip",v,g);continue}if(s.type==="aria-reference"){let m=`${s.from}.${s.attribute} references ${s.to}`,R=C.selectors[s.from],v=C.selectors[s.to];if(!R||!v){let d=E(`Relationship selector missing: from="${s.from}" or to="${s.to}" not found in selectors.`,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let S=T.locator(R).first(),w=T.locator(v).first(),k=await S.count()>0,M=await w.count()>0;if(!k||!M){if(c==="menu"&&D(s)){let U="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";I.push(U),o.reportStaticTest(m,"skip",U,g);continue}let d=E(`Relationship target not found: ${k?s.to:s.from}.`,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let p=await S.getAttribute(s.attribute),u=await w.getAttribute("id");if(!u){let d=E(`Relationship target "${s.to}" must have an id for ${s.attribute} validation.`,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}if(!(p||"").split(/\s+/).filter(Boolean).includes(u)){let d=E(`Expected ${s.from} ${s.attribute} to reference id "${u}", found "${p||""}".`,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}Y.push(`Relationship valid: ${s.from}.${s.attribute} -> ${s.to} (id=${u}).`),z+=1,o.reportStaticTest(m,"pass",void 0,g);continue}if(s.type==="contains"){let m=`${s.parent} contains ${s.child}`,R=C.selectors[s.parent],v=C.selectors[s.child];if(!R||!v){let p=E(`Relationship selector missing: parent="${s.parent}" or child="${s.child}" not found in selectors.`,s.level);p.status==="fail"&&(F+=1),p.status==="warn"&&(V+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}let S=T.locator(R).first();if(!(await S.count()>0)){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";I.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=E(`Relationship parent target not found: ${s.parent}.`,s.level);p.status==="fail"&&(F+=1),p.status==="warn"&&(V+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}if(await S.locator(v).count()<1){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";I.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=E(`Expected ${s.parent} to contain descendant matching selector for ${s.child}.`,s.level);p.status==="fail"&&(F+=1),p.status==="warn"&&(V+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}Y.push(`Relationship valid: ${s.parent} contains ${s.child}.`),z+=1,o.reportStaticTest(m,"pass",void 0,g);}}async function He(s,g,m,R={}){if(!s||typeof s!="object"||!("ref"in s))return s;let v;if(s.ref==="relative"){if(!s.relativeTarget||!R.relativeBaseSelector)return;let S=m.locator(R.relativeBaseSelector),w=await S.count(),k=0;if(s.relativeTarget==="first"?k=0:s.relativeTarget==="second"?k=1:s.relativeTarget==="last"?k=w-1:isNaN(Number(s.relativeTarget))?k=0:k=Number(s.relativeTarget),k<0||k>=w)return;let M=S.nth(k);return await De(M,s.property||s.attribute)}else {if(v=g[s.ref],!v)throw new Error(`Selector for ref '${s.ref}' not found in contract selectors.`);let S=m.locator(v).first();return await De(S,s.property||s.attribute)}}async function De(s,g){if(s)return !g||g==="id"?await s.getAttribute("id")??void 0:g==="class"?await s.getAttribute("class")??void 0:g==="textContent"?await s.evaluate(m=>m.textContent??void 0):g.startsWith("aria-")?await s.getAttribute(g)??void 0:g.endsWith("*")?await s.evaluate(R=>{let v=[];for(let S of Array.from(R.attributes))S.name.startsWith("aria-")&&v.push(`${S.name}=${S.value}`);return v.join(";")}):await s.getAttribute(g)??void 0}let At=new le(T,C.selectors,ee);async function ve(s,g,m,R,v,S=[]){if(!Array.isArray(s)||s.length===0)return {success:!0};m&&typeof m.resetState=="function"&&await m.resetState(R);for(let w of s){let k={success:!0};try{if(w.type==="focus")w.target==="relative"&&w.relativeTarget?k=await g.focus("relative",w.relativeTarget):k=await g.focus(w.target);else if(w.type==="type"&&w.value)k=await g.type(w.target,w.value);else if(w.type==="click")k=await g.click(w.target,w.relativeTarget);else if(w.type==="keypress"&&w.key)k=await g.keypress(w.target,w.key,w.relativeTarget);else if(w.type==="hover")k=await g.hover(w.target,w.relativeTarget);else continue}catch(M){k={success:!1,error:M instanceof Error?M.message:String(M)};}if(!k.success){let M=k.error||"Setup action failed";return S.some(u=>v.includes(u)||M.includes(u))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${M}`}:{success:!1,error:M}}}return {success:!0}}for(let s of C.static||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(p){N.push(`Warning: resetState failed before static test: ${p instanceof Error?p.message:String(p)}`);}if(s.target==="relative")continue;let g=`${s.target}${s.attribute?` (${s.attribute})`:""}`,m=Z(s.level);if(c==="menu"&&s.target==="submenuTrigger"&&!K){let p=`Skipping submenu static assertion for ${s.target}: no submenu capability detected in rendered component.`;I.push(p),o.reportStaticTest(g,"skip",p,m);continue}let R=[];if(s.target||R.push("target"),s.attribute||R.push("attribute"),typeof s.expectedValue>"u"&&R.push("expectedValue"),R.length>0){let p=`${s.target||""}${s.attribute?` (${s.attribute})`:""}`,u=`Static assertion missing required field(s): ${R.join(", ")}`,b=E(u,s.level);b.status==="fail"&&(F+=1),b.status==="warn"&&(V+=1),o.reportStaticTest(p,b.status,b.detail,b.level);continue}if(Array.isArray(s.setup)&&s.setup.length>0){let b=function(l){return u.includes(l)};var je=b;let p=new ne(T,C.selectors,G),u=["focus","type","click","keypress","hover"],W=l=>({...l,type:b(l.type)?l.type:"click"}),d=s.setup.map(W),U=await ve(d,p,h,T,g,["submenu","submenuTrigger","submenuItems"]);if(U.skip){I.push(U.message||"Setup action skipped"),o.reportStaticTest(g,"skip",U.message,m);continue}if(!U.success){let l=`Static setup failed: ${U.error}`,A=E(l,s.level);A.status==="fail"&&(F+=1),A.status==="warn"&&(V+=1),o.reportStaticTest(g,A.status,A.detail,A.level);continue}}let v=C.selectors[s.target];if(!v){let p=`Selector for target ${s.target} not found.`,u=E(p,s.level);u.status==="fail"&&(F+=1),u.status==="warn"&&(V+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let S=T.locator(v).first();if(!(await S.count()>0)){let p=`Target ${s.target} not found.`,u=E(p,s.level);u.status==="fail"&&(F+=1),u.status==="warn"&&(V+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let k=(p,u,b)=>{let W=new RegExp(`\\[${u}(?:=["']?([^\\]"']+)["']?)?\\]`),d=p.match(W);if(!d)return !1;if(!b)return !0;let U=d[1];return U?b.split(" | ").includes(U):!1},M=s.expectedValue;if(s.expectedValue&&typeof s.expectedValue=="object"&&"ref"in s.expectedValue){let p={},u=s.relativeTarget;if(s.expectedValue.ref==="relative"&&s.target==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}else if(s.expectedValue.ref==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}M=await He(s.expectedValue,C.selectors,T,p);}if(s.expectedValue)if(k(v,s.attribute,typeof M=="string"?M:void 0))Y.push(`${s.attribute}="${M}" on ${s.target} verified by selector (already present in: ${v}).`),z+=1,o.reportStaticTest(g,"pass",void 0,m);else {let p=M??"",u=await At.validateAttribute(S,s.target,s.attribute,p,s.failureMessage,"Static ARIA Test");if(u.success&&u.passMessage)Y.push(u.passMessage),z+=1,o.reportStaticTest(g,"pass",void 0,m);else if(!u.success&&u.failMessage){let b=E(u.failMessage,s.level);b.status==="fail"&&(F+=1),b.status==="warn"&&(V+=1),o.reportStaticTest(g,b.status,b.detail,b.level);}}else {let p=s.attribute.split(" | "),u=!1,b=!0;for(let W of p){let d=W.trim();if(k(v,d)){Y.push(`${d} on ${s.target} verified by selector (already present in: ${v}).`),u=!0;continue}if(b=!1,await S.getAttribute(d)!==null){u=!0;break}}if(!u&&!b){let W=s.failureMessage+` None of the attributes "${s.attribute}" are present.`,d=E(W,s.level);d.status==="fail"&&(F+=1),d.status==="warn"&&(V+=1),o.reportStaticTest(g,d.status,d.detail,d.level);}else !b&&u?(Y.push(`At least one of the attributes "${s.attribute}" exists on the element.`),z+=1,o.reportStaticTest(g,"pass",void 0,m)):(z+=1,o.reportStaticTest(g,"pass",void 0,m));}}for(let s of C.dynamic||[]){if(!s.assertions||s.assertions.length===0){let l="Skipping test - no assertions found for this dynamic test.";I.push(l),o.reportTest({description:s.description,level:Z(s.level)},"skip",l);continue}if(!T||T.isClosed()){console.warn(`
37
37
  \u26A0\uFE0F Browser closed - skipping remaining ${C.dynamic.length-C.dynamic.indexOf(s)} tests
38
- `),H.push(`CRITICAL: Browser/page closed before completing all tests. ${C.dynamic.length-C.dynamic.indexOf(s)} tests skipped.`);break}try{await h.resetState(T);}catch(l){let A=l instanceof Error?l.message:String(l);throw o.error(A),l}let{setup:g=[],action:m,assertions:R}=s,v=Z(s.level),S=new ne(T,C.selectors,G);if(Array.isArray(g)&&g.length>0){let A=function(j){return l.includes(j)};var Ue=A;let l=["focus","type","click","keypress","hover"],se=j=>({...j,type:A(j.type)?j.type:"click"}),we=g.map(se),q=await ve(we,S,h,T,s.description,["submenu","submenuTrigger","submenuItems"]);if(q.skip){I.push(q.message||"Setup action skipped"),o.reportTest({description:s.description,level:v},"skip",q.message);continue}if(!q.success){let j=M(`Setup failed: ${q.error}`,s.level);o.reportTest({description:s.description,level:v},j.status,j.detail);continue}}let w=H.length,k=N.length,x=I.length;if(await h.shouldSkipTest(s,T)){let l="Skipping test - component-specific conditions not met";I.push(l),o.reportTest({description:s.description,level:v},"skip",l);continue}let u=new le(T,C.selectors,ee),b=!1,W=null;for(let l of m){if(!T||T.isClosed()){H.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),b=!0;break}let A;if(l.type==="focus")l.target==="relative"&&l.relativeTarget?A=await S.focus("relative",l.relativeTarget):A=await S.focus(l.target);else if(l.type==="type"&&l.value)A=await S.type(l.target,l.value);else if(l.type==="click")A=await S.click(l.target,l.relativeTarget);else if(l.type==="keypress"&&l.key)A=await S.keypress(l.target,l.key,l.relativeTarget);else if(l.type==="hover")A=await S.hover(l.target,l.relativeTarget);else continue;if(!A.success){if(A.error){let se=M(A.error,s.level);W={status:se.status,detail:se.detail};}b=!0;break}}if(b){o.reportTest({description:s.description,level:v},W?.status||"fail",W?.detail||H[H.length-1]);continue}for(let l of R){let A;if(l.expectedValue&&typeof l.expectedValue=="object"&&"ref"in l.expectedValue)if(l.expectedValue.ref==="relative"){let{RelativeTargetResolver:Q}=await Promise.resolve().then(()=>(me(),pt)),j=C.selectors.relative;if(!j)throw new Error("Relative selector not defined in contract selectors.");let ae=l.relativeTarget||"first",X=await Q.resolve(T,j,ae);if(!X)throw new Error(`Could not resolve relative target '${ae}' for expectedValue.`);let We=l.expectedValue.property||l.expectedValue.attribute||"id";if(We==="textContent")A=await X.evaluate(pe=>pe.textContent??void 0);else {let pe=await X.getAttribute(We);A=pe===null?void 0:pe;}}else A=await je(l.expectedValue,C.selectors,T,{});else typeof l.expectedValue=="string"||typeof l.expectedValue>"u"?A=l.expectedValue:A="";let se={...l,expectedValue:A},we=A??"",q=await u.validate({...se,expectedValue:we},s.description);if(q.success&&q.passMessage)Y.push(q.passMessage);else if(!q.success&&q.failMessage){let Q=[];if(l.target||Q.push("target"),l.assertion||Q.push("assertion"),["toHaveAttribute","toHaveValue","toHaveRole"].includes(l.assertion)&&(typeof l.attribute>"u"&&l.assertion==="toHaveAttribute"&&Q.push("attribute"),typeof l.expectedValue>"u"&&Q.push("expectedValue")),Q.length>0){let j=Z(l.level||s.level),ae=`Dynamic assertion missing required field(s): ${Q.join(", ")}`,X=M(ae,j);if(X.status==="skip")continue;H.push(ae),o.reportTest({description:s.description,level:j},X.status,X.detail);continue}}}let d=H.length,U=N.length,De=I.length;d>w?o.reportTest({description:s.description,level:v},"fail",H[H.length-1]):U>k?o.reportTest({description:s.description,level:v},"warn",N[N.length-1]):De>x?o.reportTest({description:s.description,level:v},"skip",I[I.length-1]):o.reportTest({description:s.description,level:v},"pass");}o.reportStatic(K,F,V),o.summary(H);}catch(h){if(h instanceof Error)throw h.message.includes("Executable doesn't exist")||h.message.includes("browserType.launch")?new Error(`
38
+ `),H.push(`CRITICAL: Browser/page closed before completing all tests. ${C.dynamic.length-C.dynamic.indexOf(s)} tests skipped.`);break}try{await h.resetState(T);}catch(l){let A=l instanceof Error?l.message:String(l);throw o.error(A),l}let{setup:g=[],action:m,assertions:R}=s,v=Z(s.level),S=new ne(T,C.selectors,G);if(Array.isArray(g)&&g.length>0){let A=function(j){return l.includes(j)};var je=A;let l=["focus","type","click","keypress","hover"],se=j=>({...j,type:A(j.type)?j.type:"click"}),we=g.map(se),q=await ve(we,S,h,T,s.description,["submenu","submenuTrigger","submenuItems"]);if(q.skip){I.push(q.message||"Setup action skipped"),o.reportTest({description:s.description,level:v},"skip",q.message);continue}if(!q.success){let j=E(`Setup failed: ${q.error}`,s.level);o.reportTest({description:s.description,level:v},j.status,j.detail);continue}}let w=H.length,k=N.length,M=I.length;if(await h.shouldSkipTest(s,T)){let l="Skipping test - component-specific conditions not met";I.push(l),o.reportTest({description:s.description,level:v},"skip",l);continue}let u=new le(T,C.selectors,ee),b=!1,W=null;for(let l of m){if(!T||T.isClosed()){H.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),b=!0;break}let A;if(l.type==="focus")l.target==="relative"&&l.relativeTarget?A=await S.focus("relative",l.relativeTarget):A=await S.focus(l.target);else if(l.type==="type"&&l.value)A=await S.type(l.target,l.value);else if(l.type==="click")A=await S.click(l.target,l.relativeTarget);else if(l.type==="keypress"&&l.key)A=await S.keypress(l.target,l.key,l.relativeTarget);else if(l.type==="hover")A=await S.hover(l.target,l.relativeTarget);else continue;if(!A.success){if(A.error){let se=E(A.error,s.level);W={status:se.status,detail:se.detail};}b=!0;break}}if(b){o.reportTest({description:s.description,level:v},W?.status||"fail",W?.detail||H[H.length-1]);continue}for(let l of R){let A;if(l.expectedValue&&typeof l.expectedValue=="object"&&"ref"in l.expectedValue)if(l.expectedValue.ref==="relative"){let{RelativeTargetResolver:Q}=await Promise.resolve().then(()=>(me(),dt)),j=C.selectors.relative;if(!j)throw new Error("Relative selector not defined in contract selectors.");let ae=l.relativeTarget||"first",X=await Q.resolve(T,j,ae);if(!X)throw new Error(`Could not resolve relative target '${ae}' for expectedValue.`);let Oe=l.expectedValue.property||l.expectedValue.attribute||"id";if(Oe==="textContent")A=await X.evaluate(pe=>pe.textContent??void 0);else {let pe=await X.getAttribute(Oe);A=pe===null?void 0:pe;}}else A=await He(l.expectedValue,C.selectors,T,{});else typeof l.expectedValue=="string"||typeof l.expectedValue>"u"?A=l.expectedValue:A="";let se={...l,expectedValue:A},we=A??"",q=await u.validate({...se,expectedValue:we},s.description);if(q.success&&q.passMessage)Y.push(q.passMessage);else if(!q.success&&q.failMessage){let Q=[];if(l.target||Q.push("target"),l.assertion||Q.push("assertion"),["toHaveAttribute","toHaveValue","toHaveRole"].includes(l.assertion)&&(typeof l.attribute>"u"&&l.assertion==="toHaveAttribute"&&Q.push("attribute"),typeof l.expectedValue>"u"&&Q.push("expectedValue")),Q.length>0){let j=Z(l.level||s.level),ae=`Dynamic assertion missing required field(s): ${Q.join(", ")}`,X=E(ae,j);if(X.status==="skip")continue;H.push(ae),o.reportTest({description:s.description,level:j},X.status,X.detail);continue}}}let d=H.length,U=N.length,We=I.length;d>w?o.reportTest({description:s.description,level:v},"fail",H[H.length-1]):U>k?o.reportTest({description:s.description,level:v},"warn",N[N.length-1]):We>M?o.reportTest({description:s.description,level:v},"skip",I[I.length-1]):o.reportTest({description:s.description,level:v},"pass");}o.reportStatic(z,F,V),o.summary(H);}catch(h){if(h instanceof Error)throw h.message.includes("Executable doesn't exist")||h.message.includes("browserType.launch")?new Error(`
39
39
  \u274C CRITICAL: Playwright browsers not found!
40
40
  \u{1F4E6} Run: npx playwright install chromium`):h.message.includes("net::ERR_CONNECTION_REFUSED")||h.message.includes("NS_ERROR_CONNECTION_REFUSED")?new Error(`
41
41
  \u274C CRITICAL: Cannot connect to dev server!
@@ -51,17 +51,17 @@ This usually means:
51
51
  This usually means:
52
52
  - The test timeout was too short
53
53
  - The browser crashed
54
- - An external process killed the browser`):h}finally{T&&await T.close();}return {passes:Y,failures:H,skipped:I,warnings:N}}var mt=E(()=>{be();lt();ut();ft();gt();Te();});var ht={};z(ht,{BADGE_CONFIGS:()=>Fe,displayAllBadges:()=>Ot,displayBadgeInfo:()=>Ht,getBadgeMarkdown:()=>oe,promptAddBadge:()=>Dt});function oe(c){let e=Fe[c];return `[![${e.label}](${e.markdownUrl})](https://github.com/aria-ease/aria-ease)`}function Ht(c){let e=oe(c);console.log(L__default.default.cyan(`
54
+ - An external process killed the browser`):h}finally{T&&await T.close();}return {passes:Y,failures:H,skipped:I,warnings:N}}var vt=x(()=>{be();ft();gt();mt();ht();Te();});var wt={};_(wt,{BADGE_CONFIGS:()=>Ve,displayAllBadges:()=>Kt,displayBadgeInfo:()=>qt,getBadgeMarkdown:()=>oe,promptAddBadge:()=>_t});function oe(c){let e=Ve[c];return `[![${e.label}](${e.markdownUrl})](https://github.com/aria-ease/aria-ease)`}function qt(c){let e=oe(c);console.log(L__default.default.cyan(`
55
55
  \u{1F3C5} Show your accessibility commitment!`)),console.log(L__default.default.white(` Add this badge to your README.md:
56
56
  `)),console.log(L__default.default.green(" "+e)),console.log(L__default.default.dim(`
57
57
  This helps others discover accessibility tools and shows you care!
58
- `));}async function Dt(c,e=process.cwd()){let t=Pe__default.default.join(e,"README.md");if(!await Le__default.default.pathExists(t)){console.log(L__default.default.yellow(" \u2139\uFE0F No README.md found in current directory"));return}let i=await Le__default.default.readFile(t,"utf-8"),n=oe(c);if(i.includes(n)||i.includes(Fe[c].fileName)){console.log(L__default.default.gray(" \u2713 Badge already in README.md"));return}let a=jt__default.default.createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(f=>{a.question(L__default.default.cyan(" Add badge to README.md now? (y/n): "),$=>{a.close(),f($.toLowerCase().trim());});});o==="y"||o==="yes"?(await Wt(t,i,n),console.log(L__default.default.green(" \u2713 Badge added to README.md!"))):console.log(L__default.default.gray(" Skipped. You can add it manually anytime."));}async function Wt(c,e,t){let r=e.split(`
59
- `),i=0;for(let n=0;n<r.length;n++){let a=r[n].trim();if(a.startsWith("[![")||a.startsWith("[!")){i=n+1;continue}if(i>0&&!a.startsWith("[![")&&!a.startsWith("[!")&&a.length>0)break;if(i===0&&a.startsWith("#")){i=n+2;break}}i===0&&(i=1),r.splice(i,0,t),await Le__default.default.writeFile(c,r.join(`
60
- `),"utf-8");}function Ot(){console.log(L__default.default.cyan(`
58
+ `));}async function _t(c,e=process.cwd()){let t=Be__default.default.join(e,"README.md");if(!await Fe__default.default.pathExists(t)){console.log(L__default.default.yellow(" \u2139\uFE0F No README.md found in current directory"));return}let i=await Fe__default.default.readFile(t,"utf-8"),n=oe(c);if(i.includes(n)||i.includes(Ve[c].fileName)){console.log(L__default.default.gray(" \u2713 Badge already in README.md"));return}let a=Ot__default.default.createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(f=>{a.question(L__default.default.cyan(" Add badge to README.md now? (y/n): "),$=>{a.close(),f($.toLowerCase().trim());});});o==="y"||o==="yes"?(await Jt(t,i,n),console.log(L__default.default.green(" \u2713 Badge added to README.md!"))):console.log(L__default.default.gray(" Skipped. You can add it manually anytime."));}async function Jt(c,e,t){let r=e.split(`
59
+ `),i=0;for(let n=0;n<r.length;n++){let a=r[n].trim();if(a.startsWith("[![")||a.startsWith("[!")){i=n+1;continue}if(i>0&&!a.startsWith("[![")&&!a.startsWith("[!")&&a.length>0)break;if(i===0&&a.startsWith("#")){i=n+2;break}}i===0&&(i=1),r.splice(i,0,t),await Fe__default.default.writeFile(c,r.join(`
60
+ `),"utf-8");}function Kt(){console.log(L__default.default.cyan(`
61
61
  \u{1F4CD} Available badges:`)),console.log(L__default.default.white(`
62
62
  For audits:`)),console.log(L__default.default.green(" "+oe("audit"))),console.log(L__default.default.white(`
63
63
  For component testing:`)),console.log(L__default.default.green(" "+oe("component"))),console.log(L__default.default.white(`
64
- For both (verified):`)),console.log(L__default.default.green(" "+oe("verified"))),console.log("");}var Fe,yt=E(()=>{Fe={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"}};});be();Te();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 i(y){try{let P=await fetch(y,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(P.ok||P.status===304)return y}catch{return null}return null}let n=ce(t.strictness),a={},o=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:y}=await Promise.resolve().then(()=>(Ge(),ze)),P=await y(process.cwd());if(a=P.config,P.configPath&&(o=Pe__default.default.dirname(P.configPath)),t.strictness===void 0){let B=a.test?.components?.find(G=>G?.name===c)?.strictness;n=ce(B??a.test?.strictness);}}catch{t.strictness===void 0&&(n="balanced");}let f;try{if(e){let y=await i(e);if(y){console.log(`\u{1F3AD} Running Playwright tests on ${y}`);let{runContractTestsPlaywright:P}=await Promise.resolve().then(()=>(mt(),dt));f=await P(c,y,n,a,o);}else throw new Error(`\u274C Dev server not running at ${e}
64
+ For both (verified):`)),console.log(L__default.default.green(" "+oe("verified"))),console.log("");}var Ve,bt=x(()=>{Ve={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"}};});be();Te();async function Gt(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 i(y){try{let P=await fetch(y,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(P.ok||P.status===304)return y}catch{return null}return null}let n=ce(t.strictness),a={},o=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:y}=await Promise.resolve().then(()=>(Ne(),Ge)),P=await y(process.cwd());if(a=P.config,P.configPath&&(o=Be__default.default.dirname(P.configPath)),t.strictness===void 0){let B=a.test?.components?.find(G=>G?.name===c)?.strictness;n=ce(B??a.test?.strictness);}}catch{t.strictness===void 0&&(n="balanced");}let f;try{if(e){let y=await i(e);if(y){console.log(`\u{1F3AD} Running Playwright tests on ${y}`);let{runContractTestsPlaywright:P}=await Promise.resolve().then(()=>(vt(),yt));f=await P(c,y,n,a,o);}else throw new Error(`\u274C Dev server not running at ${e}
65
65
  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(y){throw y instanceof Error?y:new Error(`\u274C Contract test execution failed: ${String(y)}`)}let $={violations:r.violations,raw:r,contract:f};if(f.failures.length>0&&e==="Playwright")throw new Error(`
66
66
  \u274C ${f.failures.length} accessibility contract test${f.failures.length>1?"s":""} failed (Playwright mode)
67
67
  \u2705 ${f.passes.length} test${f.passes.length>1?"s":""} passed
@@ -77,6 +77,6 @@ Please start your dev server and try again.`)}else throw new Error("\u274C URL i
77
77
  ${P}
78
78
 
79
79
  \u{1F4CB} Full details available in result.violations`)}return $}exports.runTest=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(exports.runTest=async()=>{console.log(`\u{1F680} Running component accessibility tests...
80
- `);let{exec:c}=await import('child_process'),e=(await import('chalk')).default;return new Promise((t,r)=>{c("npx vitest --run --reporter verbose",async(i,n,a)=>{if(console.log(n),a&&console.error(a),!i||i.code===0){try{let{displayBadgeInfo:f,promptAddBadge:$}=await Promise.resolve().then(()=>(yt(),ht));f("component"),await $("component",process.cwd()),console.log(e.dim(`
80
+ `);let{exec:c}=await import('child_process'),e=(await import('chalk')).default;return new Promise((t,r)=>{c("npx vitest --run --reporter verbose",async(i,n,a)=>{if(console.log(n),a&&console.error(a),!i||i.code===0){try{let{displayBadgeInfo:f,promptAddBadge:$}=await Promise.resolve().then(()=>(bt(),wt));f("component"),await $("component",process.cwd()),console.log(e.dim(`
81
81
  `+"\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)+`
82
- `));}catch(f){console.error("Warning: Could not display badge prompt:",f);}t({passes:[],failures:[],skipped:[]}),process.exit(0);}else {let f=i?.code||1;r(new Error(`Tests failed with code ${f}`)),process.exit(f);}});})});async function Jt(){await qe();}exports.cleanupTests=Jt;exports.testUiComponent=_t;
82
+ `));}catch(f){console.error("Warning: Could not display badge prompt:",f);}t({passes:[],failures:[],skipped:[]}),process.exit(0);}else {let f=i?.code||1;r(new Error(`Tests failed with code ${f}`)),process.exit(f);}});})});async function Nt(){await _e();}exports.cleanupTests=Nt;exports.testUiComponent=Gt;
@@ -3,6 +3,7 @@ interface JestAxeResult {
3
3
  raw: unknown;
4
4
  contract: unknown;
5
5
  }
6
+
6
7
  interface ContractTestResult {
7
8
  passes: string[];
8
9
  failures: string[];
@@ -3,6 +3,7 @@ interface JestAxeResult {
3
3
  raw: unknown;
4
4
  contract: unknown;
5
5
  }
6
+
6
7
  interface ContractTestResult {
7
8
  passes: string[];
8
9
  failures: string[];
@@ -1,4 +1,4 @@
1
- import {d,b}from'./chunk-APUMBDOT.js';import m from'path';async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=d(c.strictness),o={},d$1=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import('./configLoader-NCYRL2O6.js'),n=await t(process.cwd());if(o=n.config,n.configPath&&(d$1=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=d(r??o.test?.strictness);}}catch{c.strictness===void 0&&(p="balanced");}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import('./contractTestRunnerPlaywright-FSZDW7IR.js');s=await n(a,t,p,o,d$1);}else throw new Error(`\u274C Dev server not running at ${e}
1
+ import {d,b}from'./chunk-APUMBDOT.js';import m from'path';async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=d(c.strictness),o={},d$1=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import('./configLoader-NCYRL2O6.js'),n=await t(process.cwd());if(o=n.config,n.configPath&&(d$1=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=d(r??o.test?.strictness);}}catch{c.strictness===void 0&&(p="balanced");}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import('./contractTestRunnerPlaywright-ZKVK7KUM.js');s=await n(a,t,p,o,d$1);}else throw new Error(`\u274C Dev server not running at ${e}
2
2
  Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(t){throw t instanceof Error?t:new Error(`\u274C Contract test execution failed: ${String(t)}`)}let u={violations:i.violations,raw:i,contract:s};if(s.failures.length>0&&e==="Playwright")throw new Error(`
3
3
  \u274C ${s.failures.length} accessibility contract test${s.failures.length>1?"s":""} failed (Playwright mode)
4
4
  \u2705 ${s.passes.length} test${s.passes.length>1?"s":""} passed
@@ -1,4 +1,4 @@
1
- import{b as g,d as f}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";import m from"path";async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=f(c.strictness),o={},d=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import("./configLoader-ZXTSCIP6.js"),n=await t(process.cwd());if(o=n.config,n.configPath&&(d=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=f(r??o.test?.strictness)}}catch{c.strictness===void 0&&(p="balanced")}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import("./contractTestRunnerPlaywright-VLOD5IB3.js");s=await n(a,t,p,o,d)}else throw new Error(`\u274C Dev server not running at ${e}
1
+ import{b as g,d as f}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";import m from"path";async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=f(c.strictness),o={},d=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import("./configLoader-ZXTSCIP6.js"),n=await t(process.cwd());if(o=n.config,n.configPath&&(d=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=f(r??o.test?.strictness)}}catch{c.strictness===void 0&&(p="balanced")}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import("./contractTestRunnerPlaywright-CJFYO766.js");s=await n(a,t,p,o,d)}else throw new Error(`\u274C Dev server not running at ${e}
2
2
  Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(t){throw t instanceof Error?t:new Error(`\u274C Contract test execution failed: ${String(t)}`)}let u={violations:i.violations,raw:i,contract:s};if(s.failures.length>0&&e==="Playwright")throw new Error(`
3
3
  \u274C ${s.failures.length} accessibility contract test${s.failures.length>1?"s":""} failed (Playwright mode)
4
4
  \u2705 ${s.passes.length} test${s.passes.length>1?"s":""} passed