var c=class{async verify(t){throw new Error("TestVerificationStrategy.verify() must be implemented")}canVerify(t){throw new Error("TestVerificationStrategy.canVerify() must be implemented")}getName(){throw new Error("TestVerificationStrategy.getName() must be implemented")}getPriority(){return 0}};import{execSync as x}from"node:child_process";import{existsSync as w}from"node:fs";var l=class extends c{getName(){return"Playwright JSON Reporter"}getPriority(){return 100}canVerify(t){let{testFilePath:e}=t;return w(e)}async verify(t){let{testFilePath:e,cwd:n,timeout:m=3e4}=t;try{console.log(`\u{1F9EA} Running test: ${e}`);let a=`npx playwright test ${e} --reporter=json --timeout=${m}`,i=x(a,{cwd:n,encoding:"utf-8",stdio:["pipe","pipe","pipe"],timeout:m+1e4}),s=JSON.parse(i).stats||{};return{success:s.unexpected===0,passed:s.expected||0,failed:s.unexpected||0,error:null,errorDetails:null}}catch(a){let i=a.stdout||a.stderr||a.message;try{let o=JSON.parse(i),s=o.stats||{},r="Test execution failed";if(o.suites&&o.suites.length>0){let g=o.suites[0];if(g.specs&&g.specs.length>0){let p=g.specs[0];if(p.tests&&p.tests.length>0){let d=p.tests[0];if(d.results&&d.results.length>0){let h=d.results[0];h.error&&(r=h.error.message||r)}}}}let u=r.includes("Executable doesn't exist")||r.includes("browserType.launch")||r.includes("Please run the following command")||r.includes("npx playwright install")||i.includes("Executable doesn't exist")||i.includes("npx playwright install");return{success:!1,passed:s.expected||0,failed:s.unexpected||0,error:r,errorDetails:r,isEnvironmentError:u}}catch{let s=i.match(/Error: (.+)/),r=s?s[1]:"Test execution failed",u=r.includes("Executable doesn't exist")||r.includes("browserType.launch")||r.includes("Please run the following command")||r.includes("npx playwright install")||i.includes("Executable doesn't exist")||i.includes("npx playwright install");return{success:!1,passed:0,failed:1,error:r,errorDetails:r,isEnvironmentError:u}}}}};var f=class{constructor(){this.strategies=[new l],this.strategies.sort((t,e)=>e.getPriority()-t.getPriority())}registerStrategy(t){this.strategies.push(t),this.strategies.sort((e,n)=>n.getPriority()-e.getPriority())}async verify(t){console.log(`
\u{1F4CB} Available verification strategies (${this.strategies.length}):`),this.strategies.forEach(e=>{let n=e.canVerify(t);console.log(`   ${n?"\u2713":"\u2717"} ${e.getName()} (priority: ${e.getPriority()})`)});for(let e of this.strategies)if(e.canVerify(t))return console.log(`
\u{1F3AF} Selected: ${e.getName()}`),e.verify(t);throw new Error("No verification strategy available for this context")}getStrategy(t){return this.strategies.find(e=>e.getName().includes(t))||null}},E=new f,$=E;export{l as PlaywrightJsonVerificationStrategy,c as TestVerificationStrategy,f as TestVerificationStrategyManager,$ as default,E as testVerificationManager};
