brave-real-playwright-core
Version:
Brave-optimized Playwright Core (v1.56.1) with comprehensive stealth patches and error stack sanitization
6 lines (5 loc) • 36.2 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./assets/xtermModule-CsJ4vdCR.js","./xtermModule.DYP7pi_n.css"])))=>i.map(i=>d[i]);
import{u as At,r as K,f as Ut,_ as Wt,g as zt,h as Vt,j as r,R as u,E as Kt,s as xt,i as ht,k as Ht,t as $t,m as qt,l as H,n as O,M as St,b as Yt,o as ot,T as Qt,W as Xt,S as Jt,p as Zt,a as Gt,d as te,e as ee}from"./assets/defaultSettingsView-w0zYjHsW.js";var se={};class dt{constructor(t,e={}){this.isListing=!1,this._tests=new Map,this._rootSuite=new X("","root"),this._options=e,this._reporter=t}reset(){this._rootSuite._entries=[],this._tests.clear()}dispatch(t){const{method:e,params:s}=t;if(e==="onConfigure"){this._onConfigure(s.config);return}if(e==="onProject"){this._onProject(s.project);return}if(e==="onBegin"){this._onBegin();return}if(e==="onTestBegin"){this._onTestBegin(s.testId,s.result);return}if(e==="onTestEnd"){this._onTestEnd(s.test,s.result);return}if(e==="onStepBegin"){this._onStepBegin(s.testId,s.resultId,s.step);return}if(e==="onAttach"){this._onAttach(s.testId,s.resultId,s.attachments);return}if(e==="onStepEnd"){this._onStepEnd(s.testId,s.resultId,s.step);return}if(e==="onError"){this._onError(s.error);return}if(e==="onStdIO"){this._onStdIO(s.type,s.testId,s.resultId,s.data,s.isBase64);return}if(e==="onEnd")return this._onEnd(s.result);if(e==="onExit")return this._onExit()}_onConfigure(t){var e,s;this._rootDir=t.rootDir,this._config=this._parseConfig(t),(s=(e=this._reporter).onConfigure)==null||s.call(e,this._config)}_onProject(t){let e=this._options.mergeProjects?this._rootSuite.suites.find(s=>s.project().name===t.name):void 0;e||(e=new X(t.name,"project"),this._rootSuite._addSuite(e)),e._project=this._parseProject(t);for(const s of t.suites)this._mergeSuiteInto(s,e)}_onBegin(){var t,e;(e=(t=this._reporter).onBegin)==null||e.call(t,this._rootSuite)}_onTestBegin(t,e){var d,n;const s=this._tests.get(t);this._options.clearPreviousResultsWhenTestBegins&&(s.results=[]);const i=s._createTestResult(e.id);i.retry=e.retry,i.workerIndex=e.workerIndex,i.parallelIndex=e.parallelIndex,i.setStartTimeNumber(e.startTime),(n=(d=this._reporter).onTestBegin)==null||n.call(d,s,i)}_onTestEnd(t,e){var d,n,m;const s=this._tests.get(t.testId);s.timeout=t.timeout,s.expectedStatus=t.expectedStatus;const i=s.results.find(c=>c._id===e.id);i.duration=e.duration,i.status=e.status,i.errors=e.errors,i.error=(d=i.errors)==null?void 0:d[0],e.attachments&&(i.attachments=this._parseAttachments(e.attachments)),e.annotations&&(this._absoluteAnnotationLocationsInplace(e.annotations),i.annotations=e.annotations,s.annotations=e.annotations),(m=(n=this._reporter).onTestEnd)==null||m.call(n,s,i),i._stepMap=new Map}_onStepBegin(t,e,s){var f,a;const i=this._tests.get(t),d=i.results.find(w=>w._id===e),n=s.parentStepId?d._stepMap.get(s.parentStepId):void 0,m=this._absoluteLocation(s.location),c=new oe(s,n,m,d);n?n.steps.push(c):d.steps.push(c),d._stepMap.set(s.id,c),(a=(f=this._reporter).onStepBegin)==null||a.call(f,i,d,c)}_onStepEnd(t,e,s){var m,c;const i=this._tests.get(t),d=i.results.find(f=>f._id===e),n=d._stepMap.get(s.id);n._endPayload=s,n.duration=s.duration,n.error=s.error,(c=(m=this._reporter).onStepEnd)==null||c.call(m,i,d,n)}_onAttach(t,e,s){this._tests.get(t).results.find(n=>n._id===e).attachments.push(...s.map(n=>({name:n.name,contentType:n.contentType,path:n.path,body:n.base64&&globalThis.Buffer?Buffer.from(n.base64,"base64"):void 0})))}_onError(t){var e,s;(s=(e=this._reporter).onError)==null||s.call(e,t)}_onStdIO(t,e,s,i,d){var f,a,w,x;const n=d?globalThis.Buffer?Buffer.from(i,"base64"):atob(i):i,m=e?this._tests.get(e):void 0,c=m&&s?m.results.find(l=>l._id===s):void 0;t==="stdout"?(c==null||c.stdout.push(n),(a=(f=this._reporter).onStdOut)==null||a.call(f,n,m,c)):(c==null||c.stderr.push(n),(x=(w=this._reporter).onStdErr)==null||x.call(w,n,m,c))}async _onEnd(t){var e,s;await((s=(e=this._reporter).onEnd)==null?void 0:s.call(e,{status:t.status,startTime:new Date(t.startTime),duration:t.duration}))}_onExit(){var t,e;return(e=(t=this._reporter).onExit)==null?void 0:e.call(t)}_parseConfig(t){const e={...ne,...t};return this._options.configOverrides&&(e.configFile=this._options.configOverrides.configFile,e.reportSlowTests=this._options.configOverrides.reportSlowTests,e.quiet=this._options.configOverrides.quiet,e.reporter=[...this._options.configOverrides.reporter]),e}_parseProject(t){return{metadata:t.metadata,name:t.name,outputDir:this._absolutePath(t.outputDir),repeatEach:t.repeatEach,retries:t.retries,testDir:this._absolutePath(t.testDir),testIgnore:rt(t.testIgnore),testMatch:rt(t.testMatch),timeout:t.timeout,grep:rt(t.grep),grepInvert:rt(t.grepInvert),dependencies:t.dependencies,teardown:t.teardown,snapshotDir:this._absolutePath(t.snapshotDir),use:t.use}}_parseAttachments(t){return t.map(e=>({...e,body:e.base64&&globalThis.Buffer?Buffer.from(e.base64,"base64"):void 0}))}_mergeSuiteInto(t,e){let s=e.suites.find(i=>i.title===t.title);s||(s=new X(t.title,e.type==="project"?"file":"describe"),e._addSuite(s)),s.location=this._absoluteLocation(t.location),t.entries.forEach(i=>{"testId"in i?this._mergeTestInto(i,s):this._mergeSuiteInto(i,s)})}_mergeTestInto(t,e){let s=this._options.mergeTestCases?e.tests.find(i=>i.title===t.title&&i.repeatEachIndex===t.repeatEachIndex):void 0;s||(s=new ie(t.testId,t.title,this._absoluteLocation(t.location),t.repeatEachIndex),e._addTest(s),this._tests.set(s.id,s)),this._updateTest(t,s)}_updateTest(t,e){return e.id=t.testId,e.location=this._absoluteLocation(t.location),e.retries=t.retries,e.tags=t.tags??[],e.annotations=t.annotations??[],this._absoluteAnnotationLocationsInplace(e.annotations),e}_absoluteAnnotationLocationsInplace(t){for(const e of t)e.location&&(e.location=this._absoluteLocation(e.location))}_absoluteLocation(t){return t&&{...t,file:this._absolutePath(t.file)}}_absolutePath(t){if(t!==void 0)return this._options.resolvePath?this._options.resolvePath(this._rootDir,t):this._rootDir+"/"+t}}class X{constructor(t,e){this._entries=[],this._requireFile="",this._parallelMode="none",this.title=t,this._type=e}get type(){return this._type}get suites(){return this._entries.filter(t=>t.type!=="test")}get tests(){return this._entries.filter(t=>t.type==="test")}entries(){return this._entries}allTests(){const t=[],e=s=>{for(const i of s.entries())i.type==="test"?t.push(i):e(i)};return e(this),t}titlePath(){const t=this.parent?this.parent.titlePath():[];return(this.title||this._type!=="describe")&&t.push(this.title),t}project(){var t;return this._project??((t=this.parent)==null?void 0:t.project())}_addTest(t){t.parent=this,this._entries.push(t)}_addSuite(t){t.parent=this,this._entries.push(t)}}class ie{constructor(t,e,s,i){this.fn=()=>{},this.results=[],this.type="test",this.expectedStatus="passed",this.timeout=0,this.annotations=[],this.retries=0,this.tags=[],this.repeatEachIndex=0,this.id=t,this.title=e,this.location=s,this.repeatEachIndex=i}titlePath(){const t=this.parent?this.parent.titlePath():[];return t.push(this.title),t}outcome(){return ae(this)}ok(){const t=this.outcome();return t==="expected"||t==="flaky"||t==="skipped"}_createTestResult(t){const e=new re(this.results.length,t);return this.results.push(e),e}}class oe{constructor(t,e,s,i){this.duration=-1,this.steps=[],this._startTime=0,this.title=t.title,this.category=t.category,this.location=s,this.parent=e,this._startTime=t.startTime,this._result=i}titlePath(){var e;return[...((e=this.parent)==null?void 0:e.titlePath())||[],this.title]}get startTime(){return new Date(this._startTime)}set startTime(t){this._startTime=+t}get attachments(){var t,e;return((e=(t=this._endPayload)==null?void 0:t.attachments)==null?void 0:e.map(s=>this._result.attachments[s]))??[]}get annotations(){var t;return((t=this._endPayload)==null?void 0:t.annotations)??[]}}class re{constructor(t,e){this.parallelIndex=-1,this.workerIndex=-1,this.duration=-1,this.stdout=[],this.stderr=[],this.attachments=[],this.annotations=[],this.status="skipped",this.steps=[],this.errors=[],this._stepMap=new Map,this._startTime=0,this.retry=t,this._id=e}setStartTimeNumber(t){this._startTime=t}get startTime(){return new Date(this._startTime)}set startTime(t){this._startTime=+t}}const ne={forbidOnly:!1,fullyParallel:!1,globalSetup:null,globalTeardown:null,globalTimeout:0,grep:/.*/,grepInvert:null,maxFailures:0,metadata:{},preserveOutput:"always",projects:[],reporter:[[se.CI?"dot":"list"]],reportSlowTests:{max:5,threshold:3e5},configFile:"",rootDir:"",quiet:!1,shard:null,updateSnapshots:"missing",updateSourceMethod:"patch",version:"",workers:0,webServer:null};function rt(o){return o.map(t=>t.s!==void 0?t.s:new RegExp(t.r.source,t.r.flags))}function ae(o){let t=0,e=0,s=0;for(const i of o.results)i.status==="interrupted"||(i.status==="skipped"&&o.expectedStatus==="skipped"?++t:i.status==="skipped"||(i.status===o.expectedStatus?++e:++s));return e===0&&s===0?"skipped":s===0?"expected":e===0&&t===0?"unexpected":"flaky"}class ut{constructor(t,e,s,i,d,n){this._treeItemById=new Map,this._treeItemByTestId=new Map;const m=i&&[...i.values()].some(Boolean);this.pathSeparator=d,this.rootItem={kind:"group",subKind:"folder",id:t,title:"",location:{file:"",line:0,column:0},duration:0,parent:void 0,children:[],status:"none",hasLoadErrors:!1},this._treeItemById.set(t,this.rootItem);const c=(f,a,w,x)=>{for(const l of x==="tests"?[]:a.suites){if(!l.title){c(f,l,w,"all");continue}let T=w.children.find(_=>_.kind==="group"&&_.title===l.title);T||(T={kind:"group",subKind:"describe",id:"suite:"+a.titlePath().join("")+""+l.title,title:l.title,location:l.location,duration:0,parent:w,children:[],status:"none",hasLoadErrors:!1},this._addChild(w,T)),c(f,l,T,"all")}for(const l of x==="suites"?[]:a.tests){const T=l.title;let _=w.children.find(N=>N.kind!=="group"&&N.title===T);_||(_={kind:"case",id:"test:"+l.titlePath().join(""),title:T,parent:w,children:[],tests:[],location:l.location,duration:0,status:"none",project:void 0,test:void 0,tags:l.tags},this._addChild(w,_));const b=l.results[0];let R="none";(b==null?void 0:b[J])==="scheduled"?R="scheduled":(b==null?void 0:b[J])==="running"?R="running":(b==null?void 0:b.status)==="skipped"?R="skipped":(b==null?void 0:b.status)==="interrupted"?R="none":b&&l.outcome()!=="expected"?R="failed":b&&l.outcome()==="expected"&&(R="passed"),_.tests.push(l);const k={kind:"test",id:l.id,title:f.name,location:l.location,test:l,parent:_,children:[],status:R,duration:l.results.length?Math.max(0,l.results[0].duration):0,project:f};this._addChild(_,k),this._treeItemByTestId.set(l.id,k),_.duration=_.children.reduce((N,D)=>N+D.duration,0)}};for(const f of(e==null?void 0:e.suites)||[])if(!(m&&!i.get(f.title)))for(const a of f.suites)if(n){if(c(f.project(),a,this.rootItem,"suites"),a.tests.length){const w=this._defaultDescribeItem();c(f.project(),a,w,"tests")}}else{const w=this._fileItem(a.location.file.split(d),!0);c(f.project(),a,w,"all")}for(const f of s){if(!f.location)continue;const a=this._fileItem(f.location.file.split(d),!0);a.hasLoadErrors=!0}}_addChild(t,e){t.children.push(e),e.parent=t,this._treeItemById.set(e.id,e)}filterTree(t,e,s){const i=t.trim().toLowerCase().split(" "),d=[...e.values()].some(Boolean),n=c=>{const f=[...c.tests[0].titlePath(),...c.tests[0].tags].join(" ").toLowerCase();return!i.every(a=>f.includes(a))&&!c.tests.some(a=>s==null?void 0:s.has(a.id))?!1:(c.children=c.children.filter(a=>!d||(s==null?void 0:s.has(a.test.id))||e.get(a.status)),c.tests=c.children.map(a=>a.test),!!c.children.length)},m=c=>{const f=[];for(const a of c.children)a.kind==="case"?n(a)&&f.push(a):(m(a),(a.children.length||a.hasLoadErrors)&&f.push(a));c.children=f};m(this.rootItem)}_fileItem(t,e){if(t.length===0)return this.rootItem;const s=t.join(this.pathSeparator),i=this._treeItemById.get(s);if(i)return i;const d=this._fileItem(t.slice(0,t.length-1),!1),n={kind:"group",subKind:e?"file":"folder",id:s,title:t[t.length-1],location:{file:s,line:0,column:0},duration:0,parent:d,children:[],status:"none",hasLoadErrors:!1};return this._addChild(d,n),n}_defaultDescribeItem(){let t=this._treeItemById.get("<anonymous>");return t||(t={kind:"group",subKind:"describe",id:"<anonymous>",title:"<anonymous>",location:{file:"",line:0,column:0},duration:0,parent:this.rootItem,children:[],status:"none",hasLoadErrors:!1},this._addChild(this.rootItem,t)),t}sortAndPropagateStatus(){Tt(this.rootItem)}flattenForSingleProject(){const t=e=>{e.kind==="case"&&e.children.length===1?(e.project=e.children[0].project,e.test=e.children[0].test,e.children=[],this._treeItemByTestId.set(e.test.id,e)):e.children.forEach(t)};t(this.rootItem)}shortenRoot(){let t=this.rootItem;for(;t.children.length===1&&t.children[0].kind==="group"&&t.children[0].subKind==="folder";)t=t.children[0];t.location=this.rootItem.location,this.rootItem=t}testIds(){const t=new Set,e=s=>{s.kind==="case"&&s.tests.forEach(i=>t.add(i.id)),s.children.forEach(e)};return e(this.rootItem),t}fileNames(){const t=new Set,e=s=>{s.kind==="group"&&s.subKind==="file"?t.add(s.id):s.children.forEach(e)};return e(this.rootItem),[...t]}flatTreeItems(){const t=[],e=s=>{t.push(s),s.children.forEach(e)};return e(this.rootItem),t}treeItemById(t){return this._treeItemById.get(t)}collectTestIds(t){return t?le(t):new Set}}function Tt(o){for(const n of o.children)Tt(n);o.kind==="group"&&o.children.sort((n,m)=>n.location.file.localeCompare(m.location.file)||n.location.line-m.location.line);let t=o.children.length>0,e=o.children.length>0,s=!1,i=!1,d=!1;for(const n of o.children)e=e&&n.status==="skipped",t=t&&(n.status==="passed"||n.status==="skipped"),s=s||n.status==="failed",i=i||n.status==="running",d=d||n.status==="scheduled";i?o.status="running":d?o.status="scheduled":s?o.status="failed":e?o.status="skipped":t&&(o.status="passed")}function le(o){const t=new Set,e=s=>{var i;s.kind==="case"?s.tests.map(d=>d.id).forEach(d=>t.add(d)):s.kind==="test"?t.add(s.id):(i=s.children)==null||i.forEach(e)};return e(o),t}const J=Symbol("statusEx");class ce{constructor(t){this.loadErrors=[],this.progress={total:0,passed:0,failed:0,skipped:0},this._lastRunTestCount=0,this._receiver=new dt(this._createReporter(),{mergeProjects:!0,mergeTestCases:!0,resolvePath:(e,s)=>e+t.pathSeparator+s,clearPreviousResultsWhenTestBegins:!0}),this._options=t}_createReporter(){return{version:()=>"v2",onConfigure:t=>{this.config=t,this._lastRunReceiver=new dt({version:()=>"v2",onBegin:e=>{this._lastRunTestCount=e.allTests().length,this._lastRunReceiver=void 0}},{mergeProjects:!0,mergeTestCases:!1,resolvePath:(e,s)=>e+this._options.pathSeparator+s})},onBegin:t=>{var e;if(this.rootSuite||(this.rootSuite=t),this._testResultsSnapshot){for(const s of this.rootSuite.allTests())s.results=((e=this._testResultsSnapshot)==null?void 0:e.get(s.id))||s.results;this._testResultsSnapshot=void 0}this.progress.total=this._lastRunTestCount,this.progress.passed=0,this.progress.failed=0,this.progress.skipped=0,this._options.onUpdate(!0)},onEnd:()=>{this._options.onUpdate(!0)},onTestBegin:(t,e)=>{e[J]="running",this._options.onUpdate()},onTestEnd:(t,e)=>{t.outcome()==="skipped"?++this.progress.skipped:t.outcome()==="unexpected"?++this.progress.failed:++this.progress.passed,e[J]=e.status,this._options.onUpdate()},onError:t=>this._handleOnError(t),printsToStdio:()=>!1}}processGlobalReport(t){const e=new dt({version:()=>"v2",onConfigure:s=>{this.config=s},onError:s=>this._handleOnError(s)});for(const s of t)e.dispatch(s)}processListReport(t){var s;const e=((s=this.rootSuite)==null?void 0:s.allTests())||[];this._testResultsSnapshot=new Map(e.map(i=>[i.id,i.results])),this._receiver.reset();for(const i of t)this._receiver.dispatch(i)}processTestReportEvent(t){var e,s,i;(s=(e=this._lastRunReceiver)==null?void 0:e.dispatch(t))==null||s.catch(()=>{}),(i=this._receiver.dispatch(t))==null||i.catch(()=>{})}_handleOnError(t){var e,s;this.loadErrors.push(t),(s=(e=this._options).onError)==null||s.call(e,t),this._options.onUpdate()}asModel(){return{rootSuite:this.rootSuite||new X("","root"),config:this.config,loadErrors:this.loadErrors,progress:this.progress}}}const de=({source:o})=>{const[t,e]=At(),[s,i]=K.useState(Ut()),[d]=K.useState(Wt(()=>import("./assets/xtermModule-CsJ4vdCR.js"),__vite__mapDeps([0,1]),import.meta.url).then(m=>m.default)),n=K.useRef(null);return K.useEffect(()=>(zt(i),()=>Vt(i)),[]),K.useEffect(()=>{const m=o.write,c=o.clear;return(async()=>{const{Terminal:f,FitAddon:a}=await d,w=e.current;if(!w)return;const x=s==="dark-mode"?he:ue;if(n.current&&n.current.terminal.options.theme===x)return;n.current&&(w.textContent="");const l=new f({convertEol:!0,fontSize:13,scrollback:1e4,fontFamily:"monospace",theme:x}),T=new a;l.loadAddon(T);for(const _ of o.pending)l.write(_);o.write=(_=>{o.pending.push(_),l.write(_)}),o.clear=()=>{o.pending=[],l.clear()},l.open(w),T.fit(),n.current={terminal:l,fitAddon:T}})(),()=>{o.clear=c,o.write=m}},[d,n,e,o,s]),K.useEffect(()=>{setTimeout(()=>{n.current&&(n.current.fitAddon.fit(),o.resize(n.current.terminal.cols,n.current.terminal.rows))},250)},[t,o]),r.jsx("div",{"data-testid":"output",className:"xterm-wrapper",style:{flex:"auto"},ref:e})},ue={foreground:"#383a42",background:"#fafafa",cursor:"#383a42",black:"#000000",red:"#e45649",green:"#50a14f",yellow:"#c18401",blue:"#4078f2",magenta:"#a626a4",cyan:"#0184bc",white:"#a0a0a0",brightBlack:"#000000",brightRed:"#e06c75",brightGreen:"#98c379",brightYellow:"#d19a66",brightBlue:"#4078f2",brightMagenta:"#a626a4",brightCyan:"#0184bc",brightWhite:"#383a42",selectionBackground:"#d7d7d7",selectionForeground:"#383a42"},he={foreground:"#f8f8f2",background:"#1e1e1e",cursor:"#f8f8f0",black:"#000000",red:"#ff5555",green:"#50fa7b",yellow:"#f1fa8c",blue:"#bd93f9",magenta:"#ff79c6",cyan:"#8be9fd",white:"#bfbfbf",brightBlack:"#4d4d4d",brightRed:"#ff6e6e",brightGreen:"#69ff94",brightYellow:"#ffffa5",brightBlue:"#d6acff",brightMagenta:"#ff92df",brightCyan:"#a4ffff",brightWhite:"#e6e6e6",selectionBackground:"#44475a",selectionForeground:"#f8f8f2"},fe=({filterText:o,setFilterText:t,statusFilters:e,setStatusFilters:s,projectFilters:i,setProjectFilters:d,testModel:n,runTests:m})=>{const[c,f]=u.useState(!1),a=u.useRef(null);u.useEffect(()=>{var l;(l=a.current)==null||l.focus()},[]);const w=[...e.entries()].filter(([l,T])=>T).map(([l])=>l).join(" ")||"all",x=[...i.entries()].filter(([l,T])=>T).map(([l])=>l).join(" ")||"all";return r.jsxs("div",{className:"filters",children:[r.jsx(Kt,{expanded:c,setExpanded:f,title:r.jsx("input",{ref:a,type:"search",placeholder:"Filter (e.g. text, @tag)",spellCheck:!1,value:o,onChange:l=>{t(l.target.value)},onKeyDown:l=>{l.key==="Enter"&&m()}})}),r.jsxs("div",{className:"filter-summary",title:"Status: "+w+`
Projects: `+x,onClick:()=>f(!c),children:[r.jsx("span",{className:"filter-label",children:"Status:"})," ",w,r.jsx("span",{className:"filter-label",children:"Projects:"})," ",x]}),c&&r.jsxs("div",{className:"hbox",style:{marginLeft:14,maxHeight:200,overflowY:"auto"},children:[r.jsx("div",{className:"filter-list",role:"list","data-testid":"status-filters",children:[...e.entries()].map(([l,T])=>r.jsx("div",{className:"filter-entry",role:"listitem",children:r.jsxs("label",{children:[r.jsx("input",{type:"checkbox",checked:T,onChange:()=>{const _=new Map(e);_.set(l,!_.get(l)),s(_)}}),r.jsx("div",{children:l})]})},l))}),r.jsx("div",{className:"filter-list",role:"list","data-testid":"project-filters",children:[...i.entries()].map(([l,T])=>r.jsx("div",{className:"filter-entry",role:"listitem",children:r.jsxs("label",{children:[r.jsx("input",{type:"checkbox",checked:T,onChange:()=>{var R;const _=new Map(i);_.set(l,!_.get(l)),d(_);const b=(R=n==null?void 0:n.config)==null?void 0:R.configFile;b&&xt.setObject(b+":projects",[..._.entries()].filter(([k,N])=>N).map(([k])=>k))}}),r.jsx("div",{children:l||"untitled"})]})},l))})]})]})},pe=({tag:o,style:t,onClick:e})=>r.jsx("span",{className:ht("tag",`tag-color-${ge(o)}`),onClick:e,style:{margin:"6px 0 0 6px",...t},title:`Click to filter by tag: ${o}`,children:o});function ge(o){let t=0;for(let e=0;e<o.length;e++)t=o.charCodeAt(e)+((t<<8)-t);return Math.abs(t%6)}const me=Ht,_e=({filterText:o,testModel:t,testServerConnection:e,testTree:s,runTests:i,runningState:d,watchAll:n,watchedTreeIds:m,setWatchedTreeIds:c,isLoading:f,onItemSelected:a,requestedCollapseAllCount:w,requestedExpandAllCount:x,setFilterText:l,onRevealSource:T})=>{const[_,b]=u.useState({expandedItems:new Map}),[R,k]=u.useState(),[N,D]=u.useState(w),[$,L]=u.useState(x);u.useEffect(()=>{if(N!==w){_.expandedItems.clear();for(const S of s.flatTreeItems())_.expandedItems.set(S.id,!1);D(w),k(void 0),b({..._});return}if($!==x){_.expandedItems.clear();for(const S of s.flatTreeItems())_.expandedItems.set(S.id,!0);L(x),k(void 0),b({..._});return}if(!d||d.itemSelectedByUser)return;let h;const E=S=>{var M;S.children.forEach(E),!h&&S.status==="failed"&&(S.kind==="test"&&d.testIds.has(S.test.id)||S.kind==="case"&&d.testIds.has((M=S.tests[0])==null?void 0:M.id))&&(h=S)};E(s.rootItem),h&&k(h.id)},[d,k,s,N,D,w,$,L,x,_,b]);const C=u.useMemo(()=>{if(R)return s.treeItemById(R)},[R,s]);u.useEffect(()=>{if(!t)return;const h=ve(C,t);let E;(C==null?void 0:C.kind)==="test"?E=C.test:(C==null?void 0:C.kind)==="case"&&C.tests.length===1&&(E=C.tests[0]),a({treeItem:C,testCase:E,testFile:h})},[t,C,a]),u.useEffect(()=>{if(!f)if(n)e==null||e.watchNoReply({fileNames:s.fileNames()});else{const h=new Set;for(const E of m.value){const S=s.treeItemById(E),M=S==null?void 0:S.location.file;M&&h.add(M)}e==null||e.watchNoReply({fileNames:[...h]})}},[f,s,n,m,e]);const Z=h=>{k(h.id),i("bounce-if-busy",s.collectTestIds(h))},q=(h,E)=>{if(h.preventDefault(),h.stopPropagation(),h.metaKey||h.ctrlKey){const S=o.split(" ");S.includes(E)?l(S.filter(M=>M!==E).join(" ").trim()):l((o+" "+E).trim())}else l((o.split(" ").filter(S=>!S.startsWith("@")).join(" ")+" "+E).trim())};return r.jsx(me,{name:"tests",treeState:_,setTreeState:b,rootItem:s.rootItem,dataTestId:"test-tree",render:h=>{const E=h.id.replace(/[^\w\d-_]/g,"-"),S=E+"-label",M=E+"-time";return r.jsxs("div",{className:"hbox ui-mode-tree-item","aria-labelledby":`${S} ${M}`,children:[r.jsxs("div",{id:S,className:"ui-mode-tree-item-title",children:[r.jsx("span",{children:h.title}),h.kind==="case"?h.tags.map(Y=>r.jsx(pe,{tag:Y.slice(1),onClick:G=>q(G,Y)},Y)):null]}),!!h.duration&&h.status!=="skipped"&&r.jsx("div",{id:M,className:"ui-mode-tree-item-time",children:qt(h.duration)}),r.jsxs(H,{noMinHeight:!0,noShadow:!0,children:[r.jsx(O,{icon:"play",title:"Run",onClick:()=>Z(h),disabled:!!d&&!d.completed}),r.jsx(O,{icon:"go-to-file",title:"Show source",onClick:T,style:h.kind==="group"&&h.subKind==="folder"?{visibility:"hidden"}:{}}),!n&&r.jsx(O,{icon:"eye",title:"Watch",onClick:()=>{m.value.has(h.id)?m.value.delete(h.id):m.value.add(h.id),c({...m})},toggled:m.value.has(h.id)})]})]})},icon:h=>$t(h.status),title:h=>h.title,selectedItem:C,onAccepted:Z,onSelected:h=>{d&&(d.itemSelectedByUser=!0),k(h.id)},isError:h=>h.kind==="group"?h.hasLoadErrors:!1,autoExpandDepth:o?5:1,noItemsMessage:f?"Loading…":"No tests"})};function ve(o,t){if(!(!o||!t))return{file:o.location.file,line:o.location.line,column:o.location.column,source:{errors:t.loadErrors.filter(e=>{var s;return((s=e.location)==null?void 0:s.file)===o.location.file}).map(e=>({line:e.location.line,message:e.message})),content:void 0}}}function we(o){return`.playwright-artifacts-${o}`}const be=({item:o,rootDir:t,onOpenExternally:e,revealSource:s,pathSeparator:i})=>{var w,x;const[d,n]=u.useState(void 0),[m,c]=u.useState(0),f=u.useRef(null),{outputDir:a}=u.useMemo(()=>({outputDir:o.testCase?xe(o.testCase):void 0}),[o]);return u.useEffect(()=>{var b,R;f.current&&clearTimeout(f.current);const l=(b=o.testCase)==null?void 0:b.results[0];if(!l){n(void 0);return}const T=l&&l.duration>=0&&l.attachments.find(k=>k.name==="trace");if(T&&T.path){vt(T.path).then(k=>n({model:k,isLive:!1}));return}if(!a){n(void 0);return}const _=[a,we(l.workerIndex),"traces",`${(R=o.testCase)==null?void 0:R.id}.json`].join(i);return f.current=setTimeout(async()=>{try{const k=await vt(_);n({model:k,isLive:!0})}catch{const k=new St([]);k.errorDescriptors.push(...l.errors.flatMap(N=>N.message?[{message:N.message}]:[])),n({model:k,isLive:!1})}finally{c(m+1)}},500),()=>{f.current&&clearTimeout(f.current)}},[a,o,n,m,c,i]),r.jsx(Yt,{model:d==null?void 0:d.model,showSourcesFirst:!0,rootDir:t,fallbackLocation:o.testFile,isLive:d==null?void 0:d.isLive,status:(w=o.treeItem)==null?void 0:w.status,annotations:((x=o.testCase)==null?void 0:x.annotations)??[],onOpenExternally:e,revealSource:s},"workbench")},xe=o=>{var t;for(let e=o.parent;e;e=e.parent)if(e.project())return(t=e.project())==null?void 0:t.outputDir};async function vt(o){const t=new URLSearchParams;t.set("trace",o),t.set("limit","1");const s=await(await fetch(`contexts?${t.toString()}`)).json();return new St(s)}let wt={cols:80};const z={pending:[],clear:()=>{},write:o=>z.pending.push(o),resize:()=>{}},A=new URLSearchParams(window.location.search),Se=new URL(A.get("server")??"../",window.location.href),ft=new URL(A.get("ws"),Se);ft.protocol=ft.protocol==="https:"?"wss:":"ws:";const B={args:A.getAll("arg"),grep:A.get("grep")||void 0,grepInvert:A.get("grepInvert")||void 0,projects:A.getAll("project"),workers:A.get("workers")||void 0,headed:A.has("headed"),updateSnapshots:A.get("updateSnapshots")||void 0,reporters:A.has("reporter")?A.getAll("reporter"):void 0,pathSeparator:A.get("pathSeparator")||"/"};B.updateSnapshots&&!["all","changed","none","missing"].includes(B.updateSnapshots)&&(B.updateSnapshots=void 0);const bt=navigator.platform==="MacIntel",Te=({})=>{var _t;const[o,t]=u.useState(""),[e,s]=u.useState(!1),[i,d]=u.useState(!1),[n,m]=u.useState(new Map([["passed",!1],["failed",!1],["skipped",!1]])),[c,f]=u.useState(new Map),[a,w]=u.useState(),[x,l]=u.useState(),[T,_]=u.useState({}),[b,R]=u.useState(new Set),[k,N]=u.useState(!1),[D,$]=u.useState(),L=D&&!D.completed,[C,Z]=ot("watch-all",!1),[q,h]=u.useState({value:new Set}),E=u.useRef(Promise.resolve()),S=u.useRef(new Set),[M,Y]=u.useState(0),[G,kt]=u.useState(0),[jt,yt]=u.useState(!1),[pt,gt]=u.useState(!0),[v,Et]=u.useState(),[tt,It]=u.useState(),[et,Rt]=u.useState(!1),[st,Bt]=u.useState(!1),[Ct,mt]=u.useState(!1),Nt=u.useCallback(()=>mt(!0),[mt]),[nt,Pt]=ot("single-worker",!1),[at,Lt]=ot("updateSnapshots","missing"),[Q]=ot("mergeFiles",!1),Dt=u.useRef(null),it=u.useCallback(()=>{Et(p=>(p==null||p.close(),new Qt(new Xt(ft))))},[]);u.useEffect(()=>{var p;(p=Dt.current)==null||p.focus(),N(!0),it()},[it]),u.useEffect(()=>{if(!v)return;const p=[v.onStdio(g=>{if(g.buffer){const j=atob(g.buffer);z.write(j)}else z.write(g.text);g.type==="stderr"&&d(!0)}),v.onClose(()=>yt(!0))];return z.resize=(g,j)=>{wt={cols:g,rows:j},v.resizeTerminalNoReply({cols:g,rows:j})},()=>{for(const g of p)g.dispose()}},[v]),u.useEffect(()=>{if(!v)return;let p;const g=new ce({onUpdate:j=>{clearTimeout(p),p=void 0,j?w(g.asModel()):p||(p=setTimeout(()=>{w(g.asModel())},250))},onError:j=>{z.write((j.stack||j.value||"")+`
`),d(!0)},pathSeparator:B.pathSeparator});return It(g),w(void 0),N(!0),h({value:new Set}),(async()=>{try{await v.initialize({interceptStdio:!0,watchTestDirs:!0});const{status:j,report:I}=await v.runGlobalSetup({});if(g.processGlobalReport(I),j!=="passed")return;const P=await v.listTests({projects:B.projects,locations:B.args,grep:B.grep,grepInvert:B.grepInvert});g.processListReport(P.report),v.onReport(F=>{g.processTestReportEvent(F)});const{hasBrowsers:U}=await v.checkBrowsers({});gt(U)}finally{N(!1)}})(),()=>{clearTimeout(p)}},[v]),u.useEffect(()=>{if(!a)return;const{config:p,rootSuite:g}=a,j=p.configFile?xt.getObject(p.configFile+":projects",void 0):void 0,I=new Map(c);for(const P of I.keys())g.suites.find(U=>U.title===P)||I.delete(P);for(const P of g.suites)I.has(P.title)||I.set(P.title,!!(j!=null&&j.includes(P.title)));!j&&I.size&&![...I.values()].includes(!0)&&I.set(I.entries().next().value[0],!0),(c.size!==I.size||[...c].some(([P,U])=>I.get(P)!==U))&&f(I)},[c,a]),u.useEffect(()=>{L&&(a!=null&&a.progress)?l(a.progress):a||l(void 0)},[a,L]);const{testTree:Mt}=u.useMemo(()=>{if(!a)return{testTree:new ut("",new X("","root"),[],c,B.pathSeparator,Q)};const p=new ut("",a.rootSuite,a.loadErrors,c,B.pathSeparator,Q);return p.filterTree(o,n,L?D==null?void 0:D.testIds:void 0),p.sortAndPropagateStatus(),p.shortenRoot(),p.flattenForSingleProject(),R(p.testIds()),{testTree:p}},[o,a,n,c,R,D,L,Q]),V=u.useCallback((p,g)=>{!v||!a||p==="bounce-if-busy"&&L||(S.current=new Set([...S.current,...g]),E.current=E.current.then(async()=>{var P,U,F;const j=S.current;if(S.current=new Set,!j.size)return;{for(const y of((P=a.rootSuite)==null?void 0:P.allTests())||[])if(j.has(y.id)){y.results=[];const W=y._createTestResult("pending");W[J]="scheduled"}w({...a})}const I=" ["+new Date().toLocaleTimeString()+"]";z.write("\x1B[2m—".repeat(Math.max(0,wt.cols-I.length))+I+"\x1B[22m"),l({total:0,passed:0,failed:0,skipped:0}),$({testIds:j}),await v.runTests({locations:B.args,grep:B.grep,grepInvert:B.grepInvert,testIds:[...j],projects:[...c].filter(([y,W])=>W).map(([y])=>y),updateSnapshots:at,reporters:B.reporters,workers:nt?1:void 0,trace:"on"});for(const y of((U=a.rootSuite)==null?void 0:U.allTests())||[])((F=y.results[0])==null?void 0:F.duration)===-1&&(y.results=[]);w({...a}),$(y=>y?{...y,completed:!0}:void 0)}))},[c,L,a,v,at,nt]);u.useEffect(()=>{if(!v||!tt)return;const p=v.onTestFilesChanged(async g=>{if(E.current=E.current.then(async()=>{N(!0);try{const F=await v.listTests({projects:B.projects,locations:B.args,grep:B.grep,grepInvert:B.grepInvert});tt.processListReport(F.report)}catch(F){console.log(F)}finally{N(!1)}}),await E.current,g.testFiles.length===0)return;const j=tt.asModel(),I=new ut("",j.rootSuite,j.loadErrors,c,B.pathSeparator,Q),P=[],U=new Set(g.testFiles);if(C){const F=y=>{const W=y.location.file;W&&U.has(W)&&P.push(...I.collectTestIds(y)),y.kind==="group"&&y.subKind==="folder"&&y.children.forEach(F)};F(I.rootItem)}else for(const F of q.value){const y=I.treeItemById(F),W=y==null?void 0:y.location.file;W&&U.has(W)&&P.push(...I.collectTestIds(y))}V("queue-if-busy",new Set(P))});return()=>p.dispose()},[V,v,C,q,tt,c,Q]),u.useEffect(()=>{if(!v)return;const p=g=>{g.code==="Backquote"&&g.ctrlKey?(g.preventDefault(),s(!e)):g.code==="F5"&&g.shiftKey?(g.preventDefault(),v==null||v.stopTestsNoReply({})):g.code==="F5"&&(g.preventDefault(),V("bounce-if-busy",b))};return addEventListener("keydown",p),()=>{removeEventListener("keydown",p)}},[V,it,v,b,e]);const lt=u.useRef(null),Ft=u.useCallback(p=>{var g;p.preventDefault(),p.stopPropagation(),(g=lt.current)==null||g.showModal()},[]),ct=u.useCallback(p=>{var g;p.preventDefault(),p.stopPropagation(),(g=lt.current)==null||g.close()},[]),Ot=u.useCallback(p=>{ct(p),s(!0),v==null||v.installBrowsers({}).then(async()=>{s(!1);const{hasBrowsers:g}=await(v==null?void 0:v.checkBrowsers({}));gt(g)})},[ct,v]);return r.jsxs("div",{className:"vbox ui-mode",children:[!pt&&r.jsxs("dialog",{ref:lt,children:[r.jsxs("div",{className:"title",children:[r.jsx("span",{className:"codicon codicon-lightbulb"}),"Install browsers"]}),r.jsxs("div",{className:"body",children:["Playwright did not find installed browsers.",r.jsx("br",{}),"Would you like to run `playwright install`?",r.jsx("br",{}),r.jsx("button",{className:"button",onClick:Ot,children:"Install"}),r.jsx("button",{className:"button secondary",onClick:ct,children:"Dismiss"})]})]}),jt&&r.jsxs("div",{className:"disconnected",children:[r.jsx("div",{className:"title",children:"UI Mode disconnected"}),r.jsxs("div",{children:[r.jsx("a",{href:"#",onClick:()=>window.location.href="/",children:"Reload the page"})," to reconnect"]})]}),r.jsx(Jt,{sidebarSize:250,minSidebarSize:150,orientation:"horizontal",sidebarIsFirst:!0,settingName:"testListSidebar",main:r.jsxs("div",{className:"vbox",children:[r.jsxs("div",{className:ht("vbox",!e&&"hidden"),children:[r.jsxs(H,{children:[r.jsx("div",{className:"section-title",style:{flex:"none"},children:"Output"}),r.jsx(O,{icon:"circle-slash",title:"Clear output",onClick:()=>{z.clear(),d(!1)}}),r.jsx("div",{className:"spacer"}),r.jsx(O,{icon:"close",title:"Close",onClick:()=>s(!1)})]}),r.jsx(de,{source:z})]}),r.jsx("div",{className:ht("vbox",e&&"hidden"),children:r.jsx(be,{pathSeparator:B.pathSeparator,item:T,rootDir:(_t=a==null?void 0:a.config)==null?void 0:_t.rootDir,revealSource:Ct,onOpenExternally:p=>v==null?void 0:v.openNoReply({location:{file:p.file,line:p.line,column:p.column}})})})]}),sidebar:r.jsxs("div",{className:"vbox ui-mode-sidebar",children:[r.jsxs(H,{noShadow:!0,noMinHeight:!0,children:[r.jsx("img",{src:"playwright-logo.svg",alt:"Playwright logo"}),r.jsx("div",{className:"section-title",children:"Playwright"}),r.jsx(O,{icon:"refresh",title:"Reload",onClick:()=>it(),disabled:L||k}),r.jsxs("div",{style:{position:"relative"},children:[r.jsx(O,{icon:"terminal",title:"Toggle output — "+(bt?"⌃`":"Ctrl + `"),toggled:e,onClick:()=>{s(!e)}}),i&&r.jsx("div",{title:"Output contains error",style:{position:"absolute",top:2,right:2,width:7,height:7,borderRadius:"50%",backgroundColor:"var(--vscode-notificationsErrorIcon-foreground)"}})]}),!pt&&r.jsx(O,{icon:"lightbulb-autofix",style:{color:"var(--vscode-list-warningForeground)"},title:"Playwright browsers are missing",onClick:Ft})]}),r.jsx(fe,{filterText:o,setFilterText:t,statusFilters:n,setStatusFilters:m,projectFilters:c,setProjectFilters:f,testModel:a,runTests:()=>V("bounce-if-busy",b)}),r.jsxs(H,{className:"section-toolbar",noMinHeight:!0,children:[!L&&!x&&r.jsx("div",{className:"section-title",children:"Tests"}),!L&&x&&r.jsx("div",{"data-testid":"status-line",className:"status-line",children:r.jsxs("div",{children:[x.passed,"/",x.total," passed (",x.passed/x.total*100|0,"%)"]})}),L&&x&&r.jsx("div",{"data-testid":"status-line",className:"status-line",children:r.jsxs("div",{children:["Running ",x.passed,"/",D.testIds.size," passed (",x.passed/D.testIds.size*100|0,"%)"]})}),r.jsx(O,{icon:"play",title:"Run all — F5",onClick:()=>V("bounce-if-busy",b),disabled:L||k}),r.jsx(O,{icon:"debug-stop",title:"Stop — "+(bt?"⇧F5":"Shift + F5"),onClick:()=>v==null?void 0:v.stopTests({}),disabled:!L||k}),r.jsx(O,{icon:"eye",title:"Watch all",toggled:C,onClick:()=>{h({value:new Set}),Z(!C)}}),r.jsx(O,{icon:"collapse-all",title:"Collapse all",onClick:()=>{Y(M+1)}}),r.jsx(O,{icon:"expand-all",title:"Expand all",onClick:()=>{kt(G+1)}})]}),r.jsx(_e,{filterText:o,testModel:a,testTree:Mt,testServerConnection:v,runningState:D,runTests:V,onItemSelected:_,watchAll:C,watchedTreeIds:q,setWatchedTreeIds:h,isLoading:k,requestedCollapseAllCount:M,requestedExpandAllCount:G,setFilterText:t,onRevealSource:Nt}),r.jsxs(H,{noShadow:!0,noMinHeight:!0,className:"settings-toolbar",onClick:()=>Bt(!st),children:[r.jsx("span",{className:`codicon codicon-${st?"chevron-down":"chevron-right"}`,style:{marginLeft:5},title:st?"Hide Testing Options":"Show Testing Options"}),r.jsx("div",{className:"section-title",children:"Testing Options"})]}),st&&r.jsx(Zt,{settings:[{type:"check",value:nt,set:Pt,name:"Single worker"},{type:"select",options:[{label:"All",value:"all"},{label:"Changed",value:"changed"},{label:"Missing",value:"missing"},{label:"None",value:"none"}],value:at,set:Lt,name:"Update snapshots"}]}),r.jsxs(H,{noShadow:!0,noMinHeight:!0,className:"settings-toolbar",onClick:()=>Rt(!et),children:[r.jsx("span",{className:`codicon codicon-${et?"chevron-down":"chevron-right"}`,style:{marginLeft:5},title:et?"Hide Settings":"Show Settings"}),r.jsx("div",{className:"section-title",children:"Settings"})]}),et&&r.jsx(Gt,{})]})})]})};(async()=>{if(te(),window.location.protocol!=="file:"){if(window.location.href.includes("isUnderTest=true")&&await new Promise(o=>setTimeout(o,1e3)),!navigator.serviceWorker)throw new Error(`Service workers are not supported.
Make sure to serve the website (${window.location}) via HTTPS or localhost.`);navigator.serviceWorker.register("sw.bundle.js"),navigator.serviceWorker.controller||await new Promise(o=>{navigator.serviceWorker.oncontrollerchange=()=>o()}),setInterval(function(){fetch("ping")},1e4)}ee.createRoot(document.querySelector("#root")).render(r.jsx(Te,{}))})();