@ctrl/dom 0.1.15 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/bridge/internal.js +1 -1
- package/dist/dom/_chunks/src-CaVKwScX.js +49 -0
- package/dist/dom/index.js +1 -1
- package/dist/dom/internal.js +1 -1
- package/dist/dom/types/css/cascade.d.ts +10 -3
- package/dist/dom/types/css/cssom.d.ts +9 -3
- package/dist/dom/types/css/parser.d.ts +27 -0
- package/dist/dom/types/css/style-deps.d.ts +11 -0
- package/dist/dom/types/events/listeners.d.ts +24 -2
- package/dist/dom/types/html/elements.d.ts +3 -2
- package/dist/dom/types/html/forms/HTMLButtonElement.d.ts +4 -3
- package/dist/dom/types/html/forms/HTMLFieldSetElement.d.ts +3 -2
- package/dist/dom/types/html/forms/HTMLInputElement.d.ts +11 -36
- package/dist/dom/types/html/forms/HTMLOutputElement.d.ts +6 -5
- package/dist/dom/types/html/forms/HTMLSelectElement.d.ts +6 -5
- package/dist/dom/types/html/forms/HTMLTextAreaElement.d.ts +10 -15
- package/dist/dom/types/html/forms/control-state.d.ts +33 -0
- package/dist/dom/types/html/forms/face.d.ts +3 -2
- package/dist/dom/types/html/forms/form-associated.d.ts +15 -3
- package/dist/dom/types/html/forms/user-validity.d.ts +2 -2
- package/dist/dom/types/html/forms/validation.d.ts +2 -2
- package/dist/dom/types/internal.d.ts +3 -2
- package/dist/dom/types/keys.d.ts +9 -16
- package/dist/dom/types/nodes/Document.d.ts +6 -2
- package/dist/dom/types/nodes/attributes.d.ts +1 -1
- package/dist/dom/types/nodes/cache.d.ts +1 -1
- package/dist/dom/types/nodes/constants.d.ts +5 -0
- package/dist/dom/types/selectors/compile.d.ts +8 -0
- package/dist/dom/types/selectors/internal.d.ts +3 -1
- package/dist/dom/types/window/clock.d.ts +30 -0
- package/dist/dom/types/window/file-reset.d.ts +22 -0
- package/dist/jest-dom/_chunks/{matchers-CkxM783o.cjs → matchers-CZ6Smfw9.cjs} +2 -2
- package/dist/jest-dom/_chunks/{matchers-Dt7W4g5X.js → matchers-CwGF61j-.js} +2 -2
- package/dist/jest-dom/index.cjs +1 -1
- package/dist/jest-dom/index.js +1 -1
- package/dist/jest-dom/jest-globals.cjs +1 -1
- package/dist/jest-dom/jest-globals.js +1 -1
- package/dist/jest-dom/matchers.cjs +1 -1
- package/dist/jest-dom/matchers.js +1 -1
- package/dist/jest-dom/vitest.cjs +1 -1
- package/dist/jest-dom/vitest.js +1 -1
- package/dist/react/_chunks/pure-CYb0HgYU.js +1 -0
- package/dist/react/_chunks/pure-DRugbA0j.cjs +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/pure.cjs +1 -1
- package/dist/react/pure.js +1 -1
- package/dist/testing-library/index.cjs +2 -2
- package/dist/testing-library/index.js +7 -7
- package/dist/user-event/index.cjs +15 -15
- package/dist/user-event/index.js +15 -15
- package/dist/user-event/types/ctrl-dom.d.ts +8 -0
- package/dist/vitest-environment/_chunks/rolldown-runtime-H3fMLYWS.js +1 -0
- package/dist/vitest-environment/failure-snapshot.js +1 -1
- package/dist/vitest-environment/index.js +1 -1
- package/dist/vitest-environment/jsx-dev-runtime.js +1 -0
- package/dist/vitest-environment/jsx-runtime.js +1 -0
- package/dist/vitest-environment/plugin.js +1 -1
- package/dist/vitest-environment/shared-workers.js +1 -0
- package/dist/vitest-environment/types/jsx-dev-runtime.d.ts +3 -0
- package/dist/vitest-environment/types/jsx-runtime.d.ts +4 -0
- package/dist/vitest-environment/types/plugin.d.ts +19 -0
- package/dist/vitest-environment/types/shared-workers.d.ts +1 -0
- package/package.json +13 -1
- package/dist/dom/_chunks/src-C4oa-U7z.js +0 -49
- package/dist/react/_chunks/pure-D7Z4g4oF.js +0 -1
- package/dist/react/_chunks/pure-DOgNQrwu.cjs +0 -1
- package/dist/vitest-environment/_chunks/rolldown-runtime-BhWHdk3m.js +0 -1
package/dist/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./_chunks/pure-
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./_chunks/pure-CYb0HgYU.js";import{registerTestHooks as f}from"@ctrl/dom/internal";export*from"@ctrl/dom/testing-library";if(r(/* @__PURE__ */ n({act:()=>s,cleanup:()=>u,configure:()=>a,fireEvent:()=>e,getConfig:()=>d,render:()=>c,renderHook:()=>i}),o),(typeof process>`u`||!process.env?.RTL_SKIP_AUTO_CLEANUP)&&(typeof afterEach==`function`?(afterEach(()=>{u()}),f(`react`,{afterEach:u})):typeof teardown==`function`&&teardown(()=>{u()}),typeof beforeAll==`function`&&typeof afterAll==`function`)){let e=l(),enterActEnvironment=()=>{e=l(),t(!0)},leaveActEnvironment=()=>{t(e)};beforeAll(enterActEnvironment),afterAll(leaveActEnvironment),f(`react`,{beforeAll:enterActEnvironment,afterAll:leaveActEnvironment})}export{s as act,u as cleanup,a as configure,e as fireEvent,d as getConfig,c as render,i as renderHook};
|
package/dist/react/pure.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/pure-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/pure-DRugbA0j.cjs");exports.act=e.o,exports.cleanup=e.t,exports.configure=e.l,exports.fireEvent=e.a,exports.getConfig=e.u,exports.render=e.r,exports.renderHook=e.i;var t=require("@ctrl/dom/testing-library");Object.keys(t).forEach(function(e){e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})});
|
package/dist/react/pure.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{o as act,t as cleanup,l as configure,a as fireEvent,u as getConfig,r as render,i as renderHook}from"./_chunks/pure-
|
|
1
|
+
export{o as act,t as cleanup,l as configure,a as fireEvent,u as getConfig,r as render,i as renderHook}from"./_chunks/pure-CYb0HgYU.js";export*from"@ctrl/dom/testing-library";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/aria-snapshot-diff-BXYf4D_D.cjs");let t=require("@ctrl/dom/internal"),n=require("@ctrl/dom/aria"),r=require("@ctrl/dom/aria/internal"),i=require("node:async_hooks");function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/aria-snapshot-diff-BXYf4D_D.cjs");let t=require("@ctrl/dom/internal"),n=require("@ctrl/dom/aria"),r=require("@ctrl/dom/aria/internal"),i=require("node:async_hooks");function isLabelledNodeName(e){if(e.prefix!==null)return!1;switch((0,t.asciiLowercase)(e.name)){case`button`:case`meter`:case`output`:case`progress`:case`select`:case`textarea`:case`input`:return!0}return!1}function buildIdMap(e,n){let r=/* @__PURE__ */ new Map;n&&e.type===t.ELEMENT_NODE&&e.id!==``&&r.set(e.id,e);for(let n=e.first;n!==null;n=(0,t.nextInTree)(n,e))n.type===t.ELEMENT_NODE&&n.id!==``&&!r.has(n.id)&&r.set(n.id,n);return r}var LabelContext=class{container;containerIds;sameTree;labelMap;constructor(e,t=!1){this.container=e,this.containerIds=null,this.sameTree=t,this.labelMap=null}labelsOf(e){return this.sameTree?(this.labelMap??=(0,r.labelMapForTree)(this.container)).get(e)??a:(0,r.labelsOf)(e)??a}byIdInContainer(e){let t=this.containerIds;return t===null&&(t=this.containerIds=buildIdMap(this.container,!1)),t.get(e)??null}};const a=[];function getTextContent(e){if(e.type===t.ELEMENT_NODE&&isLabelledNodeName(e))return``;if(e.type===t.TEXT_NODE)return e.data;let n=``;for(let t=e.first;t!==null;t=t.next)n+=getTextContent(t);return n}function getLabelContentImpl(e){if(e.tag===t.T.label&&e.ns===t.HTML_NS)return getTextContent(e);let n=e.node;return n.value||n.textContent}const o=/* @__PURE__ */ new Set([`button`,`input`,`meter`,`output`,`progress`,`select`,`textarea`]);function labelledFormControl(n,r){for(let i=n.first;i!==null;i=(0,t.nextInTree)(i,n))if(i.type===t.ELEMENT_NODE&&o.has(i.name)&&(r===`*`||e.T(i,r)))return i}function getLabelsImpl(e,n,r=`*`){let i=(0,t.ariaAttr)(n,`aria-labelledby`),a=i?i.split(` `):[];return a.length?a.map(t=>{let n=e.byIdInContainer(t);return n?{content:getLabelContentImpl(n),formControl:null}:{content:``,formControl:null}}):e.labelsOf(n).map(e=>({content:getLabelContentImpl(e),formControl:labelledFormControl(e,r)}))}function assertNotNullOrUndefined(e){if(e==null)throw Error(`It looks like ${e} was passed instead of a matcher. Did you do something like getByText(${e})?`)}function fuzzyMatches(e,t,n,r){if(typeof e!=`string`)return!1;assertNotNullOrUndefined(n);let i=r(e);return typeof n==`string`||typeof n==`number`?i.toLowerCase().includes(n.toString().toLowerCase()):typeof n==`function`?n(i,t):matchRegExp(n,i)}function matches(e,t,n,r){if(typeof e!=`string`)return!1;assertNotNullOrUndefined(n);let i=r(e);return n instanceof Function?n(i,t):n instanceof RegExp?matchRegExp(n,i):i===String(n)}function isRegExpWhitespace(e){return e<=32?e===32||e>=9&&e<=13:e<160?!1:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function changedByNormalizing(e,t,n){let r=e.length-1,i=!1;for(let a=0;a<=r;a++){let o=e.charCodeAt(a),s=isRegExpWhitespace(o);if(s&&(t&&(a===0||a===r)||n&&(i||o!==32)))return!0;i=s}return!1}const s=/\s+/g;function getDefaultNormalizer({trim:e=!0,collapseWhitespace:t=!0}={}){return n=>{if(!changedByNormalizing(n,e,t))return n;let r=n;return r=e?r.trim():r,r=t?r.replace(s,` `):r,r}}const c=getDefaultNormalizer();function textMatcher(e,t,n){if(!e)return(e,r)=>fuzzyMatches(e,r,t,n);if(n!==c||typeof t!=`string`&&typeof t!=`number`)return(e,r)=>matches(e,r,t,n);let r=String(t);if(changedByNormalizing(r,!0,!0))return()=>!1;let i=r.length,a=r.charCodeAt(0),o=r.charCodeAt(i-1);return e=>{if(typeof e!=`string`||e.length<i)return!1;if(i!==0){let t=e.charCodeAt(0);if(t!==a&&!isRegExpWhitespace(t))return!1;let n=e.charCodeAt(e.length-1);if(n!==o&&!isRegExpWhitespace(n))return!1}return c(e)===r}}function makeNormalizer({trim:e,collapseWhitespace:t,normalizer:n}){if(!n)return e===void 0&&t===void 0?c:getDefaultNormalizer({trim:e,collapseWhitespace:t});if(e!==void 0||t!==void 0)throw Error(`trim and collapseWhitespace are not supported with a normalizer. If you want to use the default trim and collapseWhitespace logic in your normalizer, use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer`);return n}function matchRegExp(e,t){let n=e.test(t);return e.global&&e.lastIndex!==0&&(console.warn(`To match all elements we had to reset the lastIndex of the RegExp because the global flag is enabled. We encourage to remove the global flag from the RegExp.`),e.lastIndex=0),n}function isButtonLikeInput(e){if(e.tag!==t.T.input||e.ns!==t.HTML_NS)return!1;let n=(0,t.attr)(e,`type`);if(n===null)return!1;let r=(0,t.asciiLowercase)(n);return r===`submit`||r===`button`||r===`reset`}function getNodeTextImpl(e){if(isButtonLikeInput(e))return e.node.value;let n=``;for(let r=e.first;r!==null;r=r.next)r.type===t.TEXT_NODE&&(n+=r.data);return n}function getNodeText(n){let r=e.A(n);return r.type===t.ELEMENT_NODE?getNodeTextImpl(r):n.matches(`input[type=submit], input[type=button], input[type=reset]`)}const l={computedStyleSupportsPseudoElements:!0};function styleOverride(e){return(0,t.getComputedStyleOverride)(e)}function nameOptions(e,t){return t===null?e?l:void 0:{computedStyleSupportsPseudoElements:e,getComputedStyle:t}}const u={implicitRole(e){let t=(0,r.implicitRole)(e);return t===``?null:t},roleMatches:r.tlRoleMatches,roleSupportsProp(e,t){return typeof e==`string`&&(0,n.roleSupportsProp)(e,t)},computeAccessibleName(e,t,n){return(0,r.computeAccessibleNameImpl)(e,nameOptions(t,n),5)},computeAccessibleDescription(e,t,n){return(0,r.computeAccessibleDescriptionImpl)(e,nameOptions(t,n),5)},isInaccessible:r.isInaccessibleImpl,isInaccessibleWithStyle:r.isInaccessibleWithStyle,isSubtreeInaccessible:r.isSubtreeInaccessibleImpl};function parentElement(e){let n=e.parent;return n!==null&&n.type===t.ELEMENT_NODE?n:null}function isInaccessibleImpl$1(e){return u.isInaccessible(e)}e.N(isInaccessibleImpl$1,`isInaccessibleImpl`);function isInaccessibleChecked(e){let t=styleOverride(e);return t===null?u.isInaccessible(e):u.isInaccessibleWithStyle(e,t,null)}function isInaccessible(t,n={}){let i=e.A(t),a=n.isSubtreeInaccessible,o=styleOverride(i);if(a===void 0)return o===null?isInaccessibleImpl$1(i):u.isInaccessibleWithStyle(i,o,null);if(o===null?(0,r.isVisibilityHidden)(i):o(t).visibility===`hidden`)return!0;for(let e=i;e!==null;e=parentElement(e))if(a(e.node))return!0;return!1}function getImplicitAriaRolesImpl(e){let t=u.implicitRole(e);return t===null?[]:[t]}function getRoles(n,{hidden:r=!1}={}){let i=e.A(n),a={},o=r===!1?styleOverride(i):null,s=o===null?null:/* @__PURE__ */ new Map,visit=e=>{if(r!==!1||(o===null?isInaccessibleImpl$1(e):u.isInaccessibleWithStyle(e,o,s))===!1){let n=(0,t.attr)(e,`role`),r=n===null?getImplicitAriaRolesImpl(e):n.split(` `).slice(0,1);for(let t of r){let n=a[t];Array.isArray(n)?n.push(e.node):a[t]=[e.node]}}for(let n=e.first;n!==null;n=n.next)n.type===t.ELEMENT_NODE&&visit(n)};return visit(i),a}const d={format:`pretty`};function prettyRoles(t,{hidden:n,includeDescription:r}){let i=getRoles(t,{hidden:n}),a=e.i().computedStyleSupportsPseudoElements,o=styleOverride(e.A(t));return Object.entries(i).filter(([e])=>e!==`generic`).map(([t,n])=>{let i=`-`.repeat(50);return`${t}:\n\n${n.map(t=>{let n=e.A(t),i=`Name "${u.computeAccessibleName(n,a,o)}":\n`,s=e.s(t.cloneNode(!1),void 0,d);return r?`${i}${`Description "${u.computeAccessibleDescription(n,a,o)}":\n`}${s}`:`${i}${s}`}).join(`
|
|
2
2
|
|
|
3
3
|
`)}\n\n${i}`}).join(`
|
|
4
4
|
`)}const logRoles=(e,{hidden:t=!1}={})=>console.log(prettyRoles(e,{hidden:t}));function checkBooleanAttribute(e,n){let r=(0,t.attr)(e,n);if(r===`true`)return!0;if(r===`false`)return!1}function computeAriaSelected(e){return e.tag===t.T.option&&e.ns===t.HTML_NS?e.node.selected:checkBooleanAttribute(e,`aria-selected`)}function computeAriaBusy(e){return(0,t.ariaAttr)(e,`aria-busy`)===`true`}function computeAriaChecked(e){let t=e.node;if(!(`indeterminate`in t&&t.indeterminate))return`checked`in t?t.checked:checkBooleanAttribute(e,`aria-checked`)}function computeAriaPressed(e){return checkBooleanAttribute(e,`aria-pressed`)}function computeAriaCurrent(e){return checkBooleanAttribute(e,`aria-current`)??(0,t.ariaAttr)(e,`aria-current`)??!1}function computeAriaExpanded(e){return checkBooleanAttribute(e,`aria-expanded`)}function computeHeadingLevelImpl(e){let n=(0,t.ariaAttr)(e,`aria-level`),r=n&&Number(n);if(r)return r;if(e.ns===t.HTML_NS)switch(e.tag){case t.T.h1:return 1;case t.T.h2:return 2;case t.T.h3:return 3;case t.T.h4:return 4;case t.T.h5:return 5;case t.T.h6:return 6}}function computeAriaValueNow(e){let n=(0,t.ariaAttr)(e,`aria-valuenow`);return n===null?void 0:+n}function computeAriaValueMax(e){let n=(0,t.ariaAttr)(e,`aria-valuemax`);return n===null?void 0:+n}function computeAriaValueMin(e){let n=(0,t.ariaAttr)(e,`aria-valuemin`);return n===null?void 0:+n}function computeAriaValueText(e){let n=(0,t.ariaAttr)(e,`aria-valuetext`);return n===null?void 0:n}const f=getDefaultNormalizer();function escapeRegExp(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,`\\$&`)}function getRegExpMatcher(e){return new RegExp(escapeRegExp(e.toLowerCase()),`i`)}function makeSuggestion(t,n,r,{variant:i,name:a}){let o=``,s={},c=[[`Role`,`TestId`].includes(t)?r:getRegExpMatcher(r)];a&&(s.name=getRegExpMatcher(a)),t===`Role`&&isInaccessibleChecked(e.A(n))&&(s.hidden=!0,o=`Element is inaccessible. This means that the element and all its children are invisible to screen readers.
|
|
@@ -13,7 +13,7 @@ Here are the matching elements:
|
|
|
13
13
|
${t}`,r)}return a[0]||null}}function getSuggestionError(t,n){return e.i().getElementError(`A better query is available, try this:
|
|
14
14
|
${t.toString()}
|
|
15
15
|
`,n)}function makeGetAllQuery(t,n){return(r,...i)=>{let a=t(r,...i);if(!a.length)throw e.i().getElementError(n(r,...i),r);return a}}function makeFindQuery(e,n=`find`){return(r,i,a,o)=>{let find=t=>waitForInSpan(()=>e(r,i,a),{container:r,...o},t);return(0,t.tracing)()?(0,t.tracePromise)(p,(0,t.describeCall)(n,[i,a]),async e=>{let t=await find(e);return e.data.matches=matchCount(t),t}):find(null)}}const p=`testing-library.query`,matchCount=e=>Array.isArray(e)?e.length:+!!e;function traceQuery(e,n){return(r,...i)=>(0,t.tracing)()?(0,t.traceSync)(p,(0,t.describeCall)(e,i),e=>{let t=n(r,...i);return e.data.matches=matchCount(t),t}):n(r,...i)}const wrapSingleQueryWithSuggestion=(t,n,r)=>(i,...a)=>{let o=t(i,...a),[{suggest:s=e.i().throwSuggestions}={}]=a.slice(-1);if(o&&s){let e=getSuggestedQuery(o,r);if(e&&!n.endsWith(e.queryName))throw getSuggestionError(e.toString(),i)}return o},wrapAllByQueryWithSuggestion=(t,n,r)=>(i,...a)=>{let o=t(i,...a),[{suggest:s=e.i().throwSuggestions}={}]=a.slice(-1);if(o.length&&s){let e=[...new Set(o.map(e=>getSuggestedQuery(e,r)?.toString()))];if(e.length===1&&!n.endsWith(getSuggestedQuery(o[0],r).queryName))throw getSuggestionError(e[0],i)}return o};function buildQueries(e,t,n){let r=wrapSingleQueryWithSuggestion(makeSingleQuery(e,t),e.name,`query`),i=makeGetAllQuery(e,n),a=makeSingleQuery(i,t),o=wrapSingleQueryWithSuggestion(a,e.name,`get`),s=wrapAllByQueryWithSuggestion(i,e.name.replace(`query`,`get`),`getAll`),c=e.name.startsWith(`queryAll`)?e.name.slice(8):``,l=makeFindQuery(wrapAllByQueryWithSuggestion(i,e.name,`findAll`),`findAll${c}`),u=makeFindQuery(wrapSingleQueryWithSuggestion(a,e.name,`find`),`find${c}`);return[traceQuery(`query${c}`,r),traceQuery(`getAll${c}`,s),traceQuery(`get${c}`,o),l,u]}const m=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]),h=/* @__PURE__ */ e.N(e=>e,`identity`);function normalize(e){return e.replace(/\s+/g,` `).trim()}function similarity(e,t){let n=normalize(e).toLowerCase(),r=normalize(t).toLowerCase();if(n===``||r===``)return-1;if(n===r)return 0;if(n.includes(r)||r.includes(n))return 1;let i=r.split(` `);for(let e=0;e<i.length;e++)if(i[e].length>2&&n.includes(i[e]))return 2;return-1}function closeness(e,t,n,r,i=!0){if((i?matches:fuzzyMatches)(e,t,n,r))return 0;if(typeof n==`string`||typeof n==`number`){let t=similarity(r(e),String(n));return t===-1?-1:t+1}return-1}function line(t,n,r,i,a){let o={role:n,name:r,props:e.v(t,n,!1,i),value:null,url:null,children:[],element:t};return`- ${e._(o,80)} # ${a}`}function format(e,t){if(t.length===0)return``;t.sort((e,t)=>e.rank-t.rank);let n=t.slice(0,10).map(e=>e.line);return t.length>10&&n.push(`# … ${t.length-10} more`),`${e}:\n${n.join(`
|
|
16
|
-
`)}`}function nameOf(e){return normalize((0,r.computeAccessibleNameImpl)(e,void 0,5))}function roleCandidates(n,i){let a=e.A(n),o=[],s=i.name;for(let n=a.first;n!==null;n=(0,t.nextInTree)(n,a)){if(n.type!==t.ELEMENT_NODE)continue;let a=(0,r.isInaccessibleImpl)(n),c=(0,r.tlRole)(n);if((0,r.tlRoleMatches)(n,i.role,i.queryFallbacks)){let t=nameOf(n),r=s===void 0?0:closeness(t,n.node,s,h),l=i.matchesState(n);r===0&&l?a&&!i.hidden&&o.push({line:line(n,c,t,!0,`hidden: ${e.h(n)} (or pass { hidden: true })`),rank:0}):r===0?o.push({line:line(n,c,t,a&&!i.hidden,`role and name match, state is not ${i.stateHint}`),rank:1}):(!a||i.hidden)&&o.push({line:line(n,c,t,!1,r>0?`similar name`:`same role, other name`),rank:r>0?2+r:10});continue}if(s===void 0)continue;if(!m.has(c)){let e=nameOf(n);if(e===``)continue;let t=closeness(e,n.node,s,h);t>=0&&o.push({line:line(n,c,e,a&&!i.hidden,`same name, role "${c}"`),rank:2+t});continue}let l=normalize(getNodeTextImpl(n));l!==``&&closeness(l,n.node,s,h)===0&&o.push({line:`- text: ${e.y(e.x(l,80))} # in ${e.p(n)}, which has no role: give it role="${i.role}" or use getByText`,rank:2})}return format(`Closest matches`,o)}function roleOrTag(t){let n=(0,r.tlRole)(t);return m.has(n)?e.p(t):n}function textCandidates(n,r,i,a,o,s){if(typeof r==`function`)return``;let c=e.A(n),l=[],u=[];for(let n=c.first;n!==null;n=(0,t.nextInTree)(n,c)){if(n.type!==t.ELEMENT_NODE||o&&typeof o==`string`&&e.T(n,o))continue;let c=getNodeTextImpl(n),d=c.trim()===``?-1:closeness(c,n.node,r,i,s);d===0?l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(c),80))} # matches, but not selector "${a}"`,rank:0}):d>0&&l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(c),80))} # similar text in ${e.p(n)}`,rank:1+d}),d!==0&&n.first!==null&&n.first!==n.last&&(s?matches:fuzzyMatches)(n.node.textContent,n.node,r,i)&&u.push(n)}for(let t=0;t<u.length;t++){let n=u[t],r=!1;for(let e=t+1;e<u.length&&!r;e++)isAncestor(n,u[e])&&(r=!0);r||l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(n.node.textContent),80))} # text split across child elements of ${e.p(n)}: use a function matcher or getByRole`,rank:0})}return format(`Closest matches`,l)}function isAncestor(e,t){for(let n=t.parent;n!==null;n=n.parent)if(n===e)return!0;return!1}const g=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`]);function labelCandidates(n,i,a,o){if(typeof i==`function`)return``;let s=e.A(n),c=[];for(let n=s.first;n!==null;n=(0,t.nextInTree)(n,s)){if(n.type!==t.ELEMENT_NODE)continue;let s=(0,r.tlRole)(n);if(!g.has(s))continue;let l=nameOf(n),u=(0,r.isInaccessibleImpl)(n);if(l===``){let r=(0,t.attr)(n,`placeholder`),o=r?`no label, placeholder ${e.y(r)}: use getByPlaceholderText or add a <label>`:`no label: add a <label>, aria-label or aria-labelledby`;c.push({line:line(n,s,``,u,o),rank:r&&closeness(r,n.node,i,a)>=0?1:5});continue}let d=closeness(l,n.node,i,a,o);c.push({line:line(n,s,l,u,d>=0?`similar label`:`labelled control`),rank:d>=0?2+d:10})}return format(`Labelled form controls`,c)}var _=/* @__PURE__ */ e.M({findAllByLabelText:()=>x,findByLabelText:()=>S,getAllByLabelText:()=>C,getByLabelText:()=>w,queryAllByLabelText:()=>T,queryByLabelText:()=>y});function queryAllLabels(n){let r=e.A(n),i=[];for(let e=r.first;e!==null;e=(0,t.nextInTree)(e,r)){if(e.type!==t.ELEMENT_NODE||e.name!==`label`&&e.name!==`input`)continue;let n=getLabelContentImpl(e);n!==null&&i.push({node:e.node,textToMatch:n})}return i}function queryAllLabelsByText(e,t,{exact:n=!0,trim:r,collapseWhitespace:i,normalizer:a}={}){let o=textMatcher(n,t,makeNormalizer({collapseWhitespace:i,trim:r,normalizer:a}));return queryAllLabels(e).filter(({node:e,textToMatch:t})=>o(t,e)).map(({node:e})=>e)}function queryAllByLabelText(n,r,{selector:i=`*`,exact:a=!0,collapseWhitespace:o,trim:s,normalizer:c}={}){e.D(n);let l=makeNormalizer({collapseWhitespace:o,trim:s,normalizer:c}),u=
|
|
16
|
+
`)}`}function nameOf(e){return normalize((0,r.computeAccessibleNameImpl)(e,void 0,5))}function roleCandidates(n,i){let a=e.A(n),o=[],s=i.name;for(let n=a.first;n!==null;n=(0,t.nextInTree)(n,a)){if(n.type!==t.ELEMENT_NODE)continue;let a=(0,r.isInaccessibleImpl)(n),c=(0,r.tlRole)(n);if((0,r.tlRoleMatches)(n,i.role,i.queryFallbacks)){let t=nameOf(n),r=s===void 0?0:closeness(t,n.node,s,h),l=i.matchesState(n);r===0&&l?a&&!i.hidden&&o.push({line:line(n,c,t,!0,`hidden: ${e.h(n)} (or pass { hidden: true })`),rank:0}):r===0?o.push({line:line(n,c,t,a&&!i.hidden,`role and name match, state is not ${i.stateHint}`),rank:1}):(!a||i.hidden)&&o.push({line:line(n,c,t,!1,r>0?`similar name`:`same role, other name`),rank:r>0?2+r:10});continue}if(s===void 0)continue;if(!m.has(c)){let e=nameOf(n);if(e===``)continue;let t=closeness(e,n.node,s,h);t>=0&&o.push({line:line(n,c,e,a&&!i.hidden,`same name, role "${c}"`),rank:2+t});continue}let l=normalize(getNodeTextImpl(n));l!==``&&closeness(l,n.node,s,h)===0&&o.push({line:`- text: ${e.y(e.x(l,80))} # in ${e.p(n)}, which has no role: give it role="${i.role}" or use getByText`,rank:2})}return format(`Closest matches`,o)}function roleOrTag(t){let n=(0,r.tlRole)(t);return m.has(n)?e.p(t):n}function textCandidates(n,r,i,a,o,s){if(typeof r==`function`)return``;let c=e.A(n),l=[],u=[];for(let n=c.first;n!==null;n=(0,t.nextInTree)(n,c)){if(n.type!==t.ELEMENT_NODE||o&&typeof o==`string`&&e.T(n,o))continue;let c=getNodeTextImpl(n),d=c.trim()===``?-1:closeness(c,n.node,r,i,s);d===0?l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(c),80))} # matches, but not selector "${a}"`,rank:0}):d>0&&l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(c),80))} # similar text in ${e.p(n)}`,rank:1+d}),d!==0&&n.first!==null&&n.first!==n.last&&(s?matches:fuzzyMatches)(n.node.textContent,n.node,r,i)&&u.push(n)}for(let t=0;t<u.length;t++){let n=u[t],r=!1;for(let e=t+1;e<u.length&&!r;e++)isAncestor(n,u[e])&&(r=!0);r||l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(n.node.textContent),80))} # text split across child elements of ${e.p(n)}: use a function matcher or getByRole`,rank:0})}return format(`Closest matches`,l)}function isAncestor(e,t){for(let n=t.parent;n!==null;n=n.parent)if(n===e)return!0;return!1}const g=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`]);function labelCandidates(n,i,a,o){if(typeof i==`function`)return``;let s=e.A(n),c=[];for(let n=s.first;n!==null;n=(0,t.nextInTree)(n,s)){if(n.type!==t.ELEMENT_NODE)continue;let s=(0,r.tlRole)(n);if(!g.has(s))continue;let l=nameOf(n),u=(0,r.isInaccessibleImpl)(n);if(l===``){let r=(0,t.attr)(n,`placeholder`),o=r?`no label, placeholder ${e.y(r)}: use getByPlaceholderText or add a <label>`:`no label: add a <label>, aria-label or aria-labelledby`;c.push({line:line(n,s,``,u,o),rank:r&&closeness(r,n.node,i,a)>=0?1:5});continue}let d=closeness(l,n.node,i,a,o);c.push({line:line(n,s,l,u,d>=0?`similar label`:`labelled control`),rank:d>=0?2+d:10})}return format(`Labelled form controls`,c)}var _=/* @__PURE__ */ e.M({findAllByLabelText:()=>x,findByLabelText:()=>S,getAllByLabelText:()=>C,getByLabelText:()=>w,queryAllByLabelText:()=>T,queryByLabelText:()=>y});function queryAllLabels(n){let r=e.A(n),i=[];for(let e=r.first;e!==null;e=(0,t.nextInTree)(e,r)){if(e.type!==t.ELEMENT_NODE||e.name!==`label`&&e.name!==`input`)continue;let n=getLabelContentImpl(e);n!==null&&i.push({node:e.node,textToMatch:n})}return i}function queryAllLabelsByText(e,t,{exact:n=!0,trim:r,collapseWhitespace:i,normalizer:a}={}){let o=textMatcher(n,t,makeNormalizer({collapseWhitespace:i,trim:r,normalizer:a}));return queryAllLabels(e).filter(({node:e,textToMatch:t})=>o(t,e)).map(({node:e})=>e)}function queryAllByLabelText(n,r,{selector:i=`*`,exact:a=!0,collapseWhitespace:o,trim:s,normalizer:c}={}){e.D(n);let l=textMatcher(a,r,makeNormalizer({collapseWhitespace:o,trim:s,normalizer:c})),u=e.A(n),d=new LabelContext(u,!0),f=[],p=[];for(let e=u.first;e!==null;e=(0,t.nextInTree)(e,u))e.type===t.ELEMENT_NODE&&((0,t.ariaAttr)(e,`aria-label`)!==null&&p.push(e),((0,t.ariaAttr)(e,`aria-labelledby`)!==null||d.labelsOf(e).length!==0)&&collectLabelled(d,e,i,l,f));for(let e=0;e<p.length;e++){let n=p[e];l((0,t.ariaAttr)(n,`aria-label`),n.node)&&f.push(n.node)}let m=Array.from(new Set(f));return i===`*`?m:m.filter(n=>e.T(n[t.$impl],i))}function collectLabelled(e,t,n,r,i){let a=getLabelsImpl(e,t,n);if(a.length===1){let e=a[0];e.formControl&&r(e.content,e.formControl.node)&&i.push(e.formControl.node),r(`${e.content||``}`,t.node)&&i.push(t.node);return}for(let e of a){if(!e.formControl)continue;let t=e.formControl.node;r(e.content,t)&&i.push(t)}let o=a.filter(e=>!!e.content).map(e=>e.content),s=t.node;r(o.join(` `),s)&&i.push(s),o.length>1&&o.forEach((e,t)=>{r(e,s)&&i.push(s);let n=[...o];n.splice(t,1),n.length>1&&r(n.join(` `),s)&&i.push(s)})}function getAllByLabelText(t,n,...r){let i=queryAllByLabelText(t,n,...r);if(!i.length){let i=queryAllLabelsByText(t,n,...r);if(i.length){let r=i.map(e=>getTagNameOfElementAssociatedWithLabelViaFor(t,e)).filter(e=>!!e);throw r.length?e.i().getElementError(r.map(e=>`Found a label with the text of: ${n}, however the element associated with this label (<${e} />) is non-labellable [https://html.spec.whatwg.org/multipage/forms.html#category-label]. If you really need to label a <${e} />, you can use aria-label or aria-labelledby instead.`).join(`
|
|
17
17
|
|
|
18
18
|
`),t):e.i().getElementError(`Found a label with the text of: ${n}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`,t)}throw e.i().getElementError(withLabelCandidates(`Unable to find a label with the text of: ${n}`,t,n,r[0]),t)}return i}function withLabelCandidates(t,n,r,i={}){if(e.w()===null)return t;let{exact:a=!0,trim:o,collapseWhitespace:s,normalizer:c}=i,l=labelCandidates(n,r,makeNormalizer({trim:o,collapseWhitespace:s,normalizer:c}),a);return l===``?t:`${t}\n\n${l}`}function getTagNameOfElementAssociatedWithLabelViaFor(t,n){let r=n.getAttribute(`for`);if(!r)return null;let i=new LabelContext(e.A(t)).byIdInContainer(r);return i?i.node.tagName.toLowerCase():null}const v=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the text of: ${t}`,`getMultipleError`),y=wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllByLabelText,v),queryAllByLabelText.name,`query`),b=makeSingleQuery(getAllByLabelText,v),x=makeFindQuery(wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`findAll`)),S=makeFindQuery(wrapSingleQueryWithSuggestion(b,getAllByLabelText.name,`find`)),C=wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`getAll`),w=wrapSingleQueryWithSuggestion(b,getAllByLabelText.name,`get`),T=wrapAllByQueryWithSuggestion(queryAllByLabelText,queryAllByLabelText.name,`queryAll`);var ee=/* @__PURE__ */ e.M({findAllByPlaceholderText:()=>O,findByPlaceholderText:()=>k,getAllByPlaceholderText:()=>E,getByPlaceholderText:()=>D,queryAllByPlaceholderText:()=>re,queryByPlaceholderText:()=>ie});function queryAllByPlaceholderText(...t){return e.D(t[0]),queryAllByAttribute(`placeholder`,...t)}const te=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the placeholder text of: ${t}`,`getMultipleError`),ne=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the placeholder text of: ${t}`,`getMissingError`),re=wrapAllByQueryWithSuggestion(queryAllByPlaceholderText,queryAllByPlaceholderText.name,`queryAll`),[ie,E,D,O,k]=buildQueries(queryAllByPlaceholderText,te,ne);var ae=/* @__PURE__ */ e.M({findAllByText:()=>P,findByText:()=>F,getAllByText:()=>M,getByText:()=>N,queryAllByText:()=>A,queryByText:()=>j});function isScriptStyleIgnore(e){return e===`script, style`||e===`script,style`}function isScriptOrStyle(e){let t=e.name;return t===`script`||t===`style`}function queryAllByText(n,r,{selector:i=`*`,exact:a=!0,collapseWhitespace:o,trim:s,ignore:c=e.i().defaultIgnore,normalizer:l}={}){e.D(n);let u=textMatcher(a,r,makeNormalizer({collapseWhitespace:o,trim:s,normalizer:l})),d=e.A(n),f=i===`*`,p=isScriptStyleIgnore(c),m=[],visit=t=>{(f||e.T(t,i))&&(c&&(p?isScriptOrStyle(t):e.T(t,c))||u(getNodeTextImpl(t),t.node)&&m.push(t.node))};d.type===t.ELEMENT_NODE&&visit(d);for(let e=d.first;e!==null;e=(0,t.nextInTree)(e,d))e.type===t.ELEMENT_NODE&&visit(e);return m}const oe=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the text: ${t}`,`getMultipleError`),se=/* @__PURE__ */ e.N((t,n,r={})=>{let{collapseWhitespace:i,trim:a,normalizer:o,selector:s}=r,c=makeNormalizer({collapseWhitespace:i,trim:a,normalizer:o}),l=c(n.toString()),u=l!==n.toString(),d=(s??`*`)!==`*`,f=`Unable to find an element with the text: ${u?`${l} (normalized from '${n}')`:n}${d?`, which matches selector '${s}'`:``}. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.`;if(e.w()===null)return f;let{exact:p=!0,ignore:m=e.i().defaultIgnore}=r,h=textCandidates(t,n,c,s??`*`,m,p);return h===``?f:`${f}\n\n${h}`},`getMissingError`),A=wrapAllByQueryWithSuggestion(queryAllByText,queryAllByText.name,`queryAll`),[j,M,N,P,F]=buildQueries(queryAllByText,oe,se);var ce=/* @__PURE__ */ e.M({findAllByDisplayValue:()=>B,findByDisplayValue:()=>V,getAllByDisplayValue:()=>R,getByDisplayValue:()=>z,queryAllByDisplayValue:()=>I,queryByDisplayValue:()=>L});function queryAllByDisplayValue(n,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){e.D(n);let c=textMatcher(i,r,makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s})),l=e.A(n),u=[];for(let e=l.first;e!==null;e=(0,t.nextInTree)(e,l)){if(e.type!==t.ELEMENT_NODE)continue;let n=e.name;if(n!==`input`&&n!==`textarea`&&n!==`select`)continue;let r=e.node;if(e.tag===t.T.select&&e.ns===t.HTML_NS){let e=r.options,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i.selected&&c(getNodeTextImpl(i[t.$impl]),i)){n=!0;break}}n&&u.push(r)}else c(r.value,r)&&u.push(r)}return u}const le=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the display value: ${t}.`,`getMultipleError`),ue=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the display value: ${t}.`,`getMissingError`),I=wrapAllByQueryWithSuggestion(queryAllByDisplayValue,queryAllByDisplayValue.name,`queryAll`),[L,R,z,B,V]=buildQueries(queryAllByDisplayValue,le,ue);var de=/* @__PURE__ */ e.M({findAllByAltText:()=>K,findByAltText:()=>q,getAllByAltText:()=>W,getByAltText:()=>G,queryAllByAltText:()=>H,queryByAltText:()=>U});const fe=/^(img|input|area|.+-.+)$/i;function queryAllByAltText(t,n,r={}){return e.D(t),queryAllByAttribute(`alt`,t,n,r).filter(e=>fe.test(e.tagName))}const pe=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the alt text: ${t}`,`getMultipleError`),me=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the alt text: ${t}`,`getMissingError`),H=wrapAllByQueryWithSuggestion(queryAllByAltText,queryAllByAltText.name,`queryAll`),[U,W,G,K,q]=buildQueries(queryAllByAltText,pe,me);var he=/* @__PURE__ */ e.M({findAllByTitle:()=>ye,findByTitle:()=>be,getAllByTitle:()=>Y,getByTitle:()=>X,queryAllByTitle:()=>ve,queryByTitle:()=>J});function isSvgTitle(e){let n=e.parent;return(0,t.asciiLowercase)(e.prefix===null?e.name:e.prefix+`:`+e.name)===`title`&&n!==null&&n.type===t.ELEMENT_NODE&&(0,t.asciiLowercase)(n.prefix===null?n.name:n.prefix+`:`+n.name)===`svg`}function queryAllByTitle(n,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){e.D(n);let c=textMatcher(i,r,makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s})),l=e.A(n),u=[];for(let e=l.first;e!==null;e=(0,t.nextInTree)(e,l)){if(e.type!==t.ELEMENT_NODE)continue;let n=e.attrs===null?null:(0,t.attr)(e,`title`),r=e.name===`title`&&e.parent!==null&&e.parent.type===t.ELEMENT_NODE&&e.parent.name===`svg`;(n!==null||r)&&(c(n,e.node)||isSvgTitle(e)&&c(getNodeTextImpl(e),e.node))&&u.push(e.node)}return u}const ge=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the title: ${t}.`,`getMultipleError`),_e=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the title: ${t}.`,`getMissingError`),ve=wrapAllByQueryWithSuggestion(queryAllByTitle,queryAllByTitle.name,`queryAll`),[J,Y,X,ye,be]=buildQueries(queryAllByTitle,ge,_e);var xe=/* @__PURE__ */ e.M({findAllByRole:()=>Oe,findByRole:()=>ke,getAllByRole:()=>Ee,getByRole:()=>De,queryAllByRole:()=>we,queryByRole:()=>Te});const identity=e=>e;function assertSupported(e,t){if(!u.roleSupportsProp(e,t))throw Error(`"${t}" is not supported on role "${e}".`)}function queryAllByRole(n,r,{hidden:i=e.i().defaultHidden,name:a,description:o,queryFallbacks:s=!1,selected:c,busy:l,checked:d,pressed:f,current:p,level:m,expanded:h,value:{now:g,min:_,max:v,text:y}={}}={}){if(e.D(n),c!==void 0&&assertSupported(r,`aria-selected`),l!==void 0&&assertSupported(r,`aria-busy`),d!==void 0&&assertSupported(r,`aria-checked`),f!==void 0&&assertSupported(r,`aria-pressed`),p!==void 0&&assertSupported(r,`aria-current`),m!==void 0&&r!==`heading`)throw Error(`Role "${r}" cannot have "level" property.`);g!==void 0&&assertSupported(r,`aria-valuenow`),v!==void 0&&assertSupported(r,`aria-valuemax`),_!==void 0&&assertSupported(r,`aria-valuemin`),y!==void 0&&assertSupported(r,`aria-valuetext`),h!==void 0&&assertSupported(r,`aria-expanded`);let b={selected:c,busy:l,checked:d,pressed:f,current:p,level:m,expanded:h,valueNow:g,valueMin:_,valueMax:v,valueText:y},x=e.i().computedStyleSupportsPseudoElements,S=e.A(n),C=[],w=styleOverride(S),T=w!==null&&i===!1?/* @__PURE__ */ new Map:null;for(let e=S.first;e!==null;e=(0,t.nextInTree)(e,S))e.type===t.ELEMENT_NODE&&u.roleMatches(e,r,s)&&matchesState(e,b)&&(i===!1&&(w===null?isInaccessibleImpl$1(e):u.isInaccessibleWithStyle(e,w,T))||(a===void 0||matches(u.computeAccessibleName(e,x,w),e.node,a,identity))&&(o===void 0||matches(u.computeAccessibleDescription(e,x,w),e.node,o,identity))&&C.push(e.node));return C}function matchesState(e,t){if(t.selected!==void 0)return t.selected===computeAriaSelected(e);if(t.busy!==void 0)return t.busy===computeAriaBusy(e);if(t.checked!==void 0)return t.checked===computeAriaChecked(e);if(t.pressed!==void 0)return t.pressed===computeAriaPressed(e);if(t.current!==void 0)return t.current===computeAriaCurrent(e);if(t.expanded!==void 0)return t.expanded===computeAriaExpanded(e);if(t.level!==void 0)return t.level===computeHeadingLevelImpl(e);if(t.valueNow!==void 0||t.valueMax!==void 0||t.valueMin!==void 0||t.valueText!==void 0){let n=!0;return t.valueNow!==void 0&&(n&&=t.valueNow===computeAriaValueNow(e)),t.valueMax!==void 0&&(n&&=t.valueMax===computeAriaValueMax(e)),t.valueMin!==void 0&&(n&&=t.valueMin===computeAriaValueMin(e)),t.valueText!==void 0&&(n&&=matches(computeAriaValueText(e)??null,e.node,t.valueText,identity)),n}return!0}const getNameHint=e=>{let t=``;return t=e===void 0?``:typeof e==`string`?` and name "${e}"`:` and name \`${e}\``,t},Se=/* @__PURE__ */ e.N((e,t,{name:n}={})=>`Found multiple elements with the role "${t}"${getNameHint(n)}`,`getMultipleError`),Ce=/* @__PURE__ */ e.N((t,n,r={})=>{let{hidden:i=e.i().defaultHidden,name:a,description:o}=r;if(e.w()!==null)return agentMissingError(t,n,r,i);if(e.i()._disableExpensiveErrorDiagnostics)return`Unable to find role="${n}"${getNameHint(a)}`;let s=``;Array.from(t.children).forEach(e=>{s+=prettyRoles(e,{hidden:i,includeDescription:o!==void 0})});let c;c=s.length===0?i===!1?"There are no accessible roles. But there might be some inaccessible roles. If you wish to access them, then set the `hidden` option to `true`. Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole":`There are no available roles.`:`
|
|
19
19
|
Here are the ${i===!1?`accessible`:`available`} roles:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{A as e,C as t,D as n,E as r,M as i,N as a,O as o,T as s,_ as c,a as l,c as u,h as d,i as f,j as p,k as m,l as h,o as g,p as _,r as v,s as y,t as b,v as x,w as S,x as C,y as w}from"./_chunks/aria-snapshot-diff-DejA3Rdn.js";import{$impl as T,ELEMENT_NODE as E,F_HTML as ee,HTML_NS as D,T as O,TEXT_NODE as k,ariaAttr as A,asciiLowercase as j,attr as M,describeCall as N,describeNode as te,getComputedStyleOverride as ne,nextInTree as P,prefixFlag as F,tracePromise as
|
|
1
|
+
import{A as e,C as t,D as n,E as r,M as i,N as a,O as o,T as s,_ as c,a as l,c as u,h as d,i as f,j as p,k as m,l as h,o as g,p as _,r as v,s as y,t as b,v as x,w as S,x as C,y as w}from"./_chunks/aria-snapshot-diff-DejA3Rdn.js";import{$impl as T,ELEMENT_NODE as E,F_HTML as ee,HTML_NS as D,T as O,TEXT_NODE as k,ariaAttr as A,asciiLowercase as j,attr as M,describeCall as N,describeNode as te,getComputedStyleOverride as ne,nextInTree as P,prefixFlag as F,tracePromise as re,traceSync as ie,tracing as I}from"@ctrl/dom/internal";import{roleSupportsProp as ae}from"@ctrl/dom/aria";import{computeAccessibleDescriptionImpl as oe,computeAccessibleNameImpl as L,implicitRole as se,isInaccessibleImpl as R,isInaccessibleWithStyle as ce,isSubtreeInaccessibleImpl as le,isVisibilityHidden as ue,labelMapForTree as de,labelsOf as fe,tlRole as z,tlRoleMatches as B}from"@ctrl/dom/aria/internal";import{AsyncLocalStorage as pe}from"node:async_hooks";function isLabelledNodeName(e){if(e.prefix!==null)return!1;switch(j(e.name)){case`button`:case`meter`:case`output`:case`progress`:case`select`:case`textarea`:case`input`:return!0}return!1}function buildIdMap(e,t){let n=/* @__PURE__ */ new Map;t&&e.type===E&&e.id!==``&&n.set(e.id,e);for(let t=e.first;t!==null;t=P(t,e))t.type===E&&t.id!==``&&!n.has(t.id)&&n.set(t.id,t);return n}var LabelContext=class{container;containerIds;sameTree;labelMap;constructor(e,t=!1){this.container=e,this.containerIds=null,this.sameTree=t,this.labelMap=null}labelsOf(e){return this.sameTree?(this.labelMap??=de(this.container)).get(e)??V:fe(e)??V}byIdInContainer(e){let t=this.containerIds;return t===null&&(t=this.containerIds=buildIdMap(this.container,!1)),t.get(e)??null}};const V=[];function getTextContent(e){if(e.type===E&&isLabelledNodeName(e))return``;if(e.type===k)return e.data;let t=``;for(let n=e.first;n!==null;n=n.next)t+=getTextContent(n);return t}function getLabelContentImpl(e){if(e.tag===O.label&&e.ns===D)return getTextContent(e);let t=e.node;return t.value||t.textContent}const me=/* @__PURE__ */ new Set([`button`,`input`,`meter`,`output`,`progress`,`select`,`textarea`]);function labelledFormControl(e,t){for(let n=e.first;n!==null;n=P(n,e))if(n.type===E&&me.has(n.name)&&(t===`*`||s(n,t)))return n}function getLabelsImpl(e,t,n=`*`){let r=A(t,`aria-labelledby`),i=r?r.split(` `):[];return i.length?i.map(t=>{let n=e.byIdInContainer(t);return n?{content:getLabelContentImpl(n),formControl:null}:{content:``,formControl:null}}):e.labelsOf(t).map(e=>({content:getLabelContentImpl(e),formControl:labelledFormControl(e,n)}))}function assertNotNullOrUndefined(e){if(e==null)throw Error(`It looks like ${e} was passed instead of a matcher. Did you do something like getByText(${e})?`)}function fuzzyMatches(e,t,n,r){if(typeof e!=`string`)return!1;assertNotNullOrUndefined(n);let i=r(e);return typeof n==`string`||typeof n==`number`?i.toLowerCase().includes(n.toString().toLowerCase()):typeof n==`function`?n(i,t):matchRegExp(n,i)}function matches$1(e,t,n,r){if(typeof e!=`string`)return!1;assertNotNullOrUndefined(n);let i=r(e);return n instanceof Function?n(i,t):n instanceof RegExp?matchRegExp(n,i):i===String(n)}a(matches$1,`matches`);function isRegExpWhitespace(e){return e<=32?e===32||e>=9&&e<=13:e<160?!1:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function changedByNormalizing(e,t,n){let r=e.length-1,i=!1;for(let a=0;a<=r;a++){let o=e.charCodeAt(a),s=isRegExpWhitespace(o);if(s&&(t&&(a===0||a===r)||n&&(i||o!==32)))return!0;i=s}return!1}const he=/\s+/g;function getDefaultNormalizer({trim:e=!0,collapseWhitespace:t=!0}={}){return n=>{if(!changedByNormalizing(n,e,t))return n;let r=n;return r=e?r.trim():r,r=t?r.replace(he,` `):r,r}}const H=getDefaultNormalizer();function textMatcher(e,t,n){if(!e)return(e,r)=>fuzzyMatches(e,r,t,n);if(n!==H||typeof t!=`string`&&typeof t!=`number`)return(e,r)=>matches$1(e,r,t,n);let r=String(t);if(changedByNormalizing(r,!0,!0))return()=>!1;let i=r.length,a=r.charCodeAt(0),o=r.charCodeAt(i-1);return e=>{if(typeof e!=`string`||e.length<i)return!1;if(i!==0){let t=e.charCodeAt(0);if(t!==a&&!isRegExpWhitespace(t))return!1;let n=e.charCodeAt(e.length-1);if(n!==o&&!isRegExpWhitespace(n))return!1}return H(e)===r}}function makeNormalizer({trim:e,collapseWhitespace:t,normalizer:n}){if(!n)return e===void 0&&t===void 0?H:getDefaultNormalizer({trim:e,collapseWhitespace:t});if(e!==void 0||t!==void 0)throw Error(`trim and collapseWhitespace are not supported with a normalizer. If you want to use the default trim and collapseWhitespace logic in your normalizer, use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer`);return n}function matchRegExp(e,t){let n=e.test(t);return e.global&&e.lastIndex!==0&&(console.warn(`To match all elements we had to reset the lastIndex of the RegExp because the global flag is enabled. We encourage to remove the global flag from the RegExp.`),e.lastIndex=0),n}function isButtonLikeInput(e){if(e.tag!==O.input||e.ns!==D)return!1;let t=M(e,`type`);if(t===null)return!1;let n=j(t);return n===`submit`||n===`button`||n===`reset`}function getNodeTextImpl(e){if(isButtonLikeInput(e))return e.node.value;let t=``;for(let n=e.first;n!==null;n=n.next)n.type===k&&(t+=n.data);return t}function getNodeText(t){let n=e(t);return n.type===E?getNodeTextImpl(n):t.matches(`input[type=submit], input[type=button], input[type=reset]`)}const ge={computedStyleSupportsPseudoElements:!0};function styleOverride(e){return ne(e)}function nameOptions(e,t){return t===null?e?ge:void 0:{computedStyleSupportsPseudoElements:e,getComputedStyle:t}}const U={implicitRole(e){let t=se(e);return t===``?null:t},roleMatches:B,roleSupportsProp(e,t){return typeof e==`string`&&ae(e,t)},computeAccessibleName(e,t,n){return L(e,nameOptions(t,n),5)},computeAccessibleDescription(e,t,n){return oe(e,nameOptions(t,n),5)},isInaccessible:R,isInaccessibleWithStyle:ce,isSubtreeInaccessible:le};function parentElement(e){let t=e.parent;return t!==null&&t.type===E?t:null}function isInaccessibleImpl$1(e){return U.isInaccessible(e)}a(isInaccessibleImpl$1,`isInaccessibleImpl`);function isInaccessibleChecked(e){let t=styleOverride(e);return t===null?U.isInaccessible(e):U.isInaccessibleWithStyle(e,t,null)}function isInaccessible(t,n={}){let r=e(t),i=n.isSubtreeInaccessible,a=styleOverride(r);if(i===void 0)return a===null?isInaccessibleImpl$1(r):U.isInaccessibleWithStyle(r,a,null);if(a===null?ue(r):a(t).visibility===`hidden`)return!0;for(let e=r;e!==null;e=parentElement(e))if(i(e.node))return!0;return!1}function getImplicitAriaRolesImpl(e){let t=U.implicitRole(e);return t===null?[]:[t]}function getRoles(t,{hidden:n=!1}={}){let r=e(t),i={},a=n===!1?styleOverride(r):null,o=a===null?null:/* @__PURE__ */ new Map,visit=e=>{if(n!==!1||(a===null?isInaccessibleImpl$1(e):U.isInaccessibleWithStyle(e,a,o))===!1){let t=M(e,`role`),n=t===null?getImplicitAriaRolesImpl(e):t.split(` `).slice(0,1);for(let t of n){let n=i[t];Array.isArray(n)?n.push(e.node):i[t]=[e.node]}}for(let t=e.first;t!==null;t=t.next)t.type===E&&visit(t)};return visit(r),i}const _e={format:`pretty`};function prettyRoles(t,{hidden:n,includeDescription:r}){let i=getRoles(t,{hidden:n}),a=f().computedStyleSupportsPseudoElements,o=styleOverride(e(t));return Object.entries(i).filter(([e])=>e!==`generic`).map(([t,n])=>{let i=`-`.repeat(50);return`${t}:\n\n${n.map(t=>{let n=e(t),i=`Name "${U.computeAccessibleName(n,a,o)}":\n`,s=y(t.cloneNode(!1),void 0,_e);return r?`${i}${`Description "${U.computeAccessibleDescription(n,a,o)}":\n`}${s}`:`${i}${s}`}).join(`
|
|
2
2
|
|
|
3
3
|
`)}\n\n${i}`}).join(`
|
|
4
4
|
`)}const logRoles=(e,{hidden:t=!1}={})=>console.log(prettyRoles(e,{hidden:t}));function checkBooleanAttribute(e,t){let n=M(e,t);if(n===`true`)return!0;if(n===`false`)return!1}function computeAriaSelected$1(e){return e.tag===O.option&&e.ns===D?e.node.selected:checkBooleanAttribute(e,`aria-selected`)}a(computeAriaSelected$1,`computeAriaSelected`);function computeAriaBusy$1(e){return A(e,`aria-busy`)===`true`}a(computeAriaBusy$1,`computeAriaBusy`);function computeAriaChecked(e){let t=e.node;if(!(`indeterminate`in t&&t.indeterminate))return`checked`in t?t.checked:checkBooleanAttribute(e,`aria-checked`)}function computeAriaPressed(e){return checkBooleanAttribute(e,`aria-pressed`)}function computeAriaCurrent$1(e){return checkBooleanAttribute(e,`aria-current`)??A(e,`aria-current`)??!1}a(computeAriaCurrent$1,`computeAriaCurrent`);function computeAriaExpanded$1(e){return checkBooleanAttribute(e,`aria-expanded`)}a(computeAriaExpanded$1,`computeAriaExpanded`);function computeHeadingLevelImpl(e){let t=A(e,`aria-level`),n=t&&Number(t);if(n)return n;if(e.ns===D)switch(e.tag){case O.h1:return 1;case O.h2:return 2;case O.h3:return 3;case O.h4:return 4;case O.h5:return 5;case O.h6:return 6}}function computeAriaValueNow(e){let t=A(e,`aria-valuenow`);return t===null?void 0:+t}function computeAriaValueMax(e){let t=A(e,`aria-valuemax`);return t===null?void 0:+t}function computeAriaValueMin(e){let t=A(e,`aria-valuemin`);return t===null?void 0:+t}function computeAriaValueText(e){let t=A(e,`aria-valuetext`);return t===null?void 0:t}const W=getDefaultNormalizer();function escapeRegExp(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,`\\$&`)}function getRegExpMatcher(e){return new RegExp(escapeRegExp(e.toLowerCase()),`i`)}function makeSuggestion(t,n,r,{variant:i,name:a}){let o=``,s={},c=[[`Role`,`TestId`].includes(t)?r:getRegExpMatcher(r)];a&&(s.name=getRegExpMatcher(a)),t===`Role`&&isInaccessibleChecked(e(n))&&(s.hidden=!0,o=`Element is inaccessible. This means that the element and all its children are invisible to screen readers.
|
|
5
5
|
If you are using the aria-hidden prop, make sure this is the right choice for your case.
|
|
6
|
-
`),Object.keys(s).length>0&&c.push(s);let l=`${i}By${t}`;return{queryName:t,queryMethod:l,queryArgs:c,variant:i,warning:o,toString(){o&&console.warn(o);let[e,t]=c;return e=typeof e==`string`?`'${e}'`:e,t=t?`, { ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)} }`:``,`${l}(${e}${t})`}}}function canSuggest(e,t,n){return!(!n||t&&t.toLowerCase()!==e.toLowerCase())}function getSuggestedQuery(t,n=`get`,r){let i=e(t);if(s(i,f().defaultIgnore))return;let a=M(i,`role`)??getImplicitAriaRolesImpl(i)?.[0];if(a!==`generic`&&canSuggest(`Role`,r,a))return makeSuggestion(`Role`,t,a,{variant:n,name:U.computeAccessibleName(i,f().computedStyleSupportsPseudoElements,styleOverride(i))});let c=getLabelsImpl(new LabelContext(e(o())),i).map(e=>e.content).join(` `);if(canSuggest(`LabelText`,r,c))return makeSuggestion(`LabelText`,t,c,{variant:n});let l=M(i,`placeholder`);if(canSuggest(`PlaceholderText`,r,l))return makeSuggestion(`PlaceholderText`,t,l,{variant:n});let u=W(getNodeTextImpl(i));if(canSuggest(`Text`,r,u))return makeSuggestion(`Text`,t,u,{variant:n});if(canSuggest(`DisplayValue`,r,t.value))return makeSuggestion(`DisplayValue`,t,W(t.value),{variant:n});let d=M(i,`alt`);if(canSuggest(`AltText`,r,d))return makeSuggestion(`AltText`,t,d,{variant:n});let p=M(i,`title`);if(canSuggest(`Title`,r,p))return makeSuggestion(`Title`,t,p,{variant:n});let m=t.getAttribute(f().testIdAttribute);if(canSuggest(`TestId`,r,m))return makeSuggestion(`TestId`,t,m,{variant:n})}function copyStackTrace(e,t){e.stack=t.stack.replace(t.message,e.message)}function waitForImpl(e,{container:t=o(),timeout:i=f().asyncUtilTimeout,showOriginalStackTrace:a=f().showOriginalStackTrace,stackTraceError:s,interval:c=50,onTimeout:u=e=>(e.name===`TestingLibraryElementError`&&S()!==null||Object.defineProperty(e,"message",{value:f().getElementError(e.message,t).message}),e),mutationObserverOptions:d={subtree:!0,childList:!0,attributes:!0,characterData:!0}},h=null){if(typeof e!=`function`)throw TypeError("Received `callback` arg must be a function");return new Promise(async(o,g)=>{let _,v,y,b=!1,x=`idle`,S=setTimeout(handleTimeout,i),C=p();if(C){let{unstable_advanceTimersWrapper:e}=f();for(checkCallback();!b;){if(!p()){let e=/* @__PURE__ */ Error(`Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`);a||copyStackTrace(e,s),g(e);return}if(await e(async()=>{r(c)}),b)break;checkCallback()}}else{try{n(t)}catch(e){b=!0,clearTimeout(S),g(e);return}let e=h===null?null:pe.snapshot(),r=e===null?checkRealTimersCallback:()=>e(checkRealTimersCallback);v=setInterval(r,c);let{MutationObserver:i}=m(t);y=new i(r),y.observe(t,d),checkCallback()}function onDone(e,t){b=!0,clearTimeout(S),C||(clearInterval(v),y.disconnect()),e?g(e):o(t)}function checkRealTimersCallback(){if(p()){let e=/* @__PURE__ */ Error(`Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`);return a||copyStackTrace(e,s),g(e)}return checkCallback()}function checkCallback(){if(x!==`pending`){h!==null&&(h.data.checks=(h.data.checks??0)+1);try{let t=l(e);typeof t?.then==`function`?(x=`pending`,t.then(e=>{x=`resolved`,onDone(null,e)},e=>{x=`rejected`,_=e})):onDone(null,t)}catch(e){_=e}}}function handleTimeout(){let e;_?(e=_,!a&&e.name===`TestingLibraryElementError`&©StackTrace(e,s)):(e=/* @__PURE__ */ Error(`Timed out in waitFor.`),a||copyStackTrace(e,s)),onDone(u(e),null)}})}function waitFor(e,t){return
|
|
6
|
+
`),Object.keys(s).length>0&&c.push(s);let l=`${i}By${t}`;return{queryName:t,queryMethod:l,queryArgs:c,variant:i,warning:o,toString(){o&&console.warn(o);let[e,t]=c;return e=typeof e==`string`?`'${e}'`:e,t=t?`, { ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)} }`:``,`${l}(${e}${t})`}}}function canSuggest(e,t,n){return!(!n||t&&t.toLowerCase()!==e.toLowerCase())}function getSuggestedQuery(t,n=`get`,r){let i=e(t);if(s(i,f().defaultIgnore))return;let a=M(i,`role`)??getImplicitAriaRolesImpl(i)?.[0];if(a!==`generic`&&canSuggest(`Role`,r,a))return makeSuggestion(`Role`,t,a,{variant:n,name:U.computeAccessibleName(i,f().computedStyleSupportsPseudoElements,styleOverride(i))});let c=getLabelsImpl(new LabelContext(e(o())),i).map(e=>e.content).join(` `);if(canSuggest(`LabelText`,r,c))return makeSuggestion(`LabelText`,t,c,{variant:n});let l=M(i,`placeholder`);if(canSuggest(`PlaceholderText`,r,l))return makeSuggestion(`PlaceholderText`,t,l,{variant:n});let u=W(getNodeTextImpl(i));if(canSuggest(`Text`,r,u))return makeSuggestion(`Text`,t,u,{variant:n});if(canSuggest(`DisplayValue`,r,t.value))return makeSuggestion(`DisplayValue`,t,W(t.value),{variant:n});let d=M(i,`alt`);if(canSuggest(`AltText`,r,d))return makeSuggestion(`AltText`,t,d,{variant:n});let p=M(i,`title`);if(canSuggest(`Title`,r,p))return makeSuggestion(`Title`,t,p,{variant:n});let m=t.getAttribute(f().testIdAttribute);if(canSuggest(`TestId`,r,m))return makeSuggestion(`TestId`,t,m,{variant:n})}function copyStackTrace(e,t){e.stack=t.stack.replace(t.message,e.message)}function waitForImpl(e,{container:t=o(),timeout:i=f().asyncUtilTimeout,showOriginalStackTrace:a=f().showOriginalStackTrace,stackTraceError:s,interval:c=50,onTimeout:u=e=>(e.name===`TestingLibraryElementError`&&S()!==null||Object.defineProperty(e,"message",{value:f().getElementError(e.message,t).message}),e),mutationObserverOptions:d={subtree:!0,childList:!0,attributes:!0,characterData:!0}},h=null){if(typeof e!=`function`)throw TypeError("Received `callback` arg must be a function");return new Promise(async(o,g)=>{let _,v,y,b=!1,x=`idle`,S=setTimeout(handleTimeout,i),C=p();if(C){let{unstable_advanceTimersWrapper:e}=f();for(checkCallback();!b;){if(!p()){let e=/* @__PURE__ */ Error(`Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`);a||copyStackTrace(e,s),g(e);return}if(await e(async()=>{r(c)}),b)break;checkCallback()}}else{try{n(t)}catch(e){b=!0,clearTimeout(S),g(e);return}let e=h===null?null:pe.snapshot(),r=e===null?checkRealTimersCallback:()=>e(checkRealTimersCallback);v=setInterval(r,c);let{MutationObserver:i}=m(t);y=new i(r),y.observe(t,d),checkCallback()}function onDone(e,t){b=!0,clearTimeout(S),C||(clearInterval(v),y.disconnect()),e?g(e):o(t)}function checkRealTimersCallback(){if(p()){let e=/* @__PURE__ */ Error(`Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`);return a||copyStackTrace(e,s),g(e)}return checkCallback()}function checkCallback(){if(x!==`pending`){h!==null&&(h.data.checks=(h.data.checks??0)+1);try{let t=l(e);typeof t?.then==`function`?(x=`pending`,t.then(e=>{x=`resolved`,onDone(null,e)},e=>{x=`rejected`,_=e})):onDone(null,t)}catch(e){_=e}}}function handleTimeout(){let e;_?(e=_,!a&&e.name===`TestingLibraryElementError`&©StackTrace(e,s)):(e=/* @__PURE__ */ Error(`Timed out in waitFor.`),a||copyStackTrace(e,s)),onDone(u(e),null)}})}function waitFor(e,t){return I()?re(`testing-library.wait_for`,`waitFor(${describeCallback(e)})`,n=>waitForInSpan(e,t,n)):waitForInSpan(e,t,null)}function waitForInSpan(e,t,n){let r=/* @__PURE__ */ Error(`STACK_TRACE_MESSAGE`);return f().asyncWrapper(()=>waitForImpl(e,{stackTraceError:r,...t},n))}function describeCallback(e){if(typeof e!=`function`)return String(e);let t=Function.prototype.toString.call(e).replace(/\s+/g,` `).replace(/__vite_ssr_import_\d+__\./g,``).replace(/\(0, ?([\w$.]+)\)/g,`$1`).replace(/(?<![\w$.])_[a-z][\w$]*\.(?=[\w$])/g,``),n=/^(async )?\(\) ?=> ?\{ ?(?:return )?(.*?);? ?\}$/.exec(t);return n!==null&&!n[2].includes(`;`)&&(t=`${n[1]??``}() => ${n[2]}`),t.length>120?`${t.slice(0,119)}…`:t}function getElementError(e,t){return f().getElementError(e,t)}function getMultipleElementsFoundError(e,t){return getElementError(`${e}\n\n(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).`,t)}function queryAllByAttribute(t,n,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){let c=textMatcher(i,r,makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s})),l=e(n),u=j(t),d=F(u),f=F(t),p=[];for(let e=l.first;e!==null;e=P(e,l)){if(e.type!==E||e.attrs===null)continue;let n=(e.flags&ee)!==0,r=n?d:f;if(r!==0&&(e.flags&r)===0)continue;let i=M(e,n?u:t);i!==null&&c(i,e.node)&&p.push(e.node)}return p}function queryByAttribute(e,t,n,r){let i=queryAllByAttribute(e,t,n,r);if(i.length>1)throw getMultipleElementsFoundError(`Found multiple elements by [${e}=${n}]`,t);return i[0]||null}function makeSingleQuery(e,n){return(r,...i)=>{let a=e(r,...i);if(a.length>1){let e=S()===null?a.map(e=>getElementError(null,e).message).join(`
|
|
7
7
|
|
|
8
8
|
`):a.map(e=>t(e)).join(`
|
|
9
9
|
`);throw getMultipleElementsFoundError(`${n(r,...i)}
|
|
@@ -12,10 +12,10 @@ Here are the matching elements:
|
|
|
12
12
|
|
|
13
13
|
${e}`,r)}return a[0]||null}}function getSuggestionError(e,t){return f().getElementError(`A better query is available, try this:
|
|
14
14
|
${e.toString()}
|
|
15
|
-
`,t)}function makeGetAllQuery(e,t){return(n,...r)=>{let i=e(n,...r);if(!i.length)throw f().getElementError(t(n,...r),n);return i}}function makeFindQuery(e,t=`find`){return(n,r,i,a)=>{let find=t=>waitForInSpan(()=>e(n,r,i),{container:n,...a},t);return
|
|
16
|
-
`)}`}function nameOf(e){return normalize(
|
|
15
|
+
`,t)}function makeGetAllQuery(e,t){return(n,...r)=>{let i=e(n,...r);if(!i.length)throw f().getElementError(t(n,...r),n);return i}}function makeFindQuery(e,t=`find`){return(n,r,i,a)=>{let find=t=>waitForInSpan(()=>e(n,r,i),{container:n,...a},t);return I()?re(G,N(t,[r,i]),async e=>{let t=await find(e);return e.data.matches=matchCount(t),t}):find(null)}}const G=`testing-library.query`,matchCount=e=>Array.isArray(e)?e.length:+!!e;function traceQuery(e,t){return(n,...r)=>I()?ie(G,N(e,r),e=>{let i=t(n,...r);return e.data.matches=matchCount(i),i}):t(n,...r)}const wrapSingleQueryWithSuggestion=(e,t,n)=>(r,...i)=>{let a=e(r,...i),[{suggest:o=f().throwSuggestions}={}]=i.slice(-1);if(a&&o){let e=getSuggestedQuery(a,n);if(e&&!t.endsWith(e.queryName))throw getSuggestionError(e.toString(),r)}return a},wrapAllByQueryWithSuggestion=(e,t,n)=>(r,...i)=>{let a=e(r,...i),[{suggest:o=f().throwSuggestions}={}]=i.slice(-1);if(a.length&&o){let e=[...new Set(a.map(e=>getSuggestedQuery(e,n)?.toString()))];if(e.length===1&&!t.endsWith(getSuggestedQuery(a[0],n).queryName))throw getSuggestionError(e[0],r)}return a};function buildQueries(e,t,n){let r=wrapSingleQueryWithSuggestion(makeSingleQuery(e,t),e.name,`query`),i=makeGetAllQuery(e,n),a=makeSingleQuery(i,t),o=wrapSingleQueryWithSuggestion(a,e.name,`get`),s=wrapAllByQueryWithSuggestion(i,e.name.replace(`query`,`get`),`getAll`),c=e.name.startsWith(`queryAll`)?e.name.slice(8):``,l=makeFindQuery(wrapAllByQueryWithSuggestion(i,e.name,`findAll`),`findAll${c}`),u=makeFindQuery(wrapSingleQueryWithSuggestion(a,e.name,`find`),`find${c}`);return[traceQuery(`query${c}`,r),traceQuery(`getAll${c}`,s),traceQuery(`get${c}`,o),l,u]}const K=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]),q=/* @__PURE__ */ a(e=>e,`identity`);function normalize(e){return e.replace(/\s+/g,` `).trim()}function similarity(e,t){let n=normalize(e).toLowerCase(),r=normalize(t).toLowerCase();if(n===``||r===``)return-1;if(n===r)return 0;if(n.includes(r)||r.includes(n))return 1;let i=r.split(` `);for(let e=0;e<i.length;e++)if(i[e].length>2&&n.includes(i[e]))return 2;return-1}function closeness(e,t,n,r,i=!0){if((i?matches$1:fuzzyMatches)(e,t,n,r))return 0;if(typeof n==`string`||typeof n==`number`){let t=similarity(r(e),String(n));return t===-1?-1:t+1}return-1}function line(e,t,n,r,i){let a={role:t,name:n,props:x(e,t,!1,r),value:null,url:null,children:[],element:e};return`- ${c(a,80)} # ${i}`}function format(e,t){if(t.length===0)return``;t.sort((e,t)=>e.rank-t.rank);let n=t.slice(0,10).map(e=>e.line);return t.length>10&&n.push(`# … ${t.length-10} more`),`${e}:\n${n.join(`
|
|
16
|
+
`)}`}function nameOf(e){return normalize(L(e,void 0,5))}function roleCandidates(t,n){let r=e(t),i=[],a=n.name;for(let e=r.first;e!==null;e=P(e,r)){if(e.type!==E)continue;let t=R(e),r=z(e);if(B(e,n.role,n.queryFallbacks)){let o=nameOf(e),s=a===void 0?0:closeness(o,e.node,a,q),c=n.matchesState(e);s===0&&c?t&&!n.hidden&&i.push({line:line(e,r,o,!0,`hidden: ${d(e)} (or pass { hidden: true })`),rank:0}):s===0?i.push({line:line(e,r,o,t&&!n.hidden,`role and name match, state is not ${n.stateHint}`),rank:1}):(!t||n.hidden)&&i.push({line:line(e,r,o,!1,s>0?`similar name`:`same role, other name`),rank:s>0?2+s:10});continue}if(a===void 0)continue;if(!K.has(r)){let o=nameOf(e);if(o===``)continue;let s=closeness(o,e.node,a,q);s>=0&&i.push({line:line(e,r,o,t&&!n.hidden,`same name, role "${r}"`),rank:2+s});continue}let o=normalize(getNodeTextImpl(e));o!==``&&closeness(o,e.node,a,q)===0&&i.push({line:`- text: ${w(C(o,80))} # in ${_(e)}, which has no role: give it role="${n.role}" or use getByText`,rank:2})}return format(`Closest matches`,i)}function roleOrTag(e){let t=z(e);return K.has(t)?_(e):t}function textCandidates(t,n,r,i,a,o){if(typeof n==`function`)return``;let c=e(t),l=[],u=[];for(let e=c.first;e!==null;e=P(e,c)){if(e.type!==E||a&&typeof a==`string`&&s(e,a))continue;let t=getNodeTextImpl(e),c=t.trim()===``?-1:closeness(t,e.node,n,r,o);c===0?l.push({line:`- ${roleOrTag(e)}: ${w(C(r(t),80))} # matches, but not selector "${i}"`,rank:0}):c>0&&l.push({line:`- ${roleOrTag(e)}: ${w(C(r(t),80))} # similar text in ${_(e)}`,rank:1+c}),c!==0&&e.first!==null&&e.first!==e.last&&(o?matches$1:fuzzyMatches)(e.node.textContent,e.node,n,r)&&u.push(e)}for(let e=0;e<u.length;e++){let t=u[e],n=!1;for(let r=e+1;r<u.length&&!n;r++)isAncestor(t,u[r])&&(n=!0);n||l.push({line:`- ${roleOrTag(t)}: ${w(C(r(t.node.textContent),80))} # text split across child elements of ${_(t)}: use a function matcher or getByRole`,rank:0})}return format(`Closest matches`,l)}function isAncestor(e,t){for(let n=t.parent;n!==null;n=n.parent)if(n===e)return!0;return!1}const ve=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`]);function labelCandidates(t,n,r,i){if(typeof n==`function`)return``;let a=e(t),o=[];for(let e=a.first;e!==null;e=P(e,a)){if(e.type!==E)continue;let t=z(e);if(!ve.has(t))continue;let a=nameOf(e),s=R(e);if(a===``){let i=M(e,`placeholder`),a=i?`no label, placeholder ${w(i)}: use getByPlaceholderText or add a <label>`:`no label: add a <label>, aria-label or aria-labelledby`;o.push({line:line(e,t,``,s,a),rank:i&&closeness(i,e.node,n,r)>=0?1:5});continue}let c=closeness(a,e.node,n,r,i);o.push({line:line(e,t,a,s,c>=0?`similar label`:`labelled control`),rank:c>=0?2+c:10})}return format(`Labelled form controls`,o)}var ye=/* @__PURE__ */ i({findAllByLabelText:()=>xe,findByLabelText:()=>Se,getAllByLabelText:()=>Ce,getByLabelText:()=>we,queryAllByLabelText:()=>Te,queryByLabelText:()=>Y});function queryAllLabels(t){let n=e(t),r=[];for(let e=n.first;e!==null;e=P(e,n)){if(e.type!==E||e.name!==`label`&&e.name!==`input`)continue;let t=getLabelContentImpl(e);t!==null&&r.push({node:e.node,textToMatch:t})}return r}function queryAllLabelsByText(e,t,{exact:n=!0,trim:r,collapseWhitespace:i,normalizer:a}={}){let o=textMatcher(n,t,makeNormalizer({collapseWhitespace:i,trim:r,normalizer:a}));return queryAllLabels(e).filter(({node:e,textToMatch:t})=>o(t,e)).map(({node:e})=>e)}function queryAllByLabelText(t,r,{selector:i=`*`,exact:a=!0,collapseWhitespace:o,trim:c,normalizer:l}={}){n(t);let u=textMatcher(a,r,makeNormalizer({collapseWhitespace:o,trim:c,normalizer:l})),d=e(t),f=new LabelContext(d,!0),p=[],m=[];for(let e=d.first;e!==null;e=P(e,d))e.type===E&&(A(e,`aria-label`)!==null&&m.push(e),(A(e,`aria-labelledby`)!==null||f.labelsOf(e).length!==0)&&collectLabelled(f,e,i,u,p));for(let e=0;e<m.length;e++){let t=m[e];u(A(t,`aria-label`),t.node)&&p.push(t.node)}let h=Array.from(new Set(p));return i===`*`?h:h.filter(e=>s(e[T],i))}function collectLabelled(e,t,n,r,i){let a=getLabelsImpl(e,t,n);if(a.length===1){let e=a[0];e.formControl&&r(e.content,e.formControl.node)&&i.push(e.formControl.node),r(`${e.content||``}`,t.node)&&i.push(t.node);return}for(let e of a){if(!e.formControl)continue;let t=e.formControl.node;r(e.content,t)&&i.push(t)}let o=a.filter(e=>!!e.content).map(e=>e.content),s=t.node;r(o.join(` `),s)&&i.push(s),o.length>1&&o.forEach((e,t)=>{r(e,s)&&i.push(s);let n=[...o];n.splice(t,1),n.length>1&&r(n.join(` `),s)&&i.push(s)})}function getAllByLabelText(e,t,...n){let r=queryAllByLabelText(e,t,...n);if(!r.length){let r=queryAllLabelsByText(e,t,...n);if(r.length){let n=r.map(t=>getTagNameOfElementAssociatedWithLabelViaFor(e,t)).filter(e=>!!e);throw n.length?f().getElementError(n.map(e=>`Found a label with the text of: ${t}, however the element associated with this label (<${e} />) is non-labellable [https://html.spec.whatwg.org/multipage/forms.html#category-label]. If you really need to label a <${e} />, you can use aria-label or aria-labelledby instead.`).join(`
|
|
17
17
|
|
|
18
|
-
`),e):f().getElementError(`Found a label with the text of: ${t}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`,e)}throw f().getElementError(withLabelCandidates(`Unable to find a label with the text of: ${t}`,e,t,n[0]),e)}return r}function withLabelCandidates(e,t,n,r={}){if(S()===null)return e;let{exact:i=!0,trim:a,collapseWhitespace:o,normalizer:s}=r,c=labelCandidates(t,n,makeNormalizer({trim:a,collapseWhitespace:o,normalizer:s}),i);return c===``?e:`${e}\n\n${c}`}function getTagNameOfElementAssociatedWithLabelViaFor(t,n){let r=n.getAttribute(`for`);if(!r)return null;let i=new LabelContext(e(t)).byIdInContainer(r);return i?i.node.tagName.toLowerCase():null}const J=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the text of: ${t}`,`getMultipleError`),be=wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllByLabelText,J),queryAllByLabelText.name,`query`),xe=makeSingleQuery(getAllByLabelText,J),Se=makeFindQuery(wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`findAll`)),Ce=makeFindQuery(wrapSingleQueryWithSuggestion(xe,getAllByLabelText.name,`find`)),we=wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`getAll`),Te=wrapSingleQueryWithSuggestion(xe,getAllByLabelText.name,`get`),Ee=wrapAllByQueryWithSuggestion(queryAllByLabelText,queryAllByLabelText.name,`queryAll`);var De=/* @__PURE__ */ i({findAllByPlaceholderText:()=>Pe,findByPlaceholderText:()=>Fe,getAllByPlaceholderText:()=>Me,getByPlaceholderText:()=>Ne,queryAllByPlaceholderText:()=>Ae,queryByPlaceholderText:()=>je});function queryAllByPlaceholderText(...e){return n(e[0]),queryAllByAttribute(`placeholder`,...e)}const Oe=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the placeholder text of: ${t}`,`getMultipleError`),ke=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the placeholder text of: ${t}`,`getMissingError`),Ae=wrapAllByQueryWithSuggestion(queryAllByPlaceholderText,queryAllByPlaceholderText.name,`queryAll`),[je,Me,Ne,Pe,Fe]=buildQueries(queryAllByPlaceholderText,Oe,ke);var Ie=/* @__PURE__ */ i({findAllByText:()=>Ue,findByText:()=>We,getAllByText:()=>Ve,getByText:()=>He,queryAllByText:()=>ze,queryByText:()=>Be});function isScriptStyleIgnore(e){return e===`script, style`||e===`script,style`}function isScriptOrStyle(e){let t=e.name;return t===`script`||t===`style`}function queryAllByText(t,r,{selector:i=`*`,exact:a=!0,collapseWhitespace:o,trim:c,ignore:l=f().defaultIgnore,normalizer:u}={}){n(t);let d=textMatcher(a,r,makeNormalizer({collapseWhitespace:o,trim:c,normalizer:u})),p=e(t),m=i===`*`,h=isScriptStyleIgnore(l),g=[],visit=e=>{(m||s(e,i))&&(l&&(h?isScriptOrStyle(e):s(e,l))||d(getNodeTextImpl(e),e.node)&&g.push(e.node))};p.type===E&&visit(p);for(let e=p.first;e!==null;e=P(e,p))e.type===E&&visit(e);return g}const Le=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the text: ${t}`,`getMultipleError`),Re=/* @__PURE__ */ a((e,t,n={})=>{let{collapseWhitespace:r,trim:i,normalizer:a,selector:o}=n,s=makeNormalizer({collapseWhitespace:r,trim:i,normalizer:a}),c=s(t.toString()),l=c!==t.toString(),u=(o??`*`)!==`*`,d=`Unable to find an element with the text: ${l?`${c} (normalized from '${t}')`:t}${u?`, which matches selector '${o}'`:``}. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.`;if(S()===null)return d;let{exact:p=!0,ignore:m=f().defaultIgnore}=n,h=textCandidates(e,t,s,o??`*`,m,p);return h===``?d:`${d}\n\n${h}`},`getMissingError`),ze=wrapAllByQueryWithSuggestion(queryAllByText,queryAllByText.name,`queryAll`),[Be,Ve,He,Ue,We]=buildQueries(queryAllByText,Le,Re);var Ge=/* @__PURE__ */ i({findAllByDisplayValue:()=>Qe,findByDisplayValue:()=>$e,getAllByDisplayValue:()=>Xe,getByDisplayValue:()=>Ze,queryAllByDisplayValue:()=>Je,queryByDisplayValue:()=>Ye});function queryAllByDisplayValue(t,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){n(t);let c=textMatcher(i,r,makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s})),l=e(t),u=[];for(let e=l.first;e!==null;e=P(e,l)){if(e.type!==E)continue;let t=e.name;if(t!==`input`&&t!==`textarea`&&t!==`select`)continue;let n=e.node;if(e.tag===O.select&&e.ns===D){let e=n.options,t=!1;for(let n=0;n<e.length;n++){let r=e[n];if(r.selected&&c(getNodeTextImpl(r[T]),r)){t=!0;break}}t&&u.push(n)}else c(n.value,n)&&u.push(n)}return u}const Ke=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the display value: ${t}.`,`getMultipleError`),qe=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the display value: ${t}.`,`getMissingError`),Je=wrapAllByQueryWithSuggestion(queryAllByDisplayValue,queryAllByDisplayValue.name,`queryAll`),[Ye,Xe,Ze,Qe,$e]=buildQueries(queryAllByDisplayValue,Ke,qe);var et=/* @__PURE__ */ i({findAllByAltText:()=>ct,findByAltText:()=>lt,getAllByAltText:()=>ot,getByAltText:()=>st,queryAllByAltText:()=>it,queryByAltText:()=>at});const tt=/^(img|input|area|.+-.+)$/i;function queryAllByAltText(e,t,r={}){return n(e),queryAllByAttribute(`alt`,e,t,r).filter(e=>tt.test(e.tagName))}const nt=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the alt text: ${t}`,`getMultipleError`),rt=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the alt text: ${t}`,`getMissingError`),it=wrapAllByQueryWithSuggestion(queryAllByAltText,queryAllByAltText.name,`queryAll`),[at,ot,st,ct,lt]=buildQueries(queryAllByAltText,nt,rt);var ut=/* @__PURE__ */ i({findAllByTitle:()=>_t,findByTitle:()=>vt,getAllByTitle:()=>ht,getByTitle:()=>gt,queryAllByTitle:()=>pt,queryByTitle:()=>mt});function isSvgTitle(e){let t=e.parent;return j(e.prefix===null?e.name:e.prefix+`:`+e.name)===`title`&&t!==null&&t.type===E&&j(t.prefix===null?t.name:t.prefix+`:`+t.name)===`svg`}function queryAllByTitle(t,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){n(t);let c=textMatcher(i,r,makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s})),l=e(t),u=[];for(let e=l.first;e!==null;e=P(e,l)){if(e.type!==E)continue;let t=e.attrs===null?null:M(e,`title`),n=e.name===`title`&&e.parent!==null&&e.parent.type===E&&e.parent.name===`svg`;(t!==null||n)&&(c(t,e.node)||isSvgTitle(e)&&c(getNodeTextImpl(e),e.node))&&u.push(e.node)}return u}const dt=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the title: ${t}.`,`getMultipleError`),ft=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the title: ${t}.`,`getMissingError`),pt=wrapAllByQueryWithSuggestion(queryAllByTitle,queryAllByTitle.name,`queryAll`),[mt,ht,gt,_t,vt]=buildQueries(queryAllByTitle,dt,ft);var yt=/* @__PURE__ */ i({findAllByRole:()=>Et,findByRole:()=>Dt,getAllByRole:()=>wt,getByRole:()=>Tt,queryAllByRole:()=>St,queryByRole:()=>Ct});const identity=e=>e;function assertSupported(e,t){if(!U.roleSupportsProp(e,t))throw Error(`"${t}" is not supported on role "${e}".`)}function queryAllByRole(t,r,{hidden:i=f().defaultHidden,name:a,description:o,queryFallbacks:s=!1,selected:c,busy:l,checked:u,pressed:d,current:p,level:m,expanded:h,value:{now:g,min:_,max:v,text:y}={}}={}){if(n(t),c!==void 0&&assertSupported(r,`aria-selected`),l!==void 0&&assertSupported(r,`aria-busy`),u!==void 0&&assertSupported(r,`aria-checked`),d!==void 0&&assertSupported(r,`aria-pressed`),p!==void 0&&assertSupported(r,`aria-current`),m!==void 0&&r!==`heading`)throw Error(`Role "${r}" cannot have "level" property.`);g!==void 0&&assertSupported(r,`aria-valuenow`),v!==void 0&&assertSupported(r,`aria-valuemax`),_!==void 0&&assertSupported(r,`aria-valuemin`),y!==void 0&&assertSupported(r,`aria-valuetext`),h!==void 0&&assertSupported(r,`aria-expanded`);let b={selected:c,busy:l,checked:u,pressed:d,current:p,level:m,expanded:h,valueNow:g,valueMin:_,valueMax:v,valueText:y},x=f().computedStyleSupportsPseudoElements,S=e(t),C=[],w=styleOverride(S),T=w!==null&&i===!1?/* @__PURE__ */ new Map:null;for(let e=S.first;e!==null;e=P(e,S))e.type===E&&U.roleMatches(e,r,s)&&matchesState(e,b)&&(i===!1&&(w===null?isInaccessibleImpl$1(e):U.isInaccessibleWithStyle(e,w,T))||(a===void 0||matches$1(U.computeAccessibleName(e,x,w),e.node,a,identity))&&(o===void 0||matches$1(U.computeAccessibleDescription(e,x,w),e.node,o,identity))&&C.push(e.node));return C}function matchesState(e,t){if(t.selected!==void 0)return t.selected===computeAriaSelected$1(e);if(t.busy!==void 0)return t.busy===computeAriaBusy$1(e);if(t.checked!==void 0)return t.checked===computeAriaChecked(e);if(t.pressed!==void 0)return t.pressed===computeAriaPressed(e);if(t.current!==void 0)return t.current===computeAriaCurrent$1(e);if(t.expanded!==void 0)return t.expanded===computeAriaExpanded$1(e);if(t.level!==void 0)return t.level===computeHeadingLevelImpl(e);if(t.valueNow!==void 0||t.valueMax!==void 0||t.valueMin!==void 0||t.valueText!==void 0){let n=!0;return t.valueNow!==void 0&&(n&&=t.valueNow===computeAriaValueNow(e)),t.valueMax!==void 0&&(n&&=t.valueMax===computeAriaValueMax(e)),t.valueMin!==void 0&&(n&&=t.valueMin===computeAriaValueMin(e)),t.valueText!==void 0&&(n&&=matches$1(computeAriaValueText(e)??null,e.node,t.valueText,identity)),n}return!0}const getNameHint=e=>{let t=``;return t=e===void 0?``:typeof e==`string`?` and name "${e}"`:` and name \`${e}\``,t},bt=/* @__PURE__ */ a((e,t,{name:n}={})=>`Found multiple elements with the role "${t}"${getNameHint(n)}`,`getMultipleError`),xt=/* @__PURE__ */ a((e,t,n={})=>{let{hidden:r=f().defaultHidden,name:i,description:a}=n;if(S()!==null)return agentMissingError(e,t,n,r);if(f()._disableExpensiveErrorDiagnostics)return`Unable to find role="${t}"${getNameHint(i)}`;let o=``;Array.from(e.children).forEach(e=>{o+=prettyRoles(e,{hidden:r,includeDescription:a!==void 0})});let s;s=o.length===0?r===!1?"There are no accessible roles. But there might be some inaccessible roles. If you wish to access them, then set the `hidden` option to `true`. Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole":`There are no available roles.`:`
|
|
18
|
+
`),e):f().getElementError(`Found a label with the text of: ${t}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`,e)}throw f().getElementError(withLabelCandidates(`Unable to find a label with the text of: ${t}`,e,t,n[0]),e)}return r}function withLabelCandidates(e,t,n,r={}){if(S()===null)return e;let{exact:i=!0,trim:a,collapseWhitespace:o,normalizer:s}=r,c=labelCandidates(t,n,makeNormalizer({trim:a,collapseWhitespace:o,normalizer:s}),i);return c===``?e:`${e}\n\n${c}`}function getTagNameOfElementAssociatedWithLabelViaFor(t,n){let r=n.getAttribute(`for`);if(!r)return null;let i=new LabelContext(e(t)).byIdInContainer(r);return i?i.node.tagName.toLowerCase():null}const J=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the text of: ${t}`,`getMultipleError`),Y=wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllByLabelText,J),queryAllByLabelText.name,`query`),be=makeSingleQuery(getAllByLabelText,J),xe=makeFindQuery(wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`findAll`)),Se=makeFindQuery(wrapSingleQueryWithSuggestion(be,getAllByLabelText.name,`find`)),Ce=wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`getAll`),we=wrapSingleQueryWithSuggestion(be,getAllByLabelText.name,`get`),Te=wrapAllByQueryWithSuggestion(queryAllByLabelText,queryAllByLabelText.name,`queryAll`);var Ee=/* @__PURE__ */ i({findAllByPlaceholderText:()=>Ne,findByPlaceholderText:()=>Pe,getAllByPlaceholderText:()=>je,getByPlaceholderText:()=>Me,queryAllByPlaceholderText:()=>ke,queryByPlaceholderText:()=>Ae});function queryAllByPlaceholderText(...e){return n(e[0]),queryAllByAttribute(`placeholder`,...e)}const De=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the placeholder text of: ${t}`,`getMultipleError`),Oe=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the placeholder text of: ${t}`,`getMissingError`),ke=wrapAllByQueryWithSuggestion(queryAllByPlaceholderText,queryAllByPlaceholderText.name,`queryAll`),[Ae,je,Me,Ne,Pe]=buildQueries(queryAllByPlaceholderText,De,Oe);var Fe=/* @__PURE__ */ i({findAllByText:()=>He,findByText:()=>Ue,getAllByText:()=>Be,getByText:()=>Ve,queryAllByText:()=>Re,queryByText:()=>ze});function isScriptStyleIgnore(e){return e===`script, style`||e===`script,style`}function isScriptOrStyle(e){let t=e.name;return t===`script`||t===`style`}function queryAllByText(t,r,{selector:i=`*`,exact:a=!0,collapseWhitespace:o,trim:c,ignore:l=f().defaultIgnore,normalizer:u}={}){n(t);let d=textMatcher(a,r,makeNormalizer({collapseWhitespace:o,trim:c,normalizer:u})),p=e(t),m=i===`*`,h=isScriptStyleIgnore(l),g=[],visit=e=>{(m||s(e,i))&&(l&&(h?isScriptOrStyle(e):s(e,l))||d(getNodeTextImpl(e),e.node)&&g.push(e.node))};p.type===E&&visit(p);for(let e=p.first;e!==null;e=P(e,p))e.type===E&&visit(e);return g}const Ie=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the text: ${t}`,`getMultipleError`),Le=/* @__PURE__ */ a((e,t,n={})=>{let{collapseWhitespace:r,trim:i,normalizer:a,selector:o}=n,s=makeNormalizer({collapseWhitespace:r,trim:i,normalizer:a}),c=s(t.toString()),l=c!==t.toString(),u=(o??`*`)!==`*`,d=`Unable to find an element with the text: ${l?`${c} (normalized from '${t}')`:t}${u?`, which matches selector '${o}'`:``}. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.`;if(S()===null)return d;let{exact:p=!0,ignore:m=f().defaultIgnore}=n,h=textCandidates(e,t,s,o??`*`,m,p);return h===``?d:`${d}\n\n${h}`},`getMissingError`),Re=wrapAllByQueryWithSuggestion(queryAllByText,queryAllByText.name,`queryAll`),[ze,Be,Ve,He,Ue]=buildQueries(queryAllByText,Ie,Le);var We=/* @__PURE__ */ i({findAllByDisplayValue:()=>Ze,findByDisplayValue:()=>Qe,getAllByDisplayValue:()=>Ye,getByDisplayValue:()=>Xe,queryAllByDisplayValue:()=>qe,queryByDisplayValue:()=>Je});function queryAllByDisplayValue(t,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){n(t);let c=textMatcher(i,r,makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s})),l=e(t),u=[];for(let e=l.first;e!==null;e=P(e,l)){if(e.type!==E)continue;let t=e.name;if(t!==`input`&&t!==`textarea`&&t!==`select`)continue;let n=e.node;if(e.tag===O.select&&e.ns===D){let e=n.options,t=!1;for(let n=0;n<e.length;n++){let r=e[n];if(r.selected&&c(getNodeTextImpl(r[T]),r)){t=!0;break}}t&&u.push(n)}else c(n.value,n)&&u.push(n)}return u}const Ge=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the display value: ${t}.`,`getMultipleError`),Ke=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the display value: ${t}.`,`getMissingError`),qe=wrapAllByQueryWithSuggestion(queryAllByDisplayValue,queryAllByDisplayValue.name,`queryAll`),[Je,Ye,Xe,Ze,Qe]=buildQueries(queryAllByDisplayValue,Ge,Ke);var $e=/* @__PURE__ */ i({findAllByAltText:()=>st,findByAltText:()=>ct,getAllByAltText:()=>at,getByAltText:()=>ot,queryAllByAltText:()=>rt,queryByAltText:()=>it});const et=/^(img|input|area|.+-.+)$/i;function queryAllByAltText(e,t,r={}){return n(e),queryAllByAttribute(`alt`,e,t,r).filter(e=>et.test(e.tagName))}const tt=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the alt text: ${t}`,`getMultipleError`),nt=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the alt text: ${t}`,`getMissingError`),rt=wrapAllByQueryWithSuggestion(queryAllByAltText,queryAllByAltText.name,`queryAll`),[it,at,ot,st,ct]=buildQueries(queryAllByAltText,tt,nt);var lt=/* @__PURE__ */ i({findAllByTitle:()=>gt,findByTitle:()=>_t,getAllByTitle:()=>mt,getByTitle:()=>ht,queryAllByTitle:()=>ft,queryByTitle:()=>pt});function isSvgTitle(e){let t=e.parent;return j(e.prefix===null?e.name:e.prefix+`:`+e.name)===`title`&&t!==null&&t.type===E&&j(t.prefix===null?t.name:t.prefix+`:`+t.name)===`svg`}function queryAllByTitle(t,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){n(t);let c=textMatcher(i,r,makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s})),l=e(t),u=[];for(let e=l.first;e!==null;e=P(e,l)){if(e.type!==E)continue;let t=e.attrs===null?null:M(e,`title`),n=e.name===`title`&&e.parent!==null&&e.parent.type===E&&e.parent.name===`svg`;(t!==null||n)&&(c(t,e.node)||isSvgTitle(e)&&c(getNodeTextImpl(e),e.node))&&u.push(e.node)}return u}const ut=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the title: ${t}.`,`getMultipleError`),dt=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the title: ${t}.`,`getMissingError`),ft=wrapAllByQueryWithSuggestion(queryAllByTitle,queryAllByTitle.name,`queryAll`),[pt,mt,ht,gt,_t]=buildQueries(queryAllByTitle,ut,dt);var vt=/* @__PURE__ */ i({findAllByRole:()=>Tt,findByRole:()=>Et,getAllByRole:()=>Ct,getByRole:()=>wt,queryAllByRole:()=>xt,queryByRole:()=>St});const identity=e=>e;function assertSupported(e,t){if(!U.roleSupportsProp(e,t))throw Error(`"${t}" is not supported on role "${e}".`)}function queryAllByRole(t,r,{hidden:i=f().defaultHidden,name:a,description:o,queryFallbacks:s=!1,selected:c,busy:l,checked:u,pressed:d,current:p,level:m,expanded:h,value:{now:g,min:_,max:v,text:y}={}}={}){if(n(t),c!==void 0&&assertSupported(r,`aria-selected`),l!==void 0&&assertSupported(r,`aria-busy`),u!==void 0&&assertSupported(r,`aria-checked`),d!==void 0&&assertSupported(r,`aria-pressed`),p!==void 0&&assertSupported(r,`aria-current`),m!==void 0&&r!==`heading`)throw Error(`Role "${r}" cannot have "level" property.`);g!==void 0&&assertSupported(r,`aria-valuenow`),v!==void 0&&assertSupported(r,`aria-valuemax`),_!==void 0&&assertSupported(r,`aria-valuemin`),y!==void 0&&assertSupported(r,`aria-valuetext`),h!==void 0&&assertSupported(r,`aria-expanded`);let b={selected:c,busy:l,checked:u,pressed:d,current:p,level:m,expanded:h,valueNow:g,valueMin:_,valueMax:v,valueText:y},x=f().computedStyleSupportsPseudoElements,S=e(t),C=[],w=styleOverride(S),T=w!==null&&i===!1?/* @__PURE__ */ new Map:null;for(let e=S.first;e!==null;e=P(e,S))e.type===E&&U.roleMatches(e,r,s)&&matchesState(e,b)&&(i===!1&&(w===null?isInaccessibleImpl$1(e):U.isInaccessibleWithStyle(e,w,T))||(a===void 0||matches$1(U.computeAccessibleName(e,x,w),e.node,a,identity))&&(o===void 0||matches$1(U.computeAccessibleDescription(e,x,w),e.node,o,identity))&&C.push(e.node));return C}function matchesState(e,t){if(t.selected!==void 0)return t.selected===computeAriaSelected$1(e);if(t.busy!==void 0)return t.busy===computeAriaBusy$1(e);if(t.checked!==void 0)return t.checked===computeAriaChecked(e);if(t.pressed!==void 0)return t.pressed===computeAriaPressed(e);if(t.current!==void 0)return t.current===computeAriaCurrent$1(e);if(t.expanded!==void 0)return t.expanded===computeAriaExpanded$1(e);if(t.level!==void 0)return t.level===computeHeadingLevelImpl(e);if(t.valueNow!==void 0||t.valueMax!==void 0||t.valueMin!==void 0||t.valueText!==void 0){let n=!0;return t.valueNow!==void 0&&(n&&=t.valueNow===computeAriaValueNow(e)),t.valueMax!==void 0&&(n&&=t.valueMax===computeAriaValueMax(e)),t.valueMin!==void 0&&(n&&=t.valueMin===computeAriaValueMin(e)),t.valueText!==void 0&&(n&&=matches$1(computeAriaValueText(e)??null,e.node,t.valueText,identity)),n}return!0}const getNameHint=e=>{let t=``;return t=e===void 0?``:typeof e==`string`?` and name "${e}"`:` and name \`${e}\``,t},yt=/* @__PURE__ */ a((e,t,{name:n}={})=>`Found multiple elements with the role "${t}"${getNameHint(n)}`,`getMultipleError`),bt=/* @__PURE__ */ a((e,t,n={})=>{let{hidden:r=f().defaultHidden,name:i,description:a}=n;if(S()!==null)return agentMissingError(e,t,n,r);if(f()._disableExpensiveErrorDiagnostics)return`Unable to find role="${t}"${getNameHint(i)}`;let o=``;Array.from(e.children).forEach(e=>{o+=prettyRoles(e,{hidden:r,includeDescription:a!==void 0})});let s;s=o.length===0?r===!1?"There are no accessible roles. But there might be some inaccessible roles. If you wish to access them, then set the `hidden` option to `true`. Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole":`There are no available roles.`:`
|
|
19
19
|
Here are the ${r===!1?`accessible`:`available`} roles:
|
|
20
20
|
|
|
21
21
|
${o.replace(/\n/g,`
|
|
@@ -25,5 +25,5 @@ Here are the ${r===!1?`accessible`:`available`} roles:
|
|
|
25
25
|
`.trim();let c=``;c=i===void 0?``:typeof i==`string`?` and name "${i}"`:` and name \`${i}\``;let l=``;return l=a===void 0?``:typeof a==`string`?` and description "${a}"`:` and description \`${a}\``,`
|
|
26
26
|
Unable to find an ${r===!1?`accessible `:``}element with the role "${t}"${c}${l}
|
|
27
27
|
|
|
28
|
-
${s}`.trim()},`getMissingError`);function agentMissingError(e,t,n,r){let{name:i,description:a,queryFallbacks:o=!1,value:{now:s,min:c,max:l,text:u}={}}=n,{selected:d,busy:f,checked:p,pressed:m,current:h,level:g,expanded:_}=n,v={selected:d,busy:f,checked:p,pressed:m,current:h,level:g,expanded:_,valueNow:s,valueMin:c,valueMax:l,valueText:u},y=Object.entries({selected:d,busy:f,checked:p,pressed:m,current:h,level:g,expanded:_,value:n.value}).filter(([,e])=>e!==void 0).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`, `),b=a===void 0?``:typeof a==`string`?` and description "${a}"`:` and description \`${a}\``,x=`Unable to find an ${r===!1?`accessible `:``}element with the role "${t}"${getNameHint(i)}${b}`,S=roleCandidates(e,{role:String(t),name:i,hidden:r,queryFallbacks:o,matchesState:e=>matchesState(e,v),stateHint:`{ ${y} }`});return S===``?x:`${x}\n\n${S}`}const St=wrapAllByQueryWithSuggestion(queryAllByRole,queryAllByRole.name,`queryAll`),[Ct,wt,Tt,Et,Dt]=buildQueries(queryAllByRole,bt,xt);var Ot=/* @__PURE__ */ i({findAllByTestId:()=>Mt,findByTestId:()=>Nt,getAllByTestId:()=>Y,getByTestId:()=>jt,queryAllByTestId:()=>kt,queryByTestId:()=>At});const getTestIdAttribute=()=>f().testIdAttribute;function queryAllByTestId(...e){return n(e[0]),queryAllByAttribute(getTestIdAttribute(),...e)}const getMultipleError=(e,t)=>`Found multiple elements by: [${getTestIdAttribute()}="${t}"]`,getMissingError=(e,t)=>`Unable to find an element by: [${getTestIdAttribute()}="${t}"]`,kt=wrapAllByQueryWithSuggestion(queryAllByTestId,queryAllByTestId.name,`queryAll`),[At,Y,jt,Mt,Nt]=buildQueries(queryAllByTestId,getMultipleError,getMissingError);function build(){let e={},t=[[ye,`LabelText`],[De,`PlaceholderText`],[Ie,`Text`],[Ge,`DisplayValue`],[et,`AltText`],[ut,`Title`],[yt,`Role`],[Ot,`TestId`]];for(let[n,r]of t)for(let t of[`findAllBy`,`findBy`,`getAllBy`,`getBy`,`queryAllBy`,`queryBy`])e[t+r]=n[t+r];return e}const X=build();function getQueriesForElement(e,t=X,n={}){return Object.keys(t).reduce((n,r)=>(n[r]=t[r].bind(null,e),n),n)}const isRemoved=e=>!e||Array.isArray(e)&&!e.length;function initialCheck(e){if(isRemoved(e))throw Error(`The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.`)}async function waitForElementToBeRemoved(callback,e){let t=/* @__PURE__ */ Error(`Timed out in waitForElementToBeRemoved.`);if(typeof callback!=`function`){initialCheck(callback);let e=(Array.isArray(callback)?callback:[callback]).map(e=>{let t=e.parentElement;if(t===null)return()=>null;for(;t.parentElement;)t=t.parentElement;return()=>t.contains(e)?e:null});callback=()=>e.map(e=>e()).filter(Boolean)}let n=callback;return initialCheck(n()),waitFor(()=>{let e;try{e=n()}catch(e){if(e.name===`TestingLibraryElementError`)return;throw e}if(!isRemoved(e))throw t},e)}const Pt={copy:{EventType:`ClipboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},cut:{EventType:`ClipboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},paste:{EventType:`ClipboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},compositionEnd:{EventType:`CompositionEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},compositionStart:{EventType:`CompositionEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},compositionUpdate:{EventType:`CompositionEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},keyDown:{EventType:`KeyboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,charCode:0,composed:!0}},keyPress:{EventType:`KeyboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,charCode:0,composed:!0}},keyUp:{EventType:`KeyboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,charCode:0,composed:!0}},focus:{EventType:`FocusEvent`,defaultInit:{bubbles:!1,cancelable:!1,composed:!0}},blur:{EventType:`FocusEvent`,defaultInit:{bubbles:!1,cancelable:!1,composed:!0}},focusIn:{EventType:`FocusEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},focusOut:{EventType:`FocusEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},change:{EventType:`Event`,defaultInit:{bubbles:!0,cancelable:!1}},input:{EventType:`InputEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},invalid:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!0}},submit:{EventType:`Event`,defaultInit:{bubbles:!0,cancelable:!0}},reset:{EventType:`Event`,defaultInit:{bubbles:!0,cancelable:!0}},click:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,button:0,composed:!0}},contextMenu:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},dblClick:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},drag:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},dragEnd:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},dragEnter:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},dragExit:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},dragLeave:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},dragOver:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},dragStart:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},drop:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseDown:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseEnter:{EventType:`MouseEvent`,defaultInit:{bubbles:!1,cancelable:!1,composed:!0}},mouseLeave:{EventType:`MouseEvent`,defaultInit:{bubbles:!1,cancelable:!1,composed:!0}},mouseMove:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseOut:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseOver:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseUp:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},select:{EventType:`Event`,defaultInit:{bubbles:!0,cancelable:!1}},touchCancel:{EventType:`TouchEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},touchEnd:{EventType:`TouchEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},touchMove:{EventType:`TouchEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},touchStart:{EventType:`TouchEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},resize:{EventType:`UIEvent`,defaultInit:{bubbles:!1,cancelable:!1}},scroll:{EventType:`UIEvent`,defaultInit:{bubbles:!1,cancelable:!1}},wheel:{EventType:`WheelEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},abort:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},canPlay:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},canPlayThrough:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},durationChange:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},emptied:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},encrypted:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},ended:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},loadedData:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},loadedMetadata:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},loadStart:{EventType:`ProgressEvent`,defaultInit:{bubbles:!1,cancelable:!1}},pause:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},play:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},playing:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},progress:{EventType:`ProgressEvent`,defaultInit:{bubbles:!1,cancelable:!1}},rateChange:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},seeked:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},seeking:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},stalled:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},suspend:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},timeUpdate:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},volumeChange:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},waiting:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},load:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},error:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},animationStart:{EventType:`AnimationEvent`,defaultInit:{bubbles:!0,cancelable:!1}},animationEnd:{EventType:`AnimationEvent`,defaultInit:{bubbles:!0,cancelable:!1}},animationIteration:{EventType:`AnimationEvent`,defaultInit:{bubbles:!0,cancelable:!1}},transitionCancel:{EventType:`TransitionEvent`,defaultInit:{bubbles:!0,cancelable:!1}},transitionEnd:{EventType:`TransitionEvent`,defaultInit:{bubbles:!0,cancelable:!0}},transitionRun:{EventType:`TransitionEvent`,defaultInit:{bubbles:!0,cancelable:!1}},transitionStart:{EventType:`TransitionEvent`,defaultInit:{bubbles:!0,cancelable:!1}},pointerOver:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerEnter:{EventType:`PointerEvent`,defaultInit:{bubbles:!1,cancelable:!1}},pointerDown:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerMove:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerUp:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerCancel:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},pointerOut:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerLeave:{EventType:`PointerEvent`,defaultInit:{bubbles:!1,cancelable:!1}},gotPointerCapture:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},lostPointerCapture:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},popState:{EventType:`PopStateEvent`,defaultInit:{bubbles:!0,cancelable:!1}},offline:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},online:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},pageHide:{EventType:`PageTransitionEvent`,defaultInit:{bubbles:!0,cancelable:!0}},pageShow:{EventType:`PageTransitionEvent`,defaultInit:{bubbles:!0,cancelable:!0}}},Ft={doubleClick:`dblClick`};function fireEvent_(e,t){return L()&&t&&e?re(`testing-library.fire_event`,`fireEvent.${t.type}(${te(e)})`,()=>fireEventUntraced(e,t)):fireEventUntraced(e,t)}function fireEventUntraced(e,t){return f().eventWrapper(()=>{if(!t)throw Error(`Unable to fire an event - please provide an event object.`);if(!e)throw Error(`Unable to fire a "${t.type}" event - please provide a DOM element.`);return e.dispatchEvent(t)})}function createEvent_(e,t,n,{EventType:r=`Event`,defaultInit:i={}}={}){if(!t)throw Error(`Unable to fire a "${e}" event - please provide a DOM element.`);let a={...i,...n},{target:{value:o,files:s,...c}={}}=a;o!==void 0&&setNativeValue(t,o),s!==void 0&&Object.defineProperty(t,"files",{configurable:!0,enumerable:!0,writable:!0,value:s}),Object.assign(t,c);let l=m(t),u=l[r]||l.Event,d;if(typeof u==`function`)d=new u(e,a);else{d=l.document.createEvent(r);let{bubbles:t,cancelable:n,detail:i,...o}=a;d.initEvent(e,t,n,i),Object.keys(o).forEach(e=>{d[e]=o[e]})}return[`dataTransfer`,`clipboardData`].forEach(e=>{let t=a[e];typeof t==`object`&&(typeof l.DataTransfer==`function`?Object.defineProperty(d,e,{value:Object.getOwnPropertyNames(t).reduce((e,n)=>(Object.defineProperty(e,n,{value:t[n]}),e),new l.DataTransfer)}):Object.defineProperty(d,e,{value:t}))}),d}function setNativeValue(e,t){let{set:n}=Object.getOwnPropertyDescriptor(e,`value`)||{},r=Object.getPrototypeOf(e),{set:i}=Object.getOwnPropertyDescriptor(r,`value`)||{};if(i&&n!==i)i.call(e,t);else if(n)n.call(e,t);else throw Error(`The given element does not have a value setter`)}Object.defineProperty(fireEvent_,"name",{value:`fireEvent`}),Object.defineProperty(createEvent_,"name",{value:`createEvent`});const Z=fireEvent_,Q=createEvent_;Object.keys(Pt).forEach(e=>{let{EventType:t,defaultInit:n}=Pt[e],r=e.toLowerCase();Q[e]=(e,i)=>Q(r,e,i,{EventType:t,defaultInit:n}),Z[e]=(t,n)=>Z(t,Q[e](t,n))}),Object.keys(Ft).forEach(e=>{let t=Ft[e];Z[e]=(...e)=>Z[t](...e)});const It=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$`;var BitWriter=class{out=[];val=0;pos=0;write(e,t){for(let n=0;n<t;n++)this.val=this.val<<1|e&1,this.pos===5?(this.pos=0,this.out.push(It.charAt(this.val)),this.val=0):this.pos++,e>>=1}flush(){for(;;){if(this.val<<=1,this.pos===5){this.out.push(It.charAt(this.val));break}this.pos++}return this.out.join(``)}};function compressToEncodedURIComponent(e){if(e==null)return``;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=new BitWriter,i=``,a=2,o=3,s=2,emit=e=>{if(n.has(e)){let t=e.charCodeAt(0);t<256?(r.write(0,s),r.write(t,8)):(r.write(1,s),r.write(t,16)),a--,a===0&&(a=2**s,s++),n.delete(e)}else r.write(t.get(e),s);a--,a===0&&(a=2**s,s++)};for(let r=0;r<e.length;r++){let a=e.charAt(r);t.has(a)||(t.set(a,o++),n.add(a));let s=i+a;t.has(s)?i=s:(emit(i),t.set(s,o++),i=a)}return i!==``&&emit(i),r.write(2,s),r.flush()}function unindent(e){return e.replace(/[ \t]*[\n][ \t]*/g,`
|
|
29
|
-
`)}function encode(e){return compressToEncodedURIComponent(unindent(e))}function getPlaygroundUrl(e){return`https://testing-playground.com/#markup=${encode(e)}`}const debug=(e,t,n)=>Array.isArray(e)?e.forEach(e=>g(e,t,n)):g(e,t,n),logTestingPlaygroundURL=(e=o().body)=>{if(!e||!(`innerHTML`in e)){console.log(`The element you're providing isn't a valid DOM element.`);return}if(!e.innerHTML){console.log(`The provided element doesn't have any children.`);return}let t=getPlaygroundUrl(e.innerHTML);return console.log(`Open this URL in your browser\n\n${t}`),t}
|
|
28
|
+
${s}`.trim()},`getMissingError`);function agentMissingError(e,t,n,r){let{name:i,description:a,queryFallbacks:o=!1,value:{now:s,min:c,max:l,text:u}={}}=n,{selected:d,busy:f,checked:p,pressed:m,current:h,level:g,expanded:_}=n,v={selected:d,busy:f,checked:p,pressed:m,current:h,level:g,expanded:_,valueNow:s,valueMin:c,valueMax:l,valueText:u},y=Object.entries({selected:d,busy:f,checked:p,pressed:m,current:h,level:g,expanded:_,value:n.value}).filter(([,e])=>e!==void 0).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`, `),b=a===void 0?``:typeof a==`string`?` and description "${a}"`:` and description \`${a}\``,x=`Unable to find an ${r===!1?`accessible `:``}element with the role "${t}"${getNameHint(i)}${b}`,S=roleCandidates(e,{role:String(t),name:i,hidden:r,queryFallbacks:o,matchesState:e=>matchesState(e,v),stateHint:`{ ${y} }`});return S===``?x:`${x}\n\n${S}`}const xt=wrapAllByQueryWithSuggestion(queryAllByRole,queryAllByRole.name,`queryAll`),[St,Ct,wt,Tt,Et]=buildQueries(queryAllByRole,yt,bt);var Dt=/* @__PURE__ */ i({findAllByTestId:()=>jt,findByTestId:()=>Mt,getAllByTestId:()=>X,getByTestId:()=>At,queryAllByTestId:()=>Ot,queryByTestId:()=>kt});const getTestIdAttribute=()=>f().testIdAttribute;function queryAllByTestId(...e){return n(e[0]),queryAllByAttribute(getTestIdAttribute(),...e)}const getMultipleError=(e,t)=>`Found multiple elements by: [${getTestIdAttribute()}="${t}"]`,getMissingError=(e,t)=>`Unable to find an element by: [${getTestIdAttribute()}="${t}"]`,Ot=wrapAllByQueryWithSuggestion(queryAllByTestId,queryAllByTestId.name,`queryAll`),[kt,X,At,jt,Mt]=buildQueries(queryAllByTestId,getMultipleError,getMissingError);function build(){let e={},t=[[ye,`LabelText`],[Ee,`PlaceholderText`],[Fe,`Text`],[We,`DisplayValue`],[$e,`AltText`],[lt,`Title`],[vt,`Role`],[Dt,`TestId`]];for(let[n,r]of t)for(let t of[`findAllBy`,`findBy`,`getAllBy`,`getBy`,`queryAllBy`,`queryBy`])e[t+r]=n[t+r];return e}const Z=build();function getQueriesForElement(e,t=Z,n={}){return Object.keys(t).reduce((n,r)=>(n[r]=t[r].bind(null,e),n),n)}const isRemoved=e=>!e||Array.isArray(e)&&!e.length;function initialCheck(e){if(isRemoved(e))throw Error(`The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.`)}async function waitForElementToBeRemoved(callback,e){let t=/* @__PURE__ */ Error(`Timed out in waitForElementToBeRemoved.`);if(typeof callback!=`function`){initialCheck(callback);let e=(Array.isArray(callback)?callback:[callback]).map(e=>{let t=e.parentElement;if(t===null)return()=>null;for(;t.parentElement;)t=t.parentElement;return()=>t.contains(e)?e:null});callback=()=>e.map(e=>e()).filter(Boolean)}let n=callback;return initialCheck(n()),waitFor(()=>{let e;try{e=n()}catch(e){if(e.name===`TestingLibraryElementError`)return;throw e}if(!isRemoved(e))throw t},e)}const Nt={copy:{EventType:`ClipboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},cut:{EventType:`ClipboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},paste:{EventType:`ClipboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},compositionEnd:{EventType:`CompositionEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},compositionStart:{EventType:`CompositionEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},compositionUpdate:{EventType:`CompositionEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},keyDown:{EventType:`KeyboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,charCode:0,composed:!0}},keyPress:{EventType:`KeyboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,charCode:0,composed:!0}},keyUp:{EventType:`KeyboardEvent`,defaultInit:{bubbles:!0,cancelable:!0,charCode:0,composed:!0}},focus:{EventType:`FocusEvent`,defaultInit:{bubbles:!1,cancelable:!1,composed:!0}},blur:{EventType:`FocusEvent`,defaultInit:{bubbles:!1,cancelable:!1,composed:!0}},focusIn:{EventType:`FocusEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},focusOut:{EventType:`FocusEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},change:{EventType:`Event`,defaultInit:{bubbles:!0,cancelable:!1}},input:{EventType:`InputEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},invalid:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!0}},submit:{EventType:`Event`,defaultInit:{bubbles:!0,cancelable:!0}},reset:{EventType:`Event`,defaultInit:{bubbles:!0,cancelable:!0}},click:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,button:0,composed:!0}},contextMenu:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},dblClick:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},drag:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},dragEnd:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},dragEnter:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},dragExit:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},dragLeave:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},dragOver:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},dragStart:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},drop:{EventType:`DragEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseDown:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseEnter:{EventType:`MouseEvent`,defaultInit:{bubbles:!1,cancelable:!1,composed:!0}},mouseLeave:{EventType:`MouseEvent`,defaultInit:{bubbles:!1,cancelable:!1,composed:!0}},mouseMove:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseOut:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseOver:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},mouseUp:{EventType:`MouseEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},select:{EventType:`Event`,defaultInit:{bubbles:!0,cancelable:!1}},touchCancel:{EventType:`TouchEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},touchEnd:{EventType:`TouchEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},touchMove:{EventType:`TouchEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},touchStart:{EventType:`TouchEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},resize:{EventType:`UIEvent`,defaultInit:{bubbles:!1,cancelable:!1}},scroll:{EventType:`UIEvent`,defaultInit:{bubbles:!1,cancelable:!1}},wheel:{EventType:`WheelEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},abort:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},canPlay:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},canPlayThrough:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},durationChange:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},emptied:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},encrypted:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},ended:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},loadedData:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},loadedMetadata:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},loadStart:{EventType:`ProgressEvent`,defaultInit:{bubbles:!1,cancelable:!1}},pause:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},play:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},playing:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},progress:{EventType:`ProgressEvent`,defaultInit:{bubbles:!1,cancelable:!1}},rateChange:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},seeked:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},seeking:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},stalled:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},suspend:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},timeUpdate:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},volumeChange:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},waiting:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},load:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},error:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},animationStart:{EventType:`AnimationEvent`,defaultInit:{bubbles:!0,cancelable:!1}},animationEnd:{EventType:`AnimationEvent`,defaultInit:{bubbles:!0,cancelable:!1}},animationIteration:{EventType:`AnimationEvent`,defaultInit:{bubbles:!0,cancelable:!1}},transitionCancel:{EventType:`TransitionEvent`,defaultInit:{bubbles:!0,cancelable:!1}},transitionEnd:{EventType:`TransitionEvent`,defaultInit:{bubbles:!0,cancelable:!0}},transitionRun:{EventType:`TransitionEvent`,defaultInit:{bubbles:!0,cancelable:!1}},transitionStart:{EventType:`TransitionEvent`,defaultInit:{bubbles:!0,cancelable:!1}},pointerOver:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerEnter:{EventType:`PointerEvent`,defaultInit:{bubbles:!1,cancelable:!1}},pointerDown:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerMove:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerUp:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerCancel:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},pointerOut:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!0,composed:!0}},pointerLeave:{EventType:`PointerEvent`,defaultInit:{bubbles:!1,cancelable:!1}},gotPointerCapture:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},lostPointerCapture:{EventType:`PointerEvent`,defaultInit:{bubbles:!0,cancelable:!1,composed:!0}},popState:{EventType:`PopStateEvent`,defaultInit:{bubbles:!0,cancelable:!1}},offline:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},online:{EventType:`Event`,defaultInit:{bubbles:!1,cancelable:!1}},pageHide:{EventType:`PageTransitionEvent`,defaultInit:{bubbles:!0,cancelable:!0}},pageShow:{EventType:`PageTransitionEvent`,defaultInit:{bubbles:!0,cancelable:!0}}},Pt={doubleClick:`dblClick`};function fireEvent_(e,t){return I()&&t&&e?ie(`testing-library.fire_event`,`fireEvent.${t.type}(${te(e)})`,()=>fireEventUntraced(e,t)):fireEventUntraced(e,t)}function fireEventUntraced(e,t){return f().eventWrapper(()=>{if(!t)throw Error(`Unable to fire an event - please provide an event object.`);if(!e)throw Error(`Unable to fire a "${t.type}" event - please provide a DOM element.`);return e.dispatchEvent(t)})}function createEvent_(e,t,n,{EventType:r=`Event`,defaultInit:i={}}={}){if(!t)throw Error(`Unable to fire a "${e}" event - please provide a DOM element.`);let a={...i,...n},{target:{value:o,files:s,...c}={}}=a;o!==void 0&&setNativeValue(t,o),s!==void 0&&Object.defineProperty(t,"files",{configurable:!0,enumerable:!0,writable:!0,value:s}),Object.assign(t,c);let l=m(t),u=l[r]||l.Event,d;if(typeof u==`function`)d=new u(e,a);else{d=l.document.createEvent(r);let{bubbles:t,cancelable:n,detail:i,...o}=a;d.initEvent(e,t,n,i),Object.keys(o).forEach(e=>{d[e]=o[e]})}return[`dataTransfer`,`clipboardData`].forEach(e=>{let t=a[e];typeof t==`object`&&(typeof l.DataTransfer==`function`?Object.defineProperty(d,e,{value:Object.getOwnPropertyNames(t).reduce((e,n)=>(Object.defineProperty(e,n,{value:t[n]}),e),new l.DataTransfer)}):Object.defineProperty(d,e,{value:t}))}),d}function setNativeValue(e,t){let{set:n}=Object.getOwnPropertyDescriptor(e,`value`)||{},r=Object.getPrototypeOf(e),{set:i}=Object.getOwnPropertyDescriptor(r,`value`)||{};if(i&&n!==i)i.call(e,t);else if(n)n.call(e,t);else throw Error(`The given element does not have a value setter`)}Object.defineProperty(fireEvent_,"name",{value:`fireEvent`}),Object.defineProperty(createEvent_,"name",{value:`createEvent`});const Q=fireEvent_,$=createEvent_;Object.keys(Nt).forEach(e=>{let{EventType:t,defaultInit:n}=Nt[e],r=e.toLowerCase();$[e]=(e,i)=>$(r,e,i,{EventType:t,defaultInit:n}),Q[e]=(t,n)=>Q(t,$[e](t,n))}),Object.keys(Pt).forEach(e=>{let t=Pt[e];Q[e]=(...e)=>Q[t](...e)});const Ft=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$`;var BitWriter=class{out=[];val=0;pos=0;write(e,t){for(let n=0;n<t;n++)this.val=this.val<<1|e&1,this.pos===5?(this.pos=0,this.out.push(Ft.charAt(this.val)),this.val=0):this.pos++,e>>=1}flush(){for(;;){if(this.val<<=1,this.pos===5){this.out.push(Ft.charAt(this.val));break}this.pos++}return this.out.join(``)}};function compressToEncodedURIComponent(e){if(e==null)return``;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=new BitWriter,i=``,a=2,o=3,s=2,emit=e=>{if(n.has(e)){let t=e.charCodeAt(0);t<256?(r.write(0,s),r.write(t,8)):(r.write(1,s),r.write(t,16)),a--,a===0&&(a=2**s,s++),n.delete(e)}else r.write(t.get(e),s);a--,a===0&&(a=2**s,s++)};for(let r=0;r<e.length;r++){let a=e.charAt(r);t.has(a)||(t.set(a,o++),n.add(a));let s=i+a;t.has(s)?i=s:(emit(i),t.set(s,o++),i=a)}return i!==``&&emit(i),r.write(2,s),r.flush()}function unindent(e){return e.replace(/[ \t]*[\n][ \t]*/g,`
|
|
29
|
+
`)}function encode(e){return compressToEncodedURIComponent(unindent(e))}function getPlaygroundUrl(e){return`https://testing-playground.com/#markup=${encode(e)}`}const debug=(e,t,n)=>Array.isArray(e)?e.forEach(e=>g(e,t,n)):g(e,t,n),logTestingPlaygroundURL=(e=o().body)=>{if(!e||!(`innerHTML`in e)){console.log(`The element you're providing isn't a valid DOM element.`);return}if(!e.innerHTML){console.log(`The provided element doesn't have any children.`);return}let t=getPlaygroundUrl(e.innerHTML);return console.log(`Open this URL in your browser\n\n${t}`),t},It={debug,logTestingPlaygroundURL,ariaSnapshot:h},Lt=typeof document<`u`&&document.body?getQueriesForElement(document.body,Z,It):Object.keys(Z).reduce((e,t)=>(e[t]=()=>{throw TypeError(`For queries bound to document.body a global document has to be available... Learn more: https://testing-library.com/s/screen-global-error`)},e),It),Rt={getElementError,wrapAllByQueryWithSuggestion,wrapSingleQueryWithSuggestion,getMultipleElementsFoundError,queryAllByAttribute,queryByAttribute,makeSingleQuery,makeGetAllQuery,makeFindQuery,buildQueries};export{h as ariaSnapshot,buildQueries,v as configure,$ as createEvent,b as diffAriaSnapshots,st as findAllByAltText,Ze as findAllByDisplayValue,xe as findAllByLabelText,Ne as findAllByPlaceholderText,Tt as findAllByRole,jt as findAllByTestId,He as findAllByText,gt as findAllByTitle,ct as findByAltText,Qe as findByDisplayValue,Se as findByLabelText,Pe as findByPlaceholderText,Et as findByRole,Mt as findByTestId,Ue as findByText,_t as findByTitle,Q as fireEvent,at as getAllByAltText,Ye as getAllByDisplayValue,Ce as getAllByLabelText,je as getAllByPlaceholderText,Ct as getAllByRole,X as getAllByTestId,Be as getAllByText,mt as getAllByTitle,ot as getByAltText,Xe as getByDisplayValue,we as getByLabelText,Me as getByPlaceholderText,wt as getByRole,At as getByTestId,Ve as getByText,ht as getByTitle,f as getConfig,getDefaultNormalizer,getElementError,getMultipleElementsFoundError,getNodeText,getQueriesForElement,getQueriesForElement as within,getRoles,getSuggestedQuery,isInaccessible,g as logDOM,logRoles,makeFindQuery,makeGetAllQuery,makeSingleQuery,y as prettyDOM,u as prettyFormat,Z as queries,rt as queryAllByAltText,queryAllByAttribute,qe as queryAllByDisplayValue,Te as queryAllByLabelText,ke as queryAllByPlaceholderText,xt as queryAllByRole,Ot as queryAllByTestId,Re as queryAllByText,ft as queryAllByTitle,it as queryByAltText,queryByAttribute,Je as queryByDisplayValue,Y as queryByLabelText,Ae as queryByPlaceholderText,St as queryByRole,kt as queryByTestId,ze as queryByText,pt as queryByTitle,Rt as queryHelpers,Lt as screen,waitFor,waitForElementToBeRemoved,wrapAllByQueryWithSuggestion,wrapSingleQueryWithSuggestion};
|