aria-ease 7.2.0 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -13
- package/dist/AccordionComponentStrategy-T5YODP3A.js +1 -0
- package/dist/buildContracts-NGEEUCN3.js +13 -0
- package/dist/cli.cjs +4 -4
- package/dist/cli.js +1 -1
- package/dist/{contractTestRunnerPlaywright-RUKMUY5P.js → contractTestRunnerPlaywright-IFI5BPGV.js} +3 -3
- package/dist/{contractTestRunnerPlaywright-2CEH3GPM.js → contractTestRunnerPlaywright-SJIHHZ3Y.js} +3 -3
- package/dist/index.cjs +27 -27
- package/dist/index.d.cts +25 -14
- package/dist/index.d.ts +25 -14
- package/dist/index.js +13 -13
- package/dist/src/{Types.d-DYfYR3Vc.d.cts → Types.d-D96FYkCN.d.cts} +22 -1
- package/dist/src/{Types.d-DYfYR3Vc.d.ts → Types.d-D96FYkCN.d.ts} +22 -1
- package/dist/src/accordion/index.d.cts +1 -1
- package/dist/src/accordion/index.d.ts +1 -1
- package/dist/src/block/index.d.cts +1 -1
- package/dist/src/block/index.d.ts +1 -1
- package/dist/src/checkbox/index.cjs +1 -1
- package/dist/src/checkbox/index.d.cts +2 -6
- package/dist/src/checkbox/index.d.ts +2 -6
- package/dist/src/checkbox/index.js +1 -1
- package/dist/src/combobox/index.d.cts +1 -1
- package/dist/src/combobox/index.d.ts +1 -1
- package/dist/src/menu/index.d.cts +1 -1
- package/dist/src/menu/index.d.ts +1 -1
- package/dist/src/radio/index.cjs +1 -1
- package/dist/src/radio/index.d.cts +3 -7
- package/dist/src/radio/index.d.ts +3 -7
- package/dist/src/radio/index.js +1 -1
- package/dist/src/tabs/index.d.cts +1 -1
- package/dist/src/tabs/index.d.ts +1 -1
- package/dist/src/toggle/index.d.cts +1 -1
- package/dist/src/toggle/index.d.ts +1 -1
- package/dist/src/utils/test/AccordionComponentStrategy-S35ZYITU.js +1 -0
- package/dist/src/utils/test/{contractTestRunnerPlaywright-LUWM3RIL.js → contractTestRunnerPlaywright-Y7N2W6AK.js} +3 -3
- package/dist/src/utils/test/dsl/index.cjs +1 -1
- package/dist/src/utils/test/dsl/index.d.cts +1 -3
- package/dist/src/utils/test/dsl/index.d.ts +1 -3
- package/dist/src/utils/test/dsl/index.js +1 -1
- package/dist/src/utils/test/index.cjs +3 -3
- package/dist/src/utils/test/index.js +1 -1
- package/dist/{test-PCRWMQUO.js → test-2XAMHIKD.js} +1 -1
- package/package.json +1 -1
- package/dist/AccordionComponentStrategy-2SWMNUR6.js +0 -1
- package/dist/buildContracts-T4XQZBDU.js +0 -13
- package/dist/src/utils/test/AccordionComponentStrategy-X2GSQ5KT.js +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
1. Escape key
|
|
3
3
|
2. Clicking trigger
|
|
4
4
|
3. Clicking outside
|
|
5
|
-
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus();}async shouldSkipTest(e,t){if(!(e.action.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")||e.assertions.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")))return false;let i=this.selectors.submenuTrigger;return i?await t.locator(i).count()===0:true}getMainSelector(){return this.mainSelector}};});var Ne={};Q(Ne,{AccordionComponentStrategy:()=>Ce});var Ce,Ye=V(()=>{Ce=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.panel||!this.selectors.trigger
|
|
5
|
+
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus();}async shouldSkipTest(e,t){if(!(e.action.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")||e.assertions.some(a=>a.target==="submenu"||a.target==="submenuTrigger"||a.target==="submenuItems")))return false;let i=this.selectors.submenuTrigger;return i?await t.locator(i).count()===0:true}getMainSelector(){return this.mainSelector}};});var Ne={};Q(Ne,{AccordionComponentStrategy:()=>Ce});var Ce,Ye=V(()=>{Ce=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.panel||!this.selectors.trigger)return;let t=this.selectors.trigger,r=this.selectors.panel;if(!t||!r)return;let i=await e.locator(t).all();for(let n of i){let a=await n.getAttribute("aria-expanded")==="true",o=await n.getAttribute("aria-controls");if(a&&o){await n.click({timeout:this.actionTimeoutMs});let f=e.locator(`#${o}`);await test.expect(f).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{});}}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};});var Qe={};Q(Qe,{ComboboxComponentStrategy:()=>Ae});var Ae,Xe=V(()=>{Ae=class{constructor(e,t,r=400,i=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=r;this.assertionTimeoutMs=i;}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,r=e.locator(t).first();if(!await r.isVisible().catch(()=>false))return;let n=false,a=this.selectors.main;if(a&&(await e.locator(a).first().focus(),await e.keyboard.press("Escape"),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n&&this.selectors.button&&(await e.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),n||(await e.mouse.click(10,10),n=await test.expect(r).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>true).catch(()=>false)),!n)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
|
|
6
6
|
1. Escape key
|
|
7
7
|
2. Clicking button
|
|
8
8
|
3. Clicking outside
|
|
@@ -27,13 +27,13 @@ ${"\u2550".repeat(60)}`),this.log(`\u{1F4CA} Summary
|
|
|
27
27
|
`),o>0?(this.log("\u{1F527} Next Steps:"),this.log(" 1. Review the failures above"),this.log(" 2. Fix ARIA attributes and keyboard handlers"),this.log(` 3. Re-run tests to verify fixes
|
|
28
28
|
`)):!this.isPlaywright&&this.skipped>0&&this.log(`\u2728 Optional: Run Playwright tests for complete validation
|
|
29
29
|
`),{passes:a,failures:o,skipped:this.skipped,duration:t}}error(e,t){this.log(`
|
|
30
|
-
\u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("");}};});var nt={};Q(nt,{RelativeTargetResolver:()=>O});var O,me=V(()=>{O=class{static async resolve(e,t,r){let i=await e.locator(t).all();if(typeof r=="number")return i[r-1];switch(r){case "first":return i[0];case "second":return i[1];case "last":return i[i.length-1];case "next":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])+1)%i.length;return i[a]}case "previous":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])-1+i.length)%i.length;return i[a]}default:return null}}};});var ne,ot=V(()=>{me();ne=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,t,r){try{if(e==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let a=this.page.locator(n).first();return await a.count()?(await a.evaluate((f,S)=>{f.setAttribute("aria-activedescendant",S);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let a=await O.resolve(this.page,n,t);return a?(await a.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let i=this.selectors[e];return i?(await this.page.locator(i).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${e}: ${i instanceof Error?i.message:String(i)}`}}}async type(e,t){try{let r=this.selectors[e];return r?(await this.page.locator(r).first().fill(t,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${e}: ${r instanceof Error?r.message:String(r)}`}}}async click(e,t){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for click action."};let n=await O.resolve(this.page,i,t);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for click.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${e}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(e,t,r){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[t]||t;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),e==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let S=this.selectors.relative;if(!S)return {success:!1,error:"Relative selector not defined for keypress action."};let y=await O.resolve(this.page,S,r);return y?(await y.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let a=this.selectors[e];if(!a)return {success:!1,error:`Selector for keypress target ${e} not found.`};let o=this.page.locator(a).first();return await o.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await o.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${t} on ${e}: ${i instanceof Error?i.message:String(i)}`}}}async hover(e,t){try{if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for hover action."};let n=await O.resolve(this.page,i,t);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for hover.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${e}: ${r instanceof Error?r.message:String(r)}`}}}};});var le,at=V(()=>{me();le=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}async resolveTarget(e,t,r){try{if(e==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!t)return {target:null,error:"Relative target or expected value is not defined."};let a=await O.resolve(this.page,n,t);return a?{target:a}:{target:null,error:`Target ${e} not found.`}}let i=this.selectors[e];return i?{target:this.page.locator(i).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(i){return {target:null,error:`Failed to resolve target ${e}: ${i instanceof Error?i.message:String(i)}`}}}async validateVisibility(e,t,r,i,n){try{return r?(await test.expect(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${n}".`}):(await test.expect(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${n}".`})}catch{let a=this.selectors[t]||"",o=await this.page.evaluate(f=>{let S=f?document.querySelector(f):null;if(!S)return "element not found";let y=window.getComputedStyle(S);return `display:${y.display}, visibility:${y.visibility}, opacity:${y.opacity}`},a);return r?{success:false,failMessage:`${i} (actual: ${o})`}:{success:false,failMessage:`${i} ${t} is still visible (actual: ${o}).`}}}async validateAttribute(e,t,r,i,n,a){if(i==="!empty"){let S=await e.getAttribute(r);return S&&S.trim()!==""?{success:true,passMessage:`${t} has non-empty "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should not be empty, found "${S}".`}}if(typeof i!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",i),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(i)}`);let o=i.split(" | ").map(S=>S.trim()),f=await e.getAttribute(r);return f!==null&&o.includes(f)?{success:true,passMessage:`${t} has expected "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should be "${i}", found "${f}".`}}async validateValue(e,t,r,i,n){let a=await e.inputValue().catch(()=>"");return r==="!empty"?a&&a.trim()!==""?{success:true,passMessage:`${t} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should not be empty, found "${a}".`}:r===""?a===""?{success:true,passMessage:`${t} has empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be empty, found "${a}".`}:a===r?{success:true,passMessage:`${t} has expected value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be "${r}", found "${a}".`}}async validateFocus(e,t,r,i,n){try{return r?(await test.expect(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${n}".`}):(await test.expect(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${n}".`})}catch{let a=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${i} (actual focus: ${a})`}}}async validateRole(e,t,r,i,n){let a=await e.getAttribute("role");return a===r?{success:true,passMessage:`${t} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${i} Expected role "${r}", found "${a}".`}}async validate(e,t){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,i;if(e.controlledBy){let n=e.controlledBy,a=this.selectors[n.target];if(!a)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let o=null;if(n.relativeTarget?o=await O.resolve(this.page,a,n.relativeTarget):o=this.page.locator(a).first(),!o)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let f=n.attribute||"aria-controls",S=await o.getAttribute(f);if(!S)return {success:false,failMessage:`Controlling element does not have attribute '${f}'.`,target:null};if(r=this.page.locator(`#${S}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${S}' not found.`,target:null}}else {let n=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(r=n.target,i=n.error,i||!r)return {success:false,failMessage:i||`Target ${e.target} not found.`,target:null}}if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let n=await O.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),a=n?await n.getAttribute("id"):null,o=await r.getAttribute("aria-activedescendant");return a&&o===a?{success:true,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case "toBeVisible":return this.validateVisibility(r,e.target,true,e.failureMessage||"",t);case "notToBeVisible":return this.validateVisibility(r,e.target,false,e.failureMessage||"",t);case "toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(r,e.target,e.attribute,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return e.expectedValue!==void 0?this.validateValue(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,e.target,true,e.failureMessage||"",t);case "notToHaveFocus":return this.validateFocus(r,e.target,false,e.failureMessage||"",t);case "toHaveRole":return e.expectedValue!==void 0?this.validateRole(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${e.assertion}`}}}};});var ct={};Q(ct,{runContractTestsPlaywright:()=>Et});async function Et(c,e,t,r,i){let n=r?.test?.components?.find(h=>h.name===c),a=!!n?.contractPath,o=new de(true,a),f={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},S=r?.test?.disableTimeouts===true,x=n?.disableTimeouts===true||S,P=(h,_,J)=>{if(x)return 0;let D=h??_;return typeof D!="number"||!Number.isFinite(D)||D<0?J:D},z=P(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,f.actionTimeoutMs),ee=P(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,f.assertionTimeoutMs),ue=P(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,f.navigationTimeoutMs),ye=P(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,f.componentReadyTimeoutMs),Le=ce(t),te=n?.contractPath;if(!te)throw new Error(`Contract path not found for component: ${c}`);let gt=(()=>{if(Me__default.default.isAbsolute(te))return te;if(i){let _=Me__default.default.resolve(i,te);try{return fs.readFileSync(_,"utf-8"),_}catch{}}let h=Me__default.default.resolve(process.cwd(),te);try{return fs.readFileSync(h,"utf-8"),h}catch{return new URL(te,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname}})(),dt=fs.readFileSync(gt,"utf-8"),C=JSON.parse(dt),mt=(C.relationships?.length||0)+(C.static[0]?.assertions.length||0)+C.dynamic.length,ht=C.meta?.source?.apg,H=[],G=[],N=[],B=[],T=null,M=(h,_)=>{let J=Z(_),D=Oe(J,Le);if(D==="error")return H.push(h),{status:"fail",level:J,detail:h};if(D==="warning")return G.push(h),{status:"warn",level:J,detail:h};let K=`${h} (ignored by strictness=${Le}, level=${J})`;return B.push(K),{status:"skip",level:J,detail:K}};try{if(T=await De(),e){try{await T.goto(e,{waitUntil:"domcontentloaded",timeout:ue});}catch(s){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${s instanceof Error?s.message:String(s)}`)}await T.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let h=await ge.detect(c,n,z,ee,i);if(!h)throw new Error(`Unsupported component: ${c}`);let _=h.getMainSelector();if(!_)throw new Error(`CRITICAL: No selector found in contract for ${c}`);try{await T.locator(_).first().waitFor({state:"attached",timeout:ye});}catch(s){throw new Error(`
|
|
30
|
+
\u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("");}};});var nt={};Q(nt,{RelativeTargetResolver:()=>O});var O,me=V(()=>{O=class{static async resolve(e,t,r){let i=await e.locator(t).all();if(typeof r=="number")return i[r-1];switch(r){case "first":return i[0];case "second":return i[1];case "last":return i[i.length-1];case "next":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])+1)%i.length;return i[a]}case "previous":{let a=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])-1+i.length)%i.length;return i[a]}default:return null}}};});var ne,ot=V(()=>{me();ne=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,t,r){try{if(e==="virtual"&&r){let n=this.selectors.main;if(!n)return {success:!1,error:"Main selector not defined for virtual focus."};let a=this.page.locator(n).first();return await a.count()?(await a.evaluate((f,S)=>{f.setAttribute("aria-activedescendant",S);},r),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let n=this.selectors.relative;if(!n)return {success:!1,error:"Relative selector not defined for focus action."};let a=await O.resolve(this.page,n,t);return a?(await a.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let i=this.selectors[e];return i?(await this.page.locator(i).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to focus ${e}: ${i instanceof Error?i.message:String(i)}`}}}async type(e,t){try{let r=this.selectors[e];return r?(await this.page.locator(r).first().fill(t,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to type into ${e}: ${r instanceof Error?r.message:String(r)}`}}}async click(e,t){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for click action."};let n=await O.resolve(this.page,i,t);return n?(await n.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for click.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to click ${e}: ${r instanceof Error?r.message:String(r)}`}}}async keypress(e,t,r){try{let n={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[t]||t;if(n==="Space"?n=" ":n.includes(" ")&&(n=n.replace(/ /g,"")),e==="relative"){if(r==null)return {success:!1,error:"relativeTarget must be provided for relative keypress."};let S=this.selectors.relative;if(!S)return {success:!1,error:"Relative selector not defined for keypress action."};let y=await O.resolve(this.page,S,r);return y?(await y.press(n,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${r} for keypress.`}}let a=this.selectors[e];if(!a)return {success:!1,error:`Selector for keypress target ${e} not found.`};let o=this.page.locator(a).first();return await o.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await o.press(n,{timeout:this.timeoutMs}),{success:!0})}catch(i){return this.isBrowserClosedError(i)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to press ${t} on ${e}: ${i instanceof Error?i.message:String(i)}`}}}async hover(e,t){try{if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return {success:!1,error:"Relative selector not defined for hover action."};let n=await O.resolve(this.page,i,t);return n?(await n.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for hover.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:false,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:true}:{success:false,error:`Failed to hover ${e}: ${r instanceof Error?r.message:String(r)}`}}}};});var le,at=V(()=>{me();le=class{constructor(e,t,r=400){this.page=e;this.selectors=t;this.timeoutMs=r;}async resolveTarget(e,t,r){try{if(e==="relative"){let n=r?this.selectors[r]:this.selectors.relative;if(!n)return {target:null,error:"Relative selector is not defined in the contract."};if(!t)return {target:null,error:"Relative target or expected value is not defined."};let a=await O.resolve(this.page,n,t);return a?{target:a}:{target:null,error:`Target ${e} not found.`}}let i=this.selectors[e];return i?{target:this.page.locator(i).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(i){return {target:null,error:`Failed to resolve target ${e}: ${i instanceof Error?i.message:String(i)}`}}}async validateVisibility(e,t,r,i,n){try{return r?(await test.expect(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${n}".`}):(await test.expect(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${n}".`})}catch{let a=this.selectors[t]||"",o=await this.page.evaluate(f=>{let S=f?document.querySelector(f):null;if(!S)return "element not found";let y=window.getComputedStyle(S);return `display:${y.display}, visibility:${y.visibility}, opacity:${y.opacity}`},a);return r?{success:false,failMessage:`${i} (actual: ${o})`}:{success:false,failMessage:`${i} ${t} is still visible (actual: ${o}).`}}}async validateAttribute(e,t,r,i,n,a){if(i==="!empty"){let S=await e.getAttribute(r);return S&&S.trim()!==""?{success:true,passMessage:`${t} has non-empty "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should not be empty, found "${S}".`}}if(typeof i!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",i),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(i)}`);let o=i.split(" | ").map(S=>S.trim()),f=await e.getAttribute(r);return f!==null&&o.includes(f)?{success:true,passMessage:`${t} has expected "${r}". Test: "${a}".`}:{success:false,failMessage:`${n} ${t} "${r}" should be "${i}", found "${f}".`}}async validateValue(e,t,r,i,n){let a=await e.inputValue().catch(()=>"");return r==="!empty"?a&&a.trim()!==""?{success:true,passMessage:`${t} has non-empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should not be empty, found "${a}".`}:r===""?a===""?{success:true,passMessage:`${t} has empty value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be empty, found "${a}".`}:a===r?{success:true,passMessage:`${t} has expected value. Test: "${n}".`}:{success:false,failMessage:`${i} ${t} value should be "${r}", found "${a}".`}}async validateFocus(e,t,r,i,n){try{return r?(await test.expect(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${n}".`}):(await test.expect(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${n}".`})}catch{let a=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return {success:false,failMessage:`${i} (actual focus: ${a})`}}}async validateRole(e,t,r,i,n){let a=await e.getAttribute("role");return a===r?{success:true,passMessage:`${t} has role "${r}". Test: "${n}".`}:{success:false,failMessage:`${i} Expected role "${r}", found "${a}".`}}async validate(e,t){if(this.page.isClosed())return {success:false,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let r=null,i;if(e.controlledBy){let n=e.controlledBy,a=this.selectors[n.target];if(!a)return {success:false,failMessage:`Selector for controlledBy.target '${n.target}' not found.`,target:null};let o=null;if(n.relativeTarget?o=await O.resolve(this.page,a,n.relativeTarget):o=this.page.locator(a).first(),!o)return {success:false,failMessage:"Controlling element for controlledBy not found.",target:null};let f=n.attribute||"aria-controls",S=await o.getAttribute(f);if(!S)return {success:false,failMessage:`Controlling element does not have attribute '${f}'.`,target:null};if(r=this.page.locator(`#${S}`),!r||await r.count()===0)return {success:false,failMessage:`Controlled element with id '${S}' not found.`,target:null}}else {let n=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(r=n.target,i=n.error,i||!r)return {success:false,failMessage:i||`Target ${e.target} not found.`,target:null}}if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let n=await O.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),a=n?await n.getAttribute("id"):null,o=await r.getAttribute("aria-activedescendant");return a&&o===a?{success:true,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:false,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case "toBeVisible":return this.validateVisibility(r,e.target,true,e.failureMessage||"",t);case "notToBeVisible":return this.validateVisibility(r,e.target,false,e.failureMessage||"",t);case "toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(r,e.target,e.attribute,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case "toHaveValue":return e.expectedValue!==void 0?this.validateValue(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveValue assertion"};case "toHaveFocus":return this.validateFocus(r,e.target,true,e.failureMessage||"",t);case "notToHaveFocus":return this.validateFocus(r,e.target,false,e.failureMessage||"",t);case "toHaveRole":return e.expectedValue!==void 0?this.validateRole(r,e.target,e.expectedValue,e.failureMessage||"",t):{success:false,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return {success:false,failMessage:`Unknown assertion type: ${e.assertion}`}}}};});var ct={};Q(ct,{runContractTestsPlaywright:()=>Et});async function Et(c,e,t,r,i){let n=r?.test?.components?.find(h=>h.name===c),a=!!n?.contractPath,o=new de(true,a),f={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},S=r?.test?.disableTimeouts===true,x=n?.disableTimeouts===true||S,P=(h,_,J)=>{if(x)return 0;let D=h??_;return typeof D!="number"||!Number.isFinite(D)||D<0?J:D},z=P(n?.actionTimeoutMs,r?.test?.actionTimeoutMs,f.actionTimeoutMs),ee=P(n?.assertionTimeoutMs,r?.test?.assertionTimeoutMs,f.assertionTimeoutMs),ue=P(n?.navigationTimeoutMs,r?.test?.navigationTimeoutMs,f.navigationTimeoutMs),ye=P(n?.componentReadyTimeoutMs,r?.test?.componentReadyTimeoutMs,f.componentReadyTimeoutMs),Le=ce(t),te=n?.contractPath;if(!te)throw new Error(`Contract path not found for component: ${c}`);let gt=(()=>{if(Me__default.default.isAbsolute(te))return te;if(i){let _=Me__default.default.resolve(i,te);try{return fs.readFileSync(_,"utf-8"),_}catch{}}let h=Me__default.default.resolve(process.cwd(),te);try{return fs.readFileSync(h,"utf-8"),h}catch{return new URL(te,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname}})(),dt=fs.readFileSync(gt,"utf-8"),C=JSON.parse(dt),mt=(C.relationships?.length||0)+(C.static.length||0)+C.dynamic.length,ht=C.meta?.source?.apg,H=[],G=[],N=[],B=[],T=null,M=(h,_)=>{let J=Z(_),D=Oe(J,Le);if(D==="error")return H.push(h),{status:"fail",level:J,detail:h};if(D==="warning")return G.push(h),{status:"warn",level:J,detail:h};let K=`${h} (ignored by strictness=${Le}, level=${J})`;return B.push(K),{status:"skip",level:J,detail:K}};try{if(T=await De(),e){try{await T.goto(e,{waitUntil:"domcontentloaded",timeout:ue});}catch(s){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${s instanceof Error?s.message:String(s)}`)}await T.addStyleTag({content:"* { transition: none !important; animation: none !important; }"});}let h=await ge.detect(c,n,z,ee,i);if(!h)throw new Error(`Unsupported component: ${c}`);let _=h.getMainSelector();if(!_)throw new Error(`CRITICAL: No selector found in contract for ${c}`);try{await T.locator(_).first().waitFor({state:"attached",timeout:ye});}catch(s){throw new Error(`
|
|
31
31
|
\u274C CRITICAL: Component not found on page!
|
|
32
32
|
This usually means:
|
|
33
33
|
- The component didn't render
|
|
34
34
|
- The URL is incorrect
|
|
35
35
|
- The component selector '${_}' in the contract is wrong
|
|
36
|
-
- Original error: ${s}`)}o.start(c,mt,ht),c==="menu"&&C.selectors.main&&await T.locator(C.selectors.main).first().waitFor({state:"visible",timeout:ye}).catch(()=>{});let J=c==="menu"&&C.selectors.submenuTrigger?await T.locator(C.selectors.submenuTrigger).count()>0:!1,D=s=>s.type==="aria-reference"&&[s.from,s.to].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||""))||s.type==="contains"&&[s.parent,s.child].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||"")),K=0,L=0,F=0;for(let s of C.relationships||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(m){G.push(`Warning: resetState failed before relationship test: ${m instanceof Error?m.message:String(m)}`);}let g=Z(s.level);if(Array.isArray(s.setup)&&s.setup.length>0){let $=function(p){return v.includes(p)};var Fe=$;let m=new ne(T,C.selectors,z),R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v=["focus","type","click","keypress","hover"],w=p=>({...p,type:$(p.type)?p.type:"click"}),k=s.setup.map(w),E=await ve(k,m,h,T,R,["submenu","submenuTrigger","submenuItems"]);if(E.skip){B.push(E.message||"Setup action skipped"),o.reportStaticTest(R,"skip",E.message,g);continue}if(!E.success){let p=`Relationship setup failed: ${E.error}`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(R,u.status,u.detail,u.level);continue}}if(c==="menu"&&!J&&D(s)){let R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";B.push(v),o.reportStaticTest(R,"skip",v,g);continue}if(s.type==="aria-reference"){let m=`${s.from}.${s.attribute} references ${s.to}`,R=C.selectors[s.from],v=C.selectors[s.to];if(!R||!v){let d=M(`Relationship selector missing: from="${s.from}" or to="${s.to}" not found in selectors.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let $=T.locator(R).first(),w=T.locator(v).first(),k=await $.count()>0,E=await w.count()>0;if(!k||!E){if(c==="menu"&&D(s)){let U="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";B.push(U),o.reportStaticTest(m,"skip",U,g);continue}let d=M(`Relationship target not found: ${k?s.to:s.from}.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let p=await $.getAttribute(s.attribute),u=await w.getAttribute("id");if(!u){let d=M(`Relationship target "${s.to}" must have an id for ${s.attribute} validation.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}if(!(p||"").split(/\s+/).filter(Boolean).includes(u)){let d=M(`Expected ${s.from} ${s.attribute} to reference id "${u}", found "${p||""}".`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}N.push(`Relationship valid: ${s.from}.${s.attribute} -> ${s.to} (id=${u}).`),K+=1,o.reportStaticTest(m,"pass",void 0,g);continue}if(s.type==="contains"){let m=`${s.parent} contains ${s.child}`,R=C.selectors[s.parent],v=C.selectors[s.child];if(!R||!v){let p=M(`Relationship selector missing: parent="${s.parent}" or child="${s.child}" not found in selectors.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}let $=T.locator(R).first();if(!(await $.count()>0)){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";B.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Relationship parent target not found: ${s.parent}.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}if(await $.locator(v).count()<1){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";B.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Expected ${s.parent} to contain descendant matching selector for ${s.child}.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}N.push(`Relationship valid: ${s.parent} contains ${s.child}.`),K+=1,o.reportStaticTest(m,"pass",void 0,g);}}async function Ve(s,g,m,R={}){if(!s||typeof s!="object"||!("ref"in s))return s;let v;if(s.ref==="relative"){if(!s.relativeTarget||!R.relativeBaseSelector)return;let $=m.locator(R.relativeBaseSelector),w=await $.count(),k=0;if(s.relativeTarget==="first"?k=0:s.relativeTarget==="second"?k=1:s.relativeTarget==="last"?k=w-1:isNaN(Number(s.relativeTarget))?k=0:k=Number(s.relativeTarget),k<0||k>=w)return;let E=$.nth(k);return await Ue(E,s.property||s.attribute)}else {if(v=g[s.ref],!v)throw new Error(`Selector for ref '${s.ref}' not found in contract selectors.`);let $=m.locator(v).first();return await Ue($,s.property||s.attribute)}}async function Ue(s,g){if(s)return !g||g==="id"?await s.getAttribute("id")??void 0:g==="class"?await s.getAttribute("class")??void 0:g==="textContent"?await s.evaluate(m=>m.textContent??void 0):g.startsWith("aria-")?await s.getAttribute(g)??void 0:g.endsWith("*")?await s.evaluate(R=>{let v=[];for(let $ of Array.from(R.attributes))$.name.startsWith("aria-")&&v.push(`${$.name}=${$.value}`);return v.join(";")}):await s.getAttribute(g)??void 0}let yt=new le(T,C.selectors,ee);async function ve(s,g,m,R,v,$=[]){if(!Array.isArray(s)||s.length===0)return {success:!0};m&&typeof m.resetState=="function"&&await m.resetState(R);for(let w of s){let k={success:!0};try{if(w.type==="focus")w.target==="relative"&&w.relativeTarget?k=await g.focus("relative",w.relativeTarget):k=await g.focus(w.target);else if(w.type==="type"&&w.value)k=await g.type(w.target,w.value);else if(w.type==="click")k=await g.click(w.target,w.relativeTarget);else if(w.type==="keypress"&&w.key)k=await g.keypress(w.target,w.key,w.relativeTarget);else if(w.type==="hover")k=await g.hover(w.target,w.relativeTarget);else continue}catch(E){k={success:!1,error:E instanceof Error?E.message:String(E)};}if(!k.success){let E=k.error||"Setup action failed";return $.some(u=>v.includes(u)||E.includes(u))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${E}`}:{success:!1,error:E}}}return {success:!0}}for(let s of C.static[0]?.assertions||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(p){G.push(`Warning: resetState failed before static test: ${p instanceof Error?p.message:String(p)}`);}if(s.target==="relative")continue;let g=`${s.target}${s.attribute?` (${s.attribute})`:""}`,m=Z(s.level);if(c==="menu"&&s.target==="submenuTrigger"&&!J){let p=`Skipping submenu static assertion for ${s.target}: no submenu capability detected in rendered component.`;B.push(p),o.reportStaticTest(g,"skip",p,m);continue}let R=[];if(s.target||R.push("target"),s.attribute||R.push("attribute"),typeof s.expectedValue>"u"&&R.push("expectedValue"),R.length>0){let p=`${s.target||""}${s.attribute?` (${s.attribute})`:""}`,u=`Static assertion missing required field(s): ${R.join(", ")}`,b=M(u,s.level);b.status==="fail"&&(L+=1),b.status==="warn"&&(F+=1),o.reportStaticTest(p,b.status,b.detail,b.level);continue}if(Array.isArray(s.setup)&&s.setup.length>0){let b=function(l){return u.includes(l)};var Fe=b;let p=new ne(T,C.selectors,z),u=["focus","type","click","keypress","hover"],W=l=>({...l,type:b(l.type)?l.type:"click"}),d=s.setup.map(W),U=await ve(d,p,h,T,g,["submenu","submenuTrigger","submenuItems"]);if(U.skip){B.push(U.message||"Setup action skipped"),o.reportStaticTest(g,"skip",U.message,m);continue}if(!U.success){let l=`Static setup failed: ${U.error}`,A=M(l,s.level);A.status==="fail"&&(L+=1),A.status==="warn"&&(F+=1),o.reportStaticTest(g,A.status,A.detail,A.level);continue}}let v=C.selectors[s.target];if(!v){let p=`Selector for target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let $=T.locator(v).first();if(!(await $.count()>0)){let p=`Target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let k=(p,u,b)=>{let W=new RegExp(`\\[${u}(?:=["']?([^\\]"']+)["']?)?\\]`),d=p.match(W);if(!d)return !1;if(!b)return !0;let U=d[1];return U?b.split(" | ").includes(U):!1},E=s.expectedValue;if(s.expectedValue&&typeof s.expectedValue=="object"&&"ref"in s.expectedValue){let p={},u=s.relativeTarget;if(s.expectedValue.ref==="relative"&&s.target==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}else if(s.expectedValue.ref==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}E=await Ve(s.expectedValue,C.selectors,T,p);}if(s.expectedValue)if(k(v,s.attribute,typeof E=="string"?E:void 0))N.push(`${s.attribute}="${E}" on ${s.target} verified by selector (already present in: ${v}).`),K+=1,o.reportStaticTest(g,"pass",void 0,m);else {let p=E??"",u=await yt.validateAttribute($,s.target,s.attribute,p,s.failureMessage,"Static ARIA Test");if(u.success&&u.passMessage)N.push(u.passMessage),K+=1,o.reportStaticTest(g,"pass",void 0,m);else if(!u.success&&u.failMessage){let b=M(u.failMessage,s.level);b.status==="fail"&&(L+=1),b.status==="warn"&&(F+=1),o.reportStaticTest(g,b.status,b.detail,b.level);}}else {let p=s.attribute.split(" | "),u=!1,b=!0;for(let W of p){let d=W.trim();if(k(v,d)){N.push(`${d} on ${s.target} verified by selector (already present in: ${v}).`),u=!0;continue}if(b=!1,await $.getAttribute(d)!==null){u=!0;break}}if(!u&&!b){let W=s.failureMessage+` None of the attributes "${s.attribute}" are present.`,d=M(W,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(g,d.status,d.detail,d.level);}else !b&&u?(N.push(`At least one of the attributes "${s.attribute}" exists on the element.`),K+=1,o.reportStaticTest(g,"pass",void 0,m)):(K+=1,o.reportStaticTest(g,"pass",void 0,m));}}for(let s of C.dynamic||[]){if(!s.assertions||s.assertions.length===0){let l="Skipping test - no assertions found for this dynamic test.";B.push(l),o.reportTest({description:s.description,level:Z(s.level)},"skip",l);continue}if(!T||T.isClosed()){console.warn(`
|
|
36
|
+
- Original error: ${s}`)}o.start(c,mt,ht),c==="menu"&&C.selectors.main&&await T.locator(C.selectors.main).first().waitFor({state:"visible",timeout:ye}).catch(()=>{});let J=c==="menu"&&C.selectors.submenuTrigger?await T.locator(C.selectors.submenuTrigger).count()>0:!1,D=s=>s.type==="aria-reference"&&[s.from,s.to].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||""))||s.type==="contains"&&[s.parent,s.child].some(g=>["submenu","submenuTrigger","submenuItems"].includes(g||"")),K=0,L=0,F=0;for(let s of C.relationships||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(m){G.push(`Warning: resetState failed before relationship test: ${m instanceof Error?m.message:String(m)}`);}let g=Z(s.level);if(Array.isArray(s.setup)&&s.setup.length>0){let $=function(p){return v.includes(p)};var Fe=$;let m=new ne(T,C.selectors,z),R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v=["focus","type","click","keypress","hover"],w=p=>({...p,type:$(p.type)?p.type:"click"}),k=s.setup.map(w),E=await ve(k,m,h,T,R,["submenu","submenuTrigger","submenuItems"]);if(E.skip){B.push(E.message||"Setup action skipped"),o.reportStaticTest(R,"skip",E.message,g);continue}if(!E.success){let p=`Relationship setup failed: ${E.error}`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(R,u.status,u.detail,u.level);continue}}if(c==="menu"&&!J&&D(s)){let R=s.type==="aria-reference"?`${s.from}.${s.attribute} references ${s.to}`:`${s.parent} contains ${s.child}`,v="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";B.push(v),o.reportStaticTest(R,"skip",v,g);continue}if(s.type==="aria-reference"){let m=`${s.from}.${s.attribute} references ${s.to}`,R=C.selectors[s.from],v=C.selectors[s.to];if(!R||!v){let d=M(`Relationship selector missing: from="${s.from}" or to="${s.to}" not found in selectors.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let $=T.locator(R).first(),w=T.locator(v).first(),k=await $.count()>0,E=await w.count()>0;if(!k||!E){if(c==="menu"&&D(s)){let U="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";B.push(U),o.reportStaticTest(m,"skip",U,g);continue}let d=M(`Relationship target not found: ${k?s.to:s.from}.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}let p=await $.getAttribute(s.attribute),u=await w.getAttribute("id");if(!u){let d=M(`Relationship target "${s.to}" must have an id for ${s.attribute} validation.`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}if(!(p||"").split(/\s+/).filter(Boolean).includes(u)){let d=M(`Expected ${s.from} ${s.attribute} to reference id "${u}", found "${p||""}".`,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(m,d.status,d.detail,d.level);continue}N.push(`Relationship valid: ${s.from}.${s.attribute} -> ${s.to} (id=${u}).`),K+=1,o.reportStaticTest(m,"pass",void 0,g);continue}if(s.type==="contains"){let m=`${s.parent} contains ${s.child}`,R=C.selectors[s.parent],v=C.selectors[s.child];if(!R||!v){let p=M(`Relationship selector missing: parent="${s.parent}" or child="${s.child}" not found in selectors.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}let $=T.locator(R).first();if(!(await $.count()>0)){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";B.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Relationship parent target not found: ${s.parent}.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}if(await $.locator(v).count()<1){if(c==="menu"&&D(s)){let u="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";B.push(u),o.reportStaticTest(m,"skip",u,g);continue}let p=M(`Expected ${s.parent} to contain descendant matching selector for ${s.child}.`,s.level);p.status==="fail"&&(L+=1),p.status==="warn"&&(F+=1),o.reportStaticTest(m,p.status,p.detail,p.level);continue}N.push(`Relationship valid: ${s.parent} contains ${s.child}.`),K+=1,o.reportStaticTest(m,"pass",void 0,g);}}async function Ve(s,g,m,R={}){if(!s||typeof s!="object"||!("ref"in s))return s;let v;if(s.ref==="relative"){if(!s.relativeTarget||!R.relativeBaseSelector)return;let $=m.locator(R.relativeBaseSelector),w=await $.count(),k=0;if(s.relativeTarget==="first"?k=0:s.relativeTarget==="second"?k=1:s.relativeTarget==="last"?k=w-1:isNaN(Number(s.relativeTarget))?k=0:k=Number(s.relativeTarget),k<0||k>=w)return;let E=$.nth(k);return await Ue(E,s.property||s.attribute)}else {if(v=g[s.ref],!v)throw new Error(`Selector for ref '${s.ref}' not found in contract selectors.`);let $=m.locator(v).first();return await Ue($,s.property||s.attribute)}}async function Ue(s,g){if(s)return !g||g==="id"?await s.getAttribute("id")??void 0:g==="class"?await s.getAttribute("class")??void 0:g==="textContent"?await s.evaluate(m=>m.textContent??void 0):g.startsWith("aria-")?await s.getAttribute(g)??void 0:g.endsWith("*")?await s.evaluate(R=>{let v=[];for(let $ of Array.from(R.attributes))$.name.startsWith("aria-")&&v.push(`${$.name}=${$.value}`);return v.join(";")}):await s.getAttribute(g)??void 0}let yt=new le(T,C.selectors,ee);async function ve(s,g,m,R,v,$=[]){if(!Array.isArray(s)||s.length===0)return {success:!0};m&&typeof m.resetState=="function"&&await m.resetState(R);for(let w of s){let k={success:!0};try{if(w.type==="focus")w.target==="relative"&&w.relativeTarget?k=await g.focus("relative",w.relativeTarget):k=await g.focus(w.target);else if(w.type==="type"&&w.value)k=await g.type(w.target,w.value);else if(w.type==="click")k=await g.click(w.target,w.relativeTarget);else if(w.type==="keypress"&&w.key)k=await g.keypress(w.target,w.key,w.relativeTarget);else if(w.type==="hover")k=await g.hover(w.target,w.relativeTarget);else continue}catch(E){k={success:!1,error:E instanceof Error?E.message:String(E)};}if(!k.success){let E=k.error||"Setup action failed";return $.some(u=>v.includes(u)||E.includes(u))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${E}`}:{success:!1,error:E}}}return {success:!0}}for(let s of C.static||[]){if(h&&typeof h.resetState=="function")try{await h.resetState(T);}catch(p){G.push(`Warning: resetState failed before static test: ${p instanceof Error?p.message:String(p)}`);}if(s.target==="relative")continue;let g=`${s.target}${s.attribute?` (${s.attribute})`:""}`,m=Z(s.level);if(c==="menu"&&s.target==="submenuTrigger"&&!J){let p=`Skipping submenu static assertion for ${s.target}: no submenu capability detected in rendered component.`;B.push(p),o.reportStaticTest(g,"skip",p,m);continue}let R=[];if(s.target||R.push("target"),s.attribute||R.push("attribute"),typeof s.expectedValue>"u"&&R.push("expectedValue"),R.length>0){let p=`${s.target||""}${s.attribute?` (${s.attribute})`:""}`,u=`Static assertion missing required field(s): ${R.join(", ")}`,b=M(u,s.level);b.status==="fail"&&(L+=1),b.status==="warn"&&(F+=1),o.reportStaticTest(p,b.status,b.detail,b.level);continue}if(Array.isArray(s.setup)&&s.setup.length>0){let b=function(l){return u.includes(l)};var Fe=b;let p=new ne(T,C.selectors,z),u=["focus","type","click","keypress","hover"],W=l=>({...l,type:b(l.type)?l.type:"click"}),d=s.setup.map(W),U=await ve(d,p,h,T,g,["submenu","submenuTrigger","submenuItems"]);if(U.skip){B.push(U.message||"Setup action skipped"),o.reportStaticTest(g,"skip",U.message,m);continue}if(!U.success){let l=`Static setup failed: ${U.error}`,A=M(l,s.level);A.status==="fail"&&(L+=1),A.status==="warn"&&(F+=1),o.reportStaticTest(g,A.status,A.detail,A.level);continue}}let v=C.selectors[s.target];if(!v){let p=`Selector for target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let $=T.locator(v).first();if(!(await $.count()>0)){let p=`Target ${s.target} not found.`,u=M(p,s.level);u.status==="fail"&&(L+=1),u.status==="warn"&&(F+=1),o.reportStaticTest(g,u.status,u.detail,u.level);continue}let k=(p,u,b)=>{let W=new RegExp(`\\[${u}(?:=["']?([^\\]"']+)["']?)?\\]`),d=p.match(W);if(!d)return !1;if(!b)return !0;let U=d[1];return U?b.split(" | ").includes(U):!1},E=s.expectedValue;if(s.expectedValue&&typeof s.expectedValue=="object"&&"ref"in s.expectedValue){let p={},u=s.relativeTarget;if(s.expectedValue.ref==="relative"&&s.target==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}else if(s.expectedValue.ref==="relative"&&u){let b=C.selectors[u];if(!b)throw new Error(`Selector for relativeTarget '${u}' not found in contract selectors.`);p.relativeBaseSelector=b;}E=await Ve(s.expectedValue,C.selectors,T,p);}if(s.expectedValue)if(k(v,s.attribute,typeof E=="string"?E:void 0))N.push(`${s.attribute}="${E}" on ${s.target} verified by selector (already present in: ${v}).`),K+=1,o.reportStaticTest(g,"pass",void 0,m);else {let p=E??"",u=await yt.validateAttribute($,s.target,s.attribute,p,s.failureMessage,"Static ARIA Test");if(u.success&&u.passMessage)N.push(u.passMessage),K+=1,o.reportStaticTest(g,"pass",void 0,m);else if(!u.success&&u.failMessage){let b=M(u.failMessage,s.level);b.status==="fail"&&(L+=1),b.status==="warn"&&(F+=1),o.reportStaticTest(g,b.status,b.detail,b.level);}}else {let p=s.attribute.split(" | "),u=!1,b=!0;for(let W of p){let d=W.trim();if(k(v,d)){N.push(`${d} on ${s.target} verified by selector (already present in: ${v}).`),u=!0;continue}if(b=!1,await $.getAttribute(d)!==null){u=!0;break}}if(!u&&!b){let W=s.failureMessage+` None of the attributes "${s.attribute}" are present.`,d=M(W,s.level);d.status==="fail"&&(L+=1),d.status==="warn"&&(F+=1),o.reportStaticTest(g,d.status,d.detail,d.level);}else !b&&u?(N.push(`At least one of the attributes "${s.attribute}" exists on the element.`),K+=1,o.reportStaticTest(g,"pass",void 0,m)):(K+=1,o.reportStaticTest(g,"pass",void 0,m));}}for(let s of C.dynamic||[]){if(!s.assertions||s.assertions.length===0){let l="Skipping test - no assertions found for this dynamic test.";B.push(l),o.reportTest({description:s.description,level:Z(s.level)},"skip",l);continue}if(!T||T.isClosed()){console.warn(`
|
|
37
37
|
\u26A0\uFE0F Browser closed - skipping remaining ${C.dynamic.length-C.dynamic.indexOf(s)} tests
|
|
38
38
|
`),H.push(`CRITICAL: Browser/page closed before completing all tests. ${C.dynamic.length-C.dynamic.indexOf(s)} tests skipped.`);break}try{await h.resetState(T);}catch(l){let A=l instanceof Error?l.message:String(l);throw o.error(A),l}let{setup:g=[],action:m,assertions:R}=s,v=Z(s.level),$=new ne(T,C.selectors,z);if(Array.isArray(g)&&g.length>0){let A=function(j){return l.includes(j)};var Fe=A;let l=["focus","type","click","keypress","hover"],se=j=>({...j,type:A(j.type)?j.type:"click"}),we=g.map(se),q=await ve(we,$,h,T,s.description,["submenu","submenuTrigger","submenuItems"]);if(q.skip){B.push(q.message||"Setup action skipped"),o.reportTest({description:s.description,level:v},"skip",q.message);continue}if(!q.success){let j=M(`Setup failed: ${q.error}`,s.level);o.reportTest({description:s.description,level:v},j.status,j.detail);continue}}let w=H.length,k=G.length,E=B.length;if(await h.shouldSkipTest(s,T)){let l="Skipping test - component-specific conditions not met";B.push(l),o.reportTest({description:s.description,level:v},"skip",l);continue}let u=new le(T,C.selectors,ee),b=!1,W=null;for(let l of m){if(!T||T.isClosed()){H.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),b=!0;break}let A;if(l.type==="focus")l.target==="relative"&&l.relativeTarget?A=await $.focus("relative",l.relativeTarget):A=await $.focus(l.target);else if(l.type==="type"&&l.value)A=await $.type(l.target,l.value);else if(l.type==="click")A=await $.click(l.target,l.relativeTarget);else if(l.type==="keypress"&&l.key)A=await $.keypress(l.target,l.key,l.relativeTarget);else if(l.type==="hover")A=await $.hover(l.target,l.relativeTarget);else continue;if(!A.success){if(A.error){let se=M(A.error,s.level);W={status:se.status,detail:se.detail};}b=!0;break}}if(b){o.reportTest({description:s.description,level:v},W?.status||"fail",W?.detail||H[H.length-1]);continue}for(let l of R){let A;if(l.expectedValue&&typeof l.expectedValue=="object"&&"ref"in l.expectedValue)if(l.expectedValue.ref==="relative"){let{RelativeTargetResolver:Y}=await Promise.resolve().then(()=>(me(),nt)),j=C.selectors.relative;if(!j)throw new Error("Relative selector not defined in contract selectors.");let ae=l.relativeTarget||"first",X=await Y.resolve(T,j,ae);if(!X)throw new Error(`Could not resolve relative target '${ae}' for expectedValue.`);let He=l.expectedValue.property||l.expectedValue.attribute||"id";if(He==="textContent")A=await X.evaluate(pe=>pe.textContent??void 0);else {let pe=await X.getAttribute(He);A=pe===null?void 0:pe;}}else A=await Ve(l.expectedValue,C.selectors,T,{});else typeof l.expectedValue=="string"||typeof l.expectedValue>"u"?A=l.expectedValue:A="";let se={...l,expectedValue:A},we=A??"",q=await u.validate({...se,expectedValue:we},s.description);if(q.success&&q.passMessage)N.push(q.passMessage);else if(!q.success&&q.failMessage){let Y=[];if(l.target||Y.push("target"),l.assertion||Y.push("assertion"),["toHaveAttribute","toHaveValue","toHaveRole"].includes(l.assertion)&&(typeof l.attribute>"u"&&l.assertion==="toHaveAttribute"&&Y.push("attribute"),typeof l.expectedValue>"u"&&Y.push("expectedValue")),Y.length>0){let j=Z(l.level||s.level),ae=`Dynamic assertion missing required field(s): ${Y.join(", ")}`,X=M(ae,j);if(X.status==="skip")continue;H.push(ae),o.reportTest({description:s.description,level:j},X.status,X.detail);continue}}}let d=H.length,U=G.length,je=B.length;d>w?o.reportTest({description:s.description,level:v},"fail",H[H.length-1]):U>k?o.reportTest({description:s.description,level:v},"warn",G[G.length-1]):je>E?o.reportTest({description:s.description,level:v},"skip",B[B.length-1]):o.reportTest({description:s.description,level:v},"pass");}o.reportStatic(K,L,F),o.summary(H);}catch(h){if(h instanceof Error)throw h.message.includes("Executable doesn't exist")||h.message.includes("browserType.launch")?new Error(`
|
|
39
39
|
\u274C CRITICAL: Playwright browsers not found!
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {d,b}from'./chunk-APUMBDOT.js';import m from'path';async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=d(c.strictness),o={},d$1=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import('./configLoader-NCYRL2O6.js'),n=await t(process.cwd());if(o=n.config,n.configPath&&(d$1=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=d(r??o.test?.strictness);}}catch{c.strictness===void 0&&(p="balanced");}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import('./contractTestRunnerPlaywright-
|
|
1
|
+
import {d,b}from'./chunk-APUMBDOT.js';import m from'path';async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=d(c.strictness),o={},d$1=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import('./configLoader-NCYRL2O6.js'),n=await t(process.cwd());if(o=n.config,n.configPath&&(d$1=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=d(r??o.test?.strictness);}}catch{c.strictness===void 0&&(p="balanced");}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import('./contractTestRunnerPlaywright-Y7N2W6AK.js');s=await n(a,t,p,o,d$1);}else throw new Error(`\u274C Dev server not running at ${e}
|
|
2
2
|
Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(t){throw t instanceof Error?t:new Error(`\u274C Contract test execution failed: ${String(t)}`)}let u={violations:i.violations,raw:i,contract:s};if(s.failures.length>0&&e==="Playwright")throw new Error(`
|
|
3
3
|
\u274C ${s.failures.length} accessibility contract test${s.failures.length>1?"s":""} failed (Playwright mode)
|
|
4
4
|
\u2705 ${s.passes.length} test${s.passes.length>1?"s":""} passed
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as g,d as f}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";import m from"path";async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=f(c.strictness),o={},d=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import("./configLoader-ZXTSCIP6.js"),n=await t(process.cwd());if(o=n.config,n.configPath&&(d=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=f(r??o.test?.strictness)}}catch{c.strictness===void 0&&(p="balanced")}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import("./contractTestRunnerPlaywright-
|
|
1
|
+
import{b as g,d as f}from"./chunk-APUMBDOT.js";import"./chunk-CNU4N4AY.js";import m from"path";async function y(a,e,c={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let i={violations:[]};async function l(t){try{let n=await fetch(t,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(n.ok||n.status===304)return t}catch{return null}return null}let p=f(c.strictness),o={},d=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:t}=await import("./configLoader-ZXTSCIP6.js"),n=await t(process.cwd());if(o=n.config,n.configPath&&(d=m.dirname(n.configPath)),c.strictness===void 0){let r=o.test?.components?.find(h=>h?.name===a)?.strictness;p=f(r??o.test?.strictness)}}catch{c.strictness===void 0&&(p="balanced")}let s;try{if(e){let t=await l(e);if(t){console.log(`\u{1F3AD} Running Playwright tests on ${t}`);let{runContractTestsPlaywright:n}=await import("./contractTestRunnerPlaywright-SJIHHZ3Y.js");s=await n(a,t,p,o,d)}else throw new Error(`\u274C Dev server not running at ${e}
|
|
2
2
|
Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(t){throw t instanceof Error?t:new Error(`\u274C Contract test execution failed: ${String(t)}`)}let u={violations:i.violations,raw:i,contract:s};if(s.failures.length>0&&e==="Playwright")throw new Error(`
|
|
3
3
|
\u274C ${s.failures.length} accessibility contract test${s.failures.length>1?"s":""} failed (Playwright mode)
|
|
4
4
|
\u2705 ${s.passes.length} test${s.passes.length>1?"s":""} passed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aria-ease",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "Accessibility infrastructure for the entire frontend engineering lifecycle. Build accessible patterns, run automated audits, verify component interactions, and gate deployments — all in one system.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./chunk-SM6ZKEDR.js";import"./chunk-CNU4N4AY.js";var n=class{constructor(t,e,i=400,s=400){this.mainSelector=t;this.selectors=e;this.actionTimeoutMs=i;this.assertionTimeoutMs=s}async resetState(t){if(!this.selectors.panel||!this.selectors.trigger||this.selectors.popup)return;let e=this.selectors.trigger,i=this.selectors.panel;if(!e||!i)return;let s=await t.locator(e).all();for(let r of s){let c=await r.getAttribute("aria-expanded")==="true",a=await r.getAttribute("aria-controls");if(c&&a){await r.click({timeout:this.actionTimeoutMs});let l=t.locator(`#${a}`);await(0,o.expect)(l).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{})}}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}};export{n as AccordionComponentStrategy};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import"./chunk-CNU4N4AY.js";import g from"path";import v from"fs-extra";import{glob as q}from"fs/promises";import l from"chalk";function E(f){let e=[];if(!f||typeof f!="object")return{valid:!1,errors:[{path:"$",message:"Contract must be an object"}]};let r=f;if(!r.selectors)e.push({path:"$.selectors",message:"selectors is required"});else if(typeof r.selectors!="object"||r.selectors===null||Array.isArray(r.selectors))e.push({path:"$.selectors",message:"selectors must be an object"});else{let o=r.selectors;Object.entries(o).forEach(([s,a])=>{typeof a!="string"&&e.push({path:`$.selectors['${s}']`,message:"All selectors must be strings"})})}return Array.isArray(r.static)?r.static.forEach((o,s)=>{if(typeof o!="object"||o===null){e.push({path:`$.static[${s}]`,message:"static item must be an object"});return}let a=o;if(!Array.isArray(a.assertions)){e.push({path:`$.static[${s}].assertions`,message:"assertions must be an array"});return}a.assertions.forEach((n,i)=>{if(typeof n!="object"||n===null){e.push({path:`$.static[${s}].assertions[${i}]`,message:"assertion must be an object"});return}let t=n;typeof t.target!="string"&&e.push({path:`$.static[${s}].assertions[${i}].target`,message:"target is required and must be a string"}),typeof t.attribute!="string"&&e.push({path:`$.static[${s}].assertions[${i}].attribute`,message:"attribute is required and must be a string"}),typeof t.failureMessage!="string"&&e.push({path:`$.static[${s}].assertions[${i}].failureMessage`,message:"failureMessage is required and must be a string"}),t.level!==void 0&&!["required","recommended","optional"].includes(t.level)&&e.push({path:`$.static[${s}].assertions[${i}].level`,message:"level must be one of: required, recommended, optional"})})}):e.push({path:"$.static",message:"static must be an array"}),Array.isArray(r.dynamic)?r.dynamic.forEach((o,s)=>{if(typeof o!="object"||o===null){e.push({path:`$.dynamic[${s}]`,message:"dynamic item must be an object"});return}let a=o;typeof a.description!="string"&&e.push({path:`$.dynamic[${s}].description`,message:"description is required and must be a string"}),Array.isArray(a.action)?a.action.forEach((n,i)=>{if(typeof n!="object"||n===null){e.push({path:`$.dynamic[${s}].action[${i}]`,message:"action item must be an object"});return}let t=n;typeof t.type!="string"&&e.push({path:`$.dynamic[${s}].action[${i}].type`,message:"type is required and must be a string"}),typeof t.target!="string"&&e.push({path:`$.dynamic[${s}].action[${i}].target`,message:"target is required and must be a string"})}):e.push({path:`$.dynamic[${s}].action`,message:"action is required and must be an array"}),Array.isArray(a.assertions)?a.assertions.forEach((n,i)=>{if(typeof n!="object"||n===null){e.push({path:`$.dynamic[${s}].assertions[${i}]`,message:"assertion must be an object"});return}let t=n;typeof t.target!="string"&&e.push({path:`$.dynamic[${s}].assertions[${i}].target`,message:"target is required and must be a string"}),typeof t.assertion!="string"&&e.push({path:`$.dynamic[${s}].assertions[${i}].assertion`,message:"assertion is required and must be a string"}),t.level!==void 0&&!["required","recommended","optional"].includes(t.level)&&e.push({path:`$.dynamic[${s}].assertions[${i}].level`,message:"level must be one of: required, recommended, optional"})}):e.push({path:`$.dynamic[${s}].assertions`,message:"assertions is required and must be an array"})}):e.push({path:"$.dynamic",message:"dynamic must be an array"}),r.relationships!==void 0&&(Array.isArray(r.relationships)?r.relationships.forEach((o,s)=>{if(typeof o!="object"||o===null){e.push({path:`$.relationships[${s}]`,message:"relationship must be an object"});return}let a=o,n=a.type;["aria-reference","contains"].includes(n)||e.push({path:`$.relationships[${s}].type`,message:"type must be one of: aria-reference, contains"}),n==="aria-reference"?(typeof a.from!="string"&&e.push({path:`$.relationships[${s}].from`,message:"from is required for aria-reference and must be a string"}),typeof a.attribute!="string"&&e.push({path:`$.relationships[${s}].attribute`,message:"attribute is required for aria-reference and must be a string"}),typeof a.to!="string"&&e.push({path:`$.relationships[${s}].to`,message:"to is required for aria-reference and must be a string"})):n==="contains"&&(typeof a.parent!="string"&&e.push({path:`$.relationships[${s}].parent`,message:"parent is required for contains and must be a string"}),typeof a.child!="string"&&e.push({path:`$.relationships[${s}].child`,message:"child is required for contains and must be a string"}))}):e.push({path:"$.relationships",message:"relationships must be an array"})),{valid:e.length===0,errors:e}}function R(f,e){let r=[];if(!f||typeof f!="object")return r;let s=f.relationships;return Array.isArray(s)&&s.forEach((a,n)=>{let i=a.type;if(i==="aria-reference"){let t=a.from,c=a.to;t&&!e.has(t)&&r.push({path:`$.relationships[${n}].from`,message:`Selector '${t}' not found in selectors`}),c&&!e.has(c)&&r.push({path:`$.relationships[${n}].to`,message:`Selector '${c}' not found in selectors`})}else if(i==="contains"){let t=a.parent,c=a.child;t&&!e.has(t)&&r.push({path:`$.relationships[${n}].parent`,message:`Selector '${t}' not found in selectors`}),c&&!e.has(c)&&r.push({path:`$.relationships[${n}].child`,message:`Selector '${c}' not found in selectors`})}}),r}function k(f,e){let r=[];if(!f||typeof f!="object")return r;let o=f,s=o.static;Array.isArray(s)&&s.forEach((n,i)=>{let t=n.assertions;Array.isArray(t)&&t.forEach((c,h)=>{let p=c.target;p&&!e.has(p)&&r.push({path:`$.static[${i}].assertions[${h}].target`,message:`Selector '${p}' not found in selectors`})})});let a=o.dynamic;return Array.isArray(a)&&a.forEach((n,i)=>{let t=n.action;Array.isArray(t)&&t.forEach((h,p)=>{let u=h.target;u&&u!=="document"&&!e.has(u)&&r.push({path:`$.dynamic[${i}].action[${p}].target`,message:`Selector '${u}' not found in selectors (or use 'document')`})});let c=n.assertions;Array.isArray(c)&&c.forEach((h,p)=>{let u=h.target;u&&u!=="relative"&&!e.has(u)&&r.push({path:`$.dynamic[${i}].assertions[${p}].target`,message:`Selector '${u}' not found in selectors (or use 'relative')`})})}),r}async function F(f,e){let r=[],o=[];if(!e.contracts||e.contracts.length===0)return console.log(l.yellow('\u2139\uFE0F No contracts configured. Add "contracts" array to ariaease.config.js')),{success:!0,built:o,errors:r};try{console.log(l.cyanBright(`
|
|
2
|
-
\u{1F3D7}\uFE0F Building contracts...
|
|
3
|
-
`));for(let s of e.contracts){let a=g.resolve(f,s.src),n=s.out?g.resolve(f,s.out):void 0;console.log(l.gray(` Pattern: ${s.src}`)),console.log(n?l.gray(` Output: ${s.out}
|
|
4
|
-
`):l.gray(` Output: Same directory as source
|
|
5
|
-
`));let i=[];for await(let t of q(a,{cwd:f}))i.push(t);if(i.length===0){console.log(l.yellow(`\u26A0\uFE0F No contract files found matching pattern: ${s.src}`));continue}n&&await v.ensureDir(n);for(let t of i)try{let c=t.startsWith("/")?t:g.resolve(f,t),h=await import(`file://${c}`),p=h.default;if(!p){let d=Object.entries(h).find(([,m])=>m&&typeof m=="object"&&"toJSON"in m);d&&(p=d[1])}if(!p||typeof p.toJSON!="function"){r.push(`${g.basename(t)}: No contract with toJSON() method found`);continue}let u=p.toJSON(),A=E(u);if(!A.valid){let m=`Schema validation failed:
|
|
6
|
-
${A.errors.map($=>` ${l.red("\u2717")} ${$.path}: ${$.message}`).join(`
|
|
7
|
-
`)}`;r.push(`${g.basename(t)}: ${m}`),console.log(l.red(`\u274C ${g.basename(t)}`)),console.log(l.red(` ${m}`));continue}let y=new Set;if(u&&typeof u=="object"&&"selectors"in u){let d=u.selectors;Object.keys(d).forEach(m=>y.add(m))}let j=[...R(u,y),...k(u,y)];if(j.length>0){let m=`Reference validation failed:
|
|
8
|
-
${j.map($=>` ${l.red("\u2717")} ${$.path}: ${$.message}`).join(`
|
|
9
|
-
`)}`;r.push(`${g.basename(t)}: ${m}`),console.log(l.red(`\u274C ${g.basename(t)}`)),console.log(l.red(` ${m}`));continue}let w=g.basename(t,g.extname(t)),b=n?g.join(n,`${w}.json`):g.join(g.dirname(c),`${w}.json`);await v.writeFile(b,JSON.stringify(u,null,2)+`
|
|
10
|
-
`,"utf-8");let S=g.relative(f,b);o.push(S),console.log(l.green(`\u2705 ${g.basename(t)} \u2192 ${g.basename(b)}`))}catch(c){let h=c instanceof Error?c.message:String(c),p=g.basename(t);r.push(`${p}: ${h}`),console.log(l.red(`\u274C ${p}`)),console.log(l.red(` Error: ${h}`))}}return console.log(""),r.length===0?(console.log(l.green(`\u2705 Built ${o.length} contract${o.length!==1?"s":""} successfully
|
|
11
|
-
`)),{success:!0,built:o,errors:r}):(console.log(l.yellow(`\u26A0\uFE0F Built ${o.length} contracts with ${r.length} error${r.length!==1?"s":""}
|
|
12
|
-
`)),{success:!1,built:o,errors:r})}catch(s){let n=`Failed to build contracts: ${s instanceof Error?s.message:String(s)}`;return r.push(n),console.log(l.red(`\u274C ${n}
|
|
13
|
-
`)),{success:!1,built:o,errors:r}}}export{F as buildContracts};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {expect}from'@playwright/test';var a=class{constructor(t,e,o=400,i=400){this.mainSelector=t;this.selectors=e;this.actionTimeoutMs=o;this.assertionTimeoutMs=i;}async resetState(t){if(!this.selectors.panel||!this.selectors.trigger||this.selectors.popup)return;let e=this.selectors.trigger,o=this.selectors.panel;if(!e||!o)return;let i=await t.locator(e).all();for(let r of i){let n=await r.getAttribute("aria-expanded")==="true",s=await r.getAttribute("aria-controls");if(n&&s){await r.click({timeout:this.actionTimeoutMs});let c=t.locator(`#${s}`);await expect(c).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{});}}}async shouldSkipTest(){return false}getMainSelector(){return this.mainSelector}};export{a as AccordionComponentStrategy};
|