@ctrl/dom 0.3.11 → 0.3.13
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/dist/aria/_chunks/{aria-query.generated-BqD80bJk.cjs → aria-query.generated-BNKXKFqd.cjs} +2 -2
- package/dist/aria/_chunks/{aria-query.generated-BG-n1PE9.js → aria-query.generated-CU4-Yw6V.js} +2 -2
- package/dist/aria/index.cjs +1 -1
- package/dist/aria/index.js +1 -1
- package/dist/aria/internal.cjs +1 -1
- package/dist/aria/internal.js +1 -1
- package/dist/dom/_chunks/src-Dgmm77XJ.js +50 -0
- package/dist/dom/index.js +1 -1
- package/dist/dom/internal.js +1 -1
- package/dist/dom/types/css/cascade.d.ts +2 -0
- package/dist/dom/types/css/declarations.d.ts +2 -0
- package/dist/dom/types/css/values.d.ts +1 -1
- package/dist/dom/types/nodes/attributes.d.ts +5 -0
- package/dist/dom/types/nodes/tags.d.ts +2 -0
- package/dist/dom/types/selectors/compile.d.ts +7 -4
- package/dist/testing-library/_chunks/{aria-snapshot-diff-B95LLutl.cjs → aria-snapshot-diff-DbtSqGLH.cjs} +8 -8
- package/dist/testing-library/_chunks/aria-snapshot-diff-VoXekyfV.js +16 -0
- package/dist/testing-library/agent.cjs +1 -1
- package/dist/testing-library/agent.js +1 -1
- package/dist/testing-library/index.cjs +8 -8
- package/dist/testing-library/index.js +10 -10
- package/package.json +1 -1
- package/dist/dom/_chunks/src-B3vkUXY6.js +0 -50
- package/dist/testing-library/_chunks/aria-snapshot-diff-BSXxnyqJ.js +0 -16
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import{A as e,C as t,D as n,E as r,M as i,
|
|
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-VoXekyfV.js";import{$impl as T,ELEMENT_NODE as E,F_HTML as D,HTML_NS as O,T as k,TEXT_NODE as A,ariaAttr as j,asciiLowercase as M,attr as N,describeCall as P,describeNode as ee,getComputedStyleOverride as te,indexedDescendantById as ne,nextInTree as F,prefixFlag as I,tracePromise as L,traceSync as re,tracing as R}from"../bridge/internal.js";import{computeAccessibleDescriptionImpl as ie,computeAccessibleNameImpl as ae,implicitRole as oe,isInaccessibleImpl as z,isInaccessibleWithStyle as se,isLabelable as ce,isSubtreeInaccessibleImpl as le,isVisibilityHidden as ue,labelMapForTree as de,labelsOf as fe,tlRole as B,tlRoleMatcher as pe,tlRoleMatches as me}from"../aria/internal.js";import{roleSupportsProp as he}from"../aria/index.js";import{AsyncLocalStorage as ge}from"node:async_hooks";const V=/* @__PURE__ */ new Set([`button`,`input`,`meter`,`output`,`progress`,`select`,`textarea`]);function isLabelledNodeName(e){return e.prefix===null&&V.has(e.tag===0?M(e.name):e.name)}function buildIdMap(e){let t=/* @__PURE__ */ new Map;for(let n=e.first;n!==null;n=F(n,e))n.type===E&&n.id!==``&&!t.has(n.id)&&t.set(n.id,n);return t}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)??H:fe(e)??H}byIdInContainer(e){if(e===``)return null;if(this.containerIds===null){let t=ne(this.container,e);if(t!==void 0)return t;this.containerIds=buildIdMap(this.container)}return this.containerIds.get(e)??null}};const H=[];function getTextContent(e){let t=``;for(let n=e.first;n!==null;n=n.next)n.type===A?t+=n.data:n.first===null||n.type===E&&isLabelledNodeName(n)||(t+=getTextContent(n));return t}function getLabelContentImpl(e){if(e.tag===k.label&&e.ns===O)return getTextContent(e);let t=e.node;return t.value||t.textContent}function labelledFormControl(e,t){for(let n=e.first;n!==null;n=F(n,e))if(n.type===E&&V.has(n.name)&&(t===`*`||s(n,t)))return n}function getLabelsImpl(e,t,n=`*`){let r=j(t,`aria-labelledby`);return r?r.split(` `).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 _e=/\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(_e,` `):r,r}}const U=getDefaultNormalizer();function textMatcher(e,t,n){if(!e)return(e,r)=>fuzzyMatches(e,r,t,n);if(n===U&&isPlainRegExp(t)){let e;return n=>typeof n==`string`?n.length===0?e??=t.test(``):t.test(U(n)):!1}if(n!==U||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 U(e)===r}}function resolveNormalizer(e,t,n){if(!n)return e===void 0&&t===void 0?U: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 makeNormalizer({trim:e,collapseWhitespace:t,normalizer:n}){return resolveNormalizer(e,t,n)}const ve=RegExp.prototype.exec;function isPlainRegExp(e){return e instanceof RegExp&&!e.global&&!e.sticky&&Object.getPrototypeOf(e)===RegExp.prototype&&!Object.hasOwn(e,`exec`)&&!Object.hasOwn(e,`test`)&&RegExp.prototype.exec===ve&&RegExp.prototype.test===ye}const ye=RegExp.prototype.test;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!==k.input||e.ns!==O)return!1;let t=N(e,`type`);if(t===null)return!1;let n=M(t);return n===`submit`||n===`button`||n===`reset`}function getNodeTextImpl(e){if(isButtonLikeInput(e))return e.node.value;let t=e.first;if(t===null)return``;if(t===e.last)return t.type===A?t.data:``;let n=``;for(let e=t;e!==null;e=e.next)e.type===A&&(n+=e.data);return n}function getNodeText(e){let t=p(e);return t.type===E?getNodeTextImpl(t):e.matches(`input[type=submit], input[type=button], input[type=reset]`)}const be={computedStyleSupportsPseudoElements:!0};function styleOverride(e){return te(e)}function nameOptions(e,t){return t===null?e?be:void 0:{computedStyleSupportsPseudoElements:e,getComputedStyle:t}}const W={implicitRole(e){let t=oe(e);return t===``?null:t},roleMatcher:pe,roleSupportsProp(e,t){return typeof e==`string`&&he(e,t)},computeAccessibleName(e,t,n){return ae(e,nameOptions(t,n),5)},computeAccessibleDescription(e,t,n){return ie(e,nameOptions(t,n),5)},isInaccessible:z,isInaccessibleWithStyle:se,isSubtreeInaccessible:le};function parentElement(e){let t=e.parent;return t!==null&&t.type===E?t:null}function isInaccessibleImpl$1(e){return W.isInaccessible(e)}a(isInaccessibleImpl$1,`isInaccessibleImpl`);function isInaccessibleChecked(e){let t=styleOverride(e);return t===null?W.isInaccessible(e):W.isInaccessibleWithStyle(e,t,null)}function isInaccessible(e,t={}){let n=p(e),r=t.isSubtreeInaccessible,i=styleOverride(n);if(r===void 0)return i===null?isInaccessibleImpl$1(n):W.isInaccessibleWithStyle(n,i,null);if(i===null?ue(n):i(e).visibility===`hidden`)return!0;for(let e=n;e!==null;e=parentElement(e))if(r(e.node))return!0;return!1}function getImplicitAriaRolesImpl(e){let t=W.implicitRole(e);return t===null?[]:[t]}function getRoles(e,{hidden:t=!1}={}){let n=p(e),r={},i=t===!1?styleOverride(n):null,a=i===null?null:/* @__PURE__ */ new Map,visit=e=>{if(t!==!1||(i===null?isInaccessibleImpl$1(e):W.isInaccessibleWithStyle(e,i,a))===!1){let t=N(e,`role`),n=t===null?getImplicitAriaRolesImpl(e):t.split(` `).slice(0,1);for(let t of n){let n=r[t];Array.isArray(n)?n.push(e.node):r[t]=[e.node]}}for(let t=e.first;t!==null;t=t.next)t.type===E&&visit(t)};return visit(n),r}const xe={format:`pretty`};function prettyRoles(e,{hidden:t,includeDescription:n}){let r=getRoles(e,{hidden:t}),i=f().computedStyleSupportsPseudoElements,a=styleOverride(p(e));return Object.entries(r).filter(([e])=>e!==`generic`).map(([e,t])=>{let r=`-`.repeat(50);return`${e}:\n\n${t.map(e=>{let t=p(e),r=`Name "${W.computeAccessibleName(t,i,a)}":\n`,o=y(e.cloneNode(!1),void 0,xe);return n?`${r}${`Description "${W.computeAccessibleDescription(t,i,a)}":\n`}${o}`:`${r}${o}`}).join(`
|
|
2
2
|
|
|
3
|
-
`)}\n\n${
|
|
4
|
-
`)}const logRoles=(e,{hidden:t=!1}={})=>console.log(prettyRoles(e,{hidden:t}));function checkBooleanAttribute(e,t){let n=
|
|
3
|
+
`)}\n\n${r}`}).join(`
|
|
4
|
+
`)}const logRoles=(e,{hidden:t=!1}={})=>console.log(prettyRoles(e,{hidden:t}));function checkBooleanAttribute(e,t){let n=N(e,t);if(n===`true`)return!0;if(n===`false`)return!1}function computeAriaSelected$1(e){return e.tag===k.option&&e.ns===O?e.node.selected:checkBooleanAttribute(e,`aria-selected`)}a(computeAriaSelected$1,`computeAriaSelected`);function computeAriaBusy$1(e){return j(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`)??j(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=j(e,`aria-level`),n=t&&Number(t);if(n)return n;if(e.ns===O)switch(e.tag){case k.h1:return 1;case k.h2:return 2;case k.h3:return 3;case k.h4:return 4;case k.h5:return 5;case k.h6:return 6}}function computeAriaValueNow(e){let t=j(e,`aria-valuenow`);return t===null?void 0:+t}function computeAriaValueMax(e){let t=j(e,`aria-valuemax`);return t===null?void 0:+t}function computeAriaValueMin(e){let t=j(e,`aria-valuemin`);return t===null?void 0:+t}function computeAriaValueText(e){let t=j(e,`aria-valuetext`);return t===null?void 0:t}const G=getDefaultNormalizer();function escapeRegExp(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,`\\$&`)}function getRegExpMatcher(e){return new RegExp(escapeRegExp(e.toLowerCase()),`i`)}function makeSuggestion(e,t,n,{variant:r,name:i}){let a=``,o={},s=[[`Role`,`TestId`].includes(e)?n:getRegExpMatcher(n)];i&&(o.name=getRegExpMatcher(i)),e===`Role`&&isInaccessibleChecked(p(t))&&(o.hidden=!0,a=`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(
|
|
6
|
+
`),Object.keys(o).length>0&&s.push(o);let c=`${r}By${e}`;return{queryName:e,queryMethod:c,queryArgs:s,variant:r,warning:a,toString(){a&&console.warn(a);let[e,t]=s;return e=typeof e==`string`?`'${e}'`:e,t=t?`, { ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)} }`:``,`${c}(${e}${t})`}}}function canSuggest(e,t,n){return!(!n||t&&t.toLowerCase()!==e.toLowerCase())}function getSuggestedQuery(e,t=`get`,n){let r=p(e);if(s(r,f().defaultIgnore))return;let i=N(r,`role`)??getImplicitAriaRolesImpl(r)?.[0];if(i!==`generic`&&canSuggest(`Role`,n,i))return makeSuggestion(`Role`,e,i,{variant:t,name:W.computeAccessibleName(r,f().computedStyleSupportsPseudoElements,styleOverride(r))});let a=getLabelsImpl(new LabelContext(p(m())),r).map(e=>e.content).join(` `);if(canSuggest(`LabelText`,n,a))return makeSuggestion(`LabelText`,e,a,{variant:t});let o=N(r,`placeholder`);if(canSuggest(`PlaceholderText`,n,o))return makeSuggestion(`PlaceholderText`,e,o,{variant:t});let c=G(getNodeTextImpl(r));if(canSuggest(`Text`,n,c))return makeSuggestion(`Text`,e,c,{variant:t});if(canSuggest(`DisplayValue`,n,e.value))return makeSuggestion(`DisplayValue`,e,G(e.value),{variant:t});let l=N(r,`alt`);if(canSuggest(`AltText`,n,l))return makeSuggestion(`AltText`,e,l,{variant:t});let u=N(r,`title`);if(canSuggest(`Title`,n,u))return makeSuggestion(`Title`,e,u,{variant:t});let d=e.getAttribute(f().testIdAttribute);if(canSuggest(`TestId`,n,d))return makeSuggestion(`TestId`,e,d,{variant:t})}function copyStackTrace(e,t){e.stack=t.stack.replace(t.message,e.message)}const Se={subtree:!0,childList:!0,attributes:!0,characterData:!0};function defaultOnTimeout(e,t){return e.name===`TestingLibraryElementError`&&S()!==null||Object.defineProperty(e,"message",{value:f().getElementError(e.message,t).message}),e}function waitForImpl(t,r,a,{container:s=m(),timeout:c=f().asyncUtilTimeout,showOriginalStackTrace:u=f().showOriginalStackTrace,stackTraceError:d=r,interval:p=50,onTimeout:h,mutationObserverOptions:g=Se}){if(typeof t!=`function`)throw TypeError("Received `callback` arg must be a function");return new Promise((r,m)=>{let _,v,y,b=!1,x=`idle`,S=setTimeout(handleTimeout,c),C=i();if(C){let{unstable_advanceTimersWrapper:e}=f();checkCallback(),b||(async()=>{for(;!b;){if(!i()){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`);u||copyStackTrace(e,d),m(e);return}if(await e(async()=>{n(p)}),b)break;checkCallback()}})()}else{try{o(s)}catch(e){b=!0,clearTimeout(S),m(e);return}let t=a===null?null:ge.snapshot(),n=t===null?checkRealTimersCallback:()=>t(checkRealTimersCallback);v=setInterval(n,p);let{MutationObserver:r}=e(s);y=new r(n),y.observe(s,g),checkCallback()}function onDone(e,t){b=!0,clearTimeout(S),C||(clearInterval(v),y.disconnect()),e?m(e):r(t)}function checkRealTimersCallback(){if(i()){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 u||copyStackTrace(e,d),m(e)}return checkCallback()}function checkCallback(){if(x!==`pending`){a!==null&&(a.data.checks=(a.data.checks??0)+1);try{let e=l(t,!C);typeof e?.then==`function`?(x=`pending`,e.then(e=>{x=`resolved`,onDone(null,e)},e=>{x=`rejected`,_=e})):onDone(null,e)}catch(e){_=e}}}function handleTimeout(){let e;_?(e=_,!u&&e.name===`TestingLibraryElementError`&©StackTrace(e,d)):(e=/* @__PURE__ */ Error(`Timed out in waitFor.`),u||copyStackTrace(e,d)),onDone(h===void 0?defaultOnTimeout(e,s):h(e),null)}})}function waitFor(e,t){return R()?L(`testing-library.wait_for`,`waitFor(${describeCallback(e)})`,n=>waitForInSpan(e,t,n)):waitForInSpan(e,t,null)}function waitForInSpan(e,t,n){let i=/* @__PURE__ */ Error(`STACK_TRACE_MESSAGE`);return f().asyncWrapper(()=>waitForImpl(e,i,n,t??r))}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(e,t,n,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}=r){let c=textMatcher(i,n,resolveNormalizer(o,a,s)),l=p(t),u=M(e),d=I(u),f=I(e),m=[];for(let t=l.first;t!==null;t=F(t,l)){if(t.type!==E||t.attrs===null)continue;let n=(t.flags&D)!==0,r=n?d:f;if(r!==0&&(t.flags&r)===0)continue;let i=N(t,n?u:e);i!==null&&c(i,t.node)&&m.push(t.node)}return m}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 shouldSuggest(e){let t=e.at(-1)?.suggest;return t===void 0?f().throwSuggestions:t}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)}
|
|
10
10
|
|
|
11
11
|
Here are the matching elements:
|
|
12
12
|
|
|
13
|
-
${e}`,r)}return a[0]||null}}function getSuggestionError(e,t){return
|
|
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
|
|
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 R()?L(K,P(t,[r,i]),async e=>{let t=await find(e);return e.data.matches=matchCount(t),t}):find(null)}}const K=`testing-library.query`,matchCount=e=>Array.isArray(e)?e.length:+!!e;function traceQuery(e,t){return(n,...r)=>R()?re(K,P(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);if(a&&shouldSuggest(i)){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);if(a.length&&shouldSuggest(i)){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 q=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]),J=/* @__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(ae(e,void 0,5))}function roleCandidates(e,t){let n=p(e),r=[],i=t.name;for(let e=n.first;e!==null;e=F(e,n)){if(e.type!==E)continue;let n=z(e),a=B(e);if(me(e,t.role,t.queryFallbacks)){let o=nameOf(e),s=i===void 0?0:closeness(o,e.node,i,J),c=t.matchesState(e);s===0&&c?n&&!t.hidden&&r.push({line:line(e,a,o,!0,`hidden: ${d(e)} (or pass { hidden: true })`),rank:0}):s===0?r.push({line:line(e,a,o,n&&!t.hidden,`role and name match, state is not ${t.stateHint}`),rank:1}):(!n||t.hidden)&&r.push({line:line(e,a,o,!1,s>0?`similar name`:`same role, other name`),rank:s>0?2+s:10});continue}if(i===void 0)continue;if(!q.has(a)){let o=nameOf(e);if(o===``)continue;let s=closeness(o,e.node,i,J);s>=0&&r.push({line:line(e,a,o,n&&!t.hidden,`same name, role "${a}"`),rank:2+s});continue}let o=normalize(getNodeTextImpl(e));o!==``&&closeness(o,e.node,i,J)===0&&r.push({line:`- text: ${w(C(o,80))} # in ${_(e)}, which has no role: give it role="${t.role}" or use getByText`,rank:2})}return format(`Closest matches`,r)}function roleOrTag(e){let t=B(e);return q.has(t)?_(e):t}function textCandidates(e,t,n,r,i,a){if(typeof t==`function`)return``;let o=p(e),c=[],l=[];for(let e=o.first;e!==null;e=F(e,o)){if(e.type!==E||i&&typeof i==`string`&&s(e,i))continue;let o=getNodeTextImpl(e),u=o.trim()===``?-1:closeness(o,e.node,t,n,a);u===0?c.push({line:`- ${roleOrTag(e)}: ${w(C(n(o),80))} # matches, but not selector "${r}"`,rank:0}):u>0&&c.push({line:`- ${roleOrTag(e)}: ${w(C(n(o),80))} # similar text in ${_(e)}`,rank:1+u}),u!==0&&e.first!==null&&e.first!==e.last&&(a?matches$1:fuzzyMatches)(e.node.textContent,e.node,t,n)&&l.push(e)}for(let e=0;e<l.length;e++){let t=l[e],r=!1;for(let n=e+1;n<l.length&&!r;n++)isAncestor(t,l[n])&&(r=!0);r||c.push({line:`- ${roleOrTag(t)}: ${w(C(n(t.node.textContent),80))} # text split across child elements of ${_(t)}: use a function matcher or getByRole`,rank:0})}return format(`Closest matches`,c)}function isAncestor(e,t){for(let n=t.parent;n!==null;n=n.parent)if(n===e)return!0;return!1}const Ce=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`]);function labelCandidates(e,t,n,r){if(typeof t==`function`)return``;let i=p(e),a=[];for(let e=i.first;e!==null;e=F(e,i)){if(e.type!==E)continue;let i=B(e);if(!Ce.has(i))continue;let o=nameOf(e),s=z(e);if(o===``){let r=N(e,`placeholder`),o=r?`no label, placeholder ${w(r)}: use getByPlaceholderText or add a <label>`:`no label: add a <label>, aria-label or aria-labelledby`;a.push({line:line(e,i,``,s,o),rank:r&&closeness(r,e.node,t,n)>=0?1:5});continue}let c=closeness(o,e.node,t,n,r);a.push({line:line(e,i,o,s,c>=0?`similar label`:`labelled control`),rank:c>=0?2+c:10})}return format(`Labelled form controls`,a)}function queryAllLabels(e){let t=p(e),n=[];for(let e=t.first;e!==null;e=F(e,t)){if(e.type!==E||e.name!==`label`&&e.name!==`input`)continue;let t=getLabelContentImpl(e);t!==null&&n.push({node:e.node,textToMatch:t})}return n}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(e,t,{selector:n=`*`,exact:i=!0,collapseWhitespace:a,trim:c,normalizer:l}=r){o(e);let u=textMatcher(i,t,resolveNormalizer(c,a,l)),d=p(e),f=new LabelContext(d,!0),m=[],h=null;for(let e=d.first;e!==null;e=F(e,d)){if(e.type!==E)continue;j(e,`aria-label`)!==null&&(h??=[]).push(e);let t=j(e,`aria-labelledby`);(t!==null||ce(e))&&collectLabelled(f,e,t,n,u,m)}if(h!==null)for(let e=0;e<h.length;e++){let t=h[e];u(j(t,`aria-label`),t.node)&&m.push(t.node)}let g=m.length>1?Array.from(new Set(m)):m;return n===`*`?g:g.filter(e=>s(e[T],n))}function collectLabelled(e,t,n,r,i,a){if(!n){let o=e.labelsOf(t);if(o.length===0&&n===null)return;if(o.length===1){let e=o[0],n=getLabelContentImpl(e),s=labelledFormControl(e,r);s&&i(n,s.node)&&a.push(s.node),i(n,t.node)&&a.push(t.node);return}}else if(!n.includes(` `)){let r=e.byIdInContainer(n);i(`${(r===null?``:getLabelContentImpl(r))||``}`,t.node)&&a.push(t.node);return}let o=getLabelsImpl(e,t,r);for(let e of o){if(!e.formControl)continue;let t=e.formControl.node;i(e.content,t)&&a.push(t)}let s=o.filter(e=>!!e.content).map(e=>e.content),c=t.node;i(s.join(` `),c)&&a.push(c),s.length>1&&s.forEach((e,t)=>{i(e,c)&&a.push(c);let n=[...s];n.splice(t,1),n.length>1&&i(n.join(` `),c)&&a.push(c)})}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):
|
|
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),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(e,t){let n=t.getAttribute(`for`);if(!n)return null;let r=new LabelContext(p(e)).byIdInContainer(n);return r?r.node.tagName.toLowerCase():null}const we=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the text of: ${t}`,`getMultipleError`),Te=wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllByLabelText,we),queryAllByLabelText.name,`query`),Ee=makeSingleQuery(getAllByLabelText,we),De=makeFindQuery(wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`findAll`)),Oe=makeFindQuery(wrapSingleQueryWithSuggestion(Ee,getAllByLabelText.name,`find`)),ke=wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`getAll`),Ae=wrapSingleQueryWithSuggestion(Ee,getAllByLabelText.name,`get`),je=wrapAllByQueryWithSuggestion(queryAllByLabelText,queryAllByLabelText.name,`queryAll`);function queryAllByPlaceholderText(...e){return o(e[0]),queryAllByAttribute(`placeholder`,...e)}const Me=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the placeholder text of: ${t}`,`getMultipleError`),Ne=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the placeholder text of: ${t}`,`getMissingError`),Pe=wrapAllByQueryWithSuggestion(queryAllByPlaceholderText,queryAllByPlaceholderText.name,`queryAll`),[Fe,Ie,Le,Re,ze]=buildQueries(queryAllByPlaceholderText,Me,Ne);function isScriptStyleIgnore(e){return e===`script, style`||e===`script,style`}function isScriptOrStyle(e){if((e.flags&D)!==0)return e.tag===k.script||e.tag===k.style;let t=e.name;return t===`script`||t===`style`}function isCandidate(e,t,n){return t!==`*`&&!s(e,t)?!1:n?isScriptStyleIgnore(n)?!isScriptOrStyle(e):!s(e,n):!0}function queryAllByText(e,t,{selector:n=`*`,exact:i=!0,collapseWhitespace:a,trim:s,ignore:c=f().defaultIgnore,normalizer:l}=r){o(e);let u=textMatcher(i,t,resolveNormalizer(s,a,l)),d=p(e),m=[];d.type===E&&isCandidate(d,n,c)&&u(getNodeTextImpl(d),d.node)&&m.push(d.node);for(let e=d.first;e!==null;e=F(e,d))e.type===E&&isCandidate(e,n,c)&&u(getNodeTextImpl(e),e.node)&&m.push(e.node);return m}const Be=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the text: ${t}`,`getMultipleError`),Ve=/* @__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`),He=wrapAllByQueryWithSuggestion(queryAllByText,queryAllByText.name,`queryAll`),[Ue,We,Ge,Ke,qe]=buildQueries(queryAllByText,Be,Ve);function queryAllByDisplayValue(e,t,{exact:n=!0,collapseWhitespace:r,trim:i,normalizer:a}={}){o(e);let s=textMatcher(n,t,makeNormalizer({collapseWhitespace:r,trim:i,normalizer:a})),c=p(e),l=[];for(let e=c.first;e!==null;e=F(e,c)){if(e.type!==E)continue;let t=e.name;if(t!==`input`&&t!==`textarea`&&t!==`select`)continue;let n=e.node;if(e.tag===k.select&&e.ns===O){let e=n.options,t=!1;for(let n=0;n<e.length;n++){let r=e[n];if(r.selected&&s(getNodeTextImpl(r[T]),r)){t=!0;break}}t&&l.push(n)}else s(n.value,n)&&l.push(n)}return l}const Je=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the display value: ${t}.`,`getMultipleError`),Ye=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the display value: ${t}.`,`getMissingError`),Xe=wrapAllByQueryWithSuggestion(queryAllByDisplayValue,queryAllByDisplayValue.name,`queryAll`),[Ze,Qe,$e,et,tt]=buildQueries(queryAllByDisplayValue,Je,Ye),nt=/^(img|input|area|.+-.+)$/i;function queryAllByAltText(e,t,n={}){return o(e),queryAllByAttribute(`alt`,e,t,n).filter(e=>nt.test(e.tagName))}const rt=/* @__PURE__ */ a((e,t)=>`Found multiple elements with the alt text: ${t}`,`getMultipleError`),it=/* @__PURE__ */ a((e,t)=>`Unable to find an element with the alt text: ${t}`,`getMissingError`),at=wrapAllByQueryWithSuggestion(queryAllByAltText,queryAllByAltText.name,`queryAll`),[ot,st,ct,lt,ut]=buildQueries(queryAllByAltText,rt,it);function isSvgTitle(e){let t=e.parent;return M(e.prefix===null?e.name:e.prefix+`:`+e.name)===`title`&&t!==null&&t.type===E&&M(t.prefix===null?t.name:t.prefix+`:`+t.name)===`svg`}function queryAllByTitle(e,t,{exact:n=!0,collapseWhitespace:r,trim:i,normalizer:a}={}){o(e);let s=textMatcher(n,t,makeNormalizer({collapseWhitespace:r,trim:i,normalizer:a})),c=p(e),l=[];for(let e=c.first;e!==null;e=F(e,c)){if(e.type!==E)continue;let t=e.attrs===null?null:N(e,`title`),n=e.name===`title`&&e.parent!==null&&e.parent.type===E&&e.parent.name===`svg`;(t!==null||n)&&(s(t,e.node)||isSvgTitle(e)&&s(getNodeTextImpl(e),e.node))&&l.push(e.node)}return l}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),identity=e=>e;function assertSupported(e,t){if(!W.roleSupportsProp(e,t))throw Error(`"${t}" is not supported on role "${e}".`)}function queryAllByRole(e,t,{hidden:n=f().defaultHidden,name:i,description:a,queryFallbacks:s=!1,selected:c,busy:l,checked:u,pressed:d,current:m,level:h,expanded:g,value:{now:_,min:v,max:y,text:b}=r}=r){if(o(e),c!==void 0&&assertSupported(t,`aria-selected`),l!==void 0&&assertSupported(t,`aria-busy`),u!==void 0&&assertSupported(t,`aria-checked`),d!==void 0&&assertSupported(t,`aria-pressed`),m!==void 0&&assertSupported(t,`aria-current`),h!==void 0&&t!==`heading`)throw Error(`Role "${t}" cannot have "level" property.`);_!==void 0&&assertSupported(t,`aria-valuenow`),y!==void 0&&assertSupported(t,`aria-valuemax`),v!==void 0&&assertSupported(t,`aria-valuemin`),b!==void 0&&assertSupported(t,`aria-valuetext`),g!==void 0&&assertSupported(t,`aria-expanded`);let x={selected:c,busy:l,checked:u,pressed:d,current:m,level:h,expanded:g,valueNow:_,valueMin:v,valueMax:y,valueText:b},S=f().computedStyleSupportsPseudoElements,C=p(e),w=[],T=styleOverride(C),D=T!==null&&n===!1?/* @__PURE__ */ new Map:null,O=W.roleMatcher(t,s);for(let e=C.first;e!==null;e=F(e,C))e.type===E&&O(e)&&matchesState(e,x)&&(n===!1&&(T===null?isInaccessibleImpl$1(e):W.isInaccessibleWithStyle(e,T,D))||(i===void 0||matches$1(W.computeAccessibleName(e,S,T),e.node,i,identity))&&(a===void 0||matches$1(W.computeAccessibleDescription(e,S,T),e.node,a,identity))&&w.push(e.node));return w}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 vt=wrapAllByQueryWithSuggestion(queryAllByRole,queryAllByRole.name,`queryAll`),[yt,bt,xt,St,Ct]=buildQueries(queryAllByRole,gt,_t),getTestIdAttribute=()=>d().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}"]`,wt=wrapAllByQueryWithSuggestion(queryAllByTestId,queryAllByTestId.name,`queryAll`),[Tt,Et,Dt,Ot,kt]=buildQueries(queryAllByTestId,getMultipleError,getMissingError),X={findAllByLabelText:Y,findByLabelText:Te,getAllByLabelText:Ee,getByLabelText:De,queryAllByLabelText:Oe,queryByLabelText:q,findAllByPlaceholderText:Fe,findByPlaceholderText:Ie,getAllByPlaceholderText:Ne,getByPlaceholderText:Pe,queryAllByPlaceholderText:je,queryByPlaceholderText:Me,findAllByText:Ue,findByText:We,getAllByText:Ve,getByText:He,queryAllByText:ze,queryByText:Be,findAllByDisplayValue:Ze,findByDisplayValue:Qe,getAllByDisplayValue:Ye,getByDisplayValue:Xe,queryAllByDisplayValue:qe,queryByDisplayValue:Je,findAllByAltText:ot,findByAltText:st,getAllByAltText:it,getByAltText:at,queryAllByAltText:nt,queryByAltText:rt,findAllByTitle:mt,findByTitle:ht,getAllByTitle:ft,getByTitle:pt,queryAllByTitle:ut,queryByTitle:dt,findAllByRole:St,findByRole:Ct,getAllByRole:bt,getByRole:xt,queryAllByRole:vt,queryByRole:yt,findAllByTestId:Ot,findByTestId:kt,getAllByTestId:Et,getByTestId:Dt,queryAllByTestId:wt,queryByTestId:Tt};function getQueriesForElement(e,t=X,n){if(n===void 0){if(t===X&&hasDefaultKeys(t))return bindDefaultQueries(t,e);n={}}return Object.keys(t).reduce((n,r)=>(n[r]=t[r].bind(null,e),n),n)}const At=/* @__PURE__ */ `findAllByLabelText.findByLabelText.getAllByLabelText.getByLabelText.queryAllByLabelText.queryByLabelText.findAllByPlaceholderText.findByPlaceholderText.getAllByPlaceholderText.getByPlaceholderText.queryAllByPlaceholderText.queryByPlaceholderText.findAllByText.findByText.getAllByText.getByText.queryAllByText.queryByText.findAllByDisplayValue.findByDisplayValue.getAllByDisplayValue.getByDisplayValue.queryAllByDisplayValue.queryByDisplayValue.findAllByAltText.findByAltText.getAllByAltText.getByAltText.queryAllByAltText.queryByAltText.findAllByTitle.findByTitle.getAllByTitle.getByTitle.queryAllByTitle.queryByTitle.findAllByRole.findByRole.getAllByRole.getByRole.queryAllByRole.queryByRole.findAllByTestId.findByTestId.getAllByTestId.getByTestId.queryAllByTestId.queryByTestId`.split(`.`);function hasDefaultKeys(e){let t=Object.keys(e);if(t.length!==At.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==At[e])return!1;return!0}function bindDefaultQueries(e,t){return{findAllByLabelText:e.findAllByLabelText.bind(null,t),findByLabelText:e.findByLabelText.bind(null,t),getAllByLabelText:e.getAllByLabelText.bind(null,t),getByLabelText:e.getByLabelText.bind(null,t),queryAllByLabelText:e.queryAllByLabelText.bind(null,t),queryByLabelText:e.queryByLabelText.bind(null,t),findAllByPlaceholderText:e.findAllByPlaceholderText.bind(null,t),findByPlaceholderText:e.findByPlaceholderText.bind(null,t),getAllByPlaceholderText:e.getAllByPlaceholderText.bind(null,t),getByPlaceholderText:e.getByPlaceholderText.bind(null,t),queryAllByPlaceholderText:e.queryAllByPlaceholderText.bind(null,t),queryByPlaceholderText:e.queryByPlaceholderText.bind(null,t),findAllByText:e.findAllByText.bind(null,t),findByText:e.findByText.bind(null,t),getAllByText:e.getAllByText.bind(null,t),getByText:e.getByText.bind(null,t),queryAllByText:e.queryAllByText.bind(null,t),queryByText:e.queryByText.bind(null,t),findAllByDisplayValue:e.findAllByDisplayValue.bind(null,t),findByDisplayValue:e.findByDisplayValue.bind(null,t),getAllByDisplayValue:e.getAllByDisplayValue.bind(null,t),getByDisplayValue:e.getByDisplayValue.bind(null,t),queryAllByDisplayValue:e.queryAllByDisplayValue.bind(null,t),queryByDisplayValue:e.queryByDisplayValue.bind(null,t),findAllByAltText:e.findAllByAltText.bind(null,t),findByAltText:e.findByAltText.bind(null,t),getAllByAltText:e.getAllByAltText.bind(null,t),getByAltText:e.getByAltText.bind(null,t),queryAllByAltText:e.queryAllByAltText.bind(null,t),queryByAltText:e.queryByAltText.bind(null,t),findAllByTitle:e.findAllByTitle.bind(null,t),findByTitle:e.findByTitle.bind(null,t),getAllByTitle:e.getAllByTitle.bind(null,t),getByTitle:e.getByTitle.bind(null,t),queryAllByTitle:e.queryAllByTitle.bind(null,t),queryByTitle:e.queryByTitle.bind(null,t),findAllByRole:e.findAllByRole.bind(null,t),findByRole:e.findByRole.bind(null,t),getAllByRole:e.getAllByRole.bind(null,t),getByRole:e.getByRole.bind(null,t),queryAllByRole:e.queryAllByRole.bind(null,t),queryByRole:e.queryByRole.bind(null,t),findAllByTestId:e.findAllByTestId.bind(null,t),findByTestId:e.findByTestId.bind(null,t),getAllByTestId:e.getAllByTestId.bind(null,t),getByTestId:e.getByTestId.bind(null,t),queryAllByTestId:e.queryAllByTestId.bind(null,t),queryByTestId:e.queryByTestId.bind(null,t)}}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 jt={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}}},Mt={doubleClick:`dblClick`};function fireEvent_(e,t){return P()&&t&&e?oe(`testing-library.fire_event`,`fireEvent.${t.type}(${te(e)})`,()=>fireEventUntraced(e,t)):fireEventUntraced(e,t)}function fireEventUntraced(e,t){return d().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=p(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(jt).forEach(e=>{let{EventType:t,defaultInit:n}=jt[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(Mt).forEach(e=>{let t=Mt[e];Z[e]=(...e)=>Z[t](...e)});const $=`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($.charAt(this.val)),this.val=0):this.pos++,e>>=1}flush(){for(;;){if(this.val<<=1,this.pos===5){this.out.push($.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=>
|
|
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),getTestIdAttribute=()=>f().testIdAttribute;function queryAllByTestId(...e){return o(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}"]`,Dt=wrapAllByQueryWithSuggestion(queryAllByTestId,queryAllByTestId.name,`queryAll`),[Ot,kt,At,Y,jt]=buildQueries(queryAllByTestId,getMultipleError,getMissingError),X={findAllByLabelText:De,findByLabelText:Oe,getAllByLabelText:ke,getByLabelText:Ae,queryAllByLabelText:je,queryByLabelText:Te,findAllByPlaceholderText:Re,findByPlaceholderText:ze,getAllByPlaceholderText:Ie,getByPlaceholderText:Le,queryAllByPlaceholderText:Pe,queryByPlaceholderText:Fe,findAllByText:Ke,findByText:qe,getAllByText:We,getByText:Ge,queryAllByText:He,queryByText:Ue,findAllByDisplayValue:et,findByDisplayValue:tt,getAllByDisplayValue:Qe,getByDisplayValue:$e,queryAllByDisplayValue:Xe,queryByDisplayValue:Ze,findAllByAltText:lt,findByAltText:ut,getAllByAltText:st,getByAltText:ct,queryAllByAltText:at,queryByAltText:ot,findAllByTitle:_t,findByTitle:vt,getAllByTitle:ht,getByTitle:gt,queryAllByTitle:pt,queryByTitle:mt,findAllByRole:Tt,findByRole:Et,getAllByRole:Ct,getByRole:wt,queryAllByRole:xt,queryByRole:St,findAllByTestId:Y,findByTestId:jt,getAllByTestId:kt,getByTestId:At,queryAllByTestId:Dt,queryByTestId:Ot};function getQueriesForElement(e,t=X,n){if(n===void 0){if(t===X&&hasDefaultKeys(t))return bindDefaultQueries(t,e);n={}}return Object.keys(t).reduce((n,r)=>(n[r]=t[r].bind(null,e),n),n)}const Mt=/* @__PURE__ */ `findAllByLabelText.findByLabelText.getAllByLabelText.getByLabelText.queryAllByLabelText.queryByLabelText.findAllByPlaceholderText.findByPlaceholderText.getAllByPlaceholderText.getByPlaceholderText.queryAllByPlaceholderText.queryByPlaceholderText.findAllByText.findByText.getAllByText.getByText.queryAllByText.queryByText.findAllByDisplayValue.findByDisplayValue.getAllByDisplayValue.getByDisplayValue.queryAllByDisplayValue.queryByDisplayValue.findAllByAltText.findByAltText.getAllByAltText.getByAltText.queryAllByAltText.queryByAltText.findAllByTitle.findByTitle.getAllByTitle.getByTitle.queryAllByTitle.queryByTitle.findAllByRole.findByRole.getAllByRole.getByRole.queryAllByRole.queryByRole.findAllByTestId.findByTestId.getAllByTestId.getByTestId.queryAllByTestId.queryByTestId`.split(`.`);function hasDefaultKeys(e){let t=Object.keys(e);if(t.length!==Mt.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==Mt[e])return!1;return!0}function bindDefaultQueries(e,t){return{findAllByLabelText:e.findAllByLabelText.bind(null,t),findByLabelText:e.findByLabelText.bind(null,t),getAllByLabelText:e.getAllByLabelText.bind(null,t),getByLabelText:e.getByLabelText.bind(null,t),queryAllByLabelText:e.queryAllByLabelText.bind(null,t),queryByLabelText:e.queryByLabelText.bind(null,t),findAllByPlaceholderText:e.findAllByPlaceholderText.bind(null,t),findByPlaceholderText:e.findByPlaceholderText.bind(null,t),getAllByPlaceholderText:e.getAllByPlaceholderText.bind(null,t),getByPlaceholderText:e.getByPlaceholderText.bind(null,t),queryAllByPlaceholderText:e.queryAllByPlaceholderText.bind(null,t),queryByPlaceholderText:e.queryByPlaceholderText.bind(null,t),findAllByText:e.findAllByText.bind(null,t),findByText:e.findByText.bind(null,t),getAllByText:e.getAllByText.bind(null,t),getByText:e.getByText.bind(null,t),queryAllByText:e.queryAllByText.bind(null,t),queryByText:e.queryByText.bind(null,t),findAllByDisplayValue:e.findAllByDisplayValue.bind(null,t),findByDisplayValue:e.findByDisplayValue.bind(null,t),getAllByDisplayValue:e.getAllByDisplayValue.bind(null,t),getByDisplayValue:e.getByDisplayValue.bind(null,t),queryAllByDisplayValue:e.queryAllByDisplayValue.bind(null,t),queryByDisplayValue:e.queryByDisplayValue.bind(null,t),findAllByAltText:e.findAllByAltText.bind(null,t),findByAltText:e.findByAltText.bind(null,t),getAllByAltText:e.getAllByAltText.bind(null,t),getByAltText:e.getByAltText.bind(null,t),queryAllByAltText:e.queryAllByAltText.bind(null,t),queryByAltText:e.queryByAltText.bind(null,t),findAllByTitle:e.findAllByTitle.bind(null,t),findByTitle:e.findByTitle.bind(null,t),getAllByTitle:e.getAllByTitle.bind(null,t),getByTitle:e.getByTitle.bind(null,t),queryAllByTitle:e.queryAllByTitle.bind(null,t),queryByTitle:e.queryByTitle.bind(null,t),findAllByRole:e.findAllByRole.bind(null,t),findByRole:e.findByRole.bind(null,t),getAllByRole:e.getAllByRole.bind(null,t),getByRole:e.getByRole.bind(null,t),queryAllByRole:e.queryAllByRole.bind(null,t),queryByRole:e.queryByRole.bind(null,t),findAllByTestId:e.findAllByTestId.bind(null,t),findByTestId:e.findByTestId.bind(null,t),getAllByTestId:e.getAllByTestId.bind(null,t),getByTestId:e.getByTestId.bind(null,t),queryAllByTestId:e.queryAllByTestId.bind(null,t),queryByTestId:e.queryByTestId.bind(null,t)}}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 R()&&t&&e?re(`testing-library.fire_event`,`fireEvent.${t.type}(${ee(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_(t,n,r,{EventType:i=`Event`,defaultInit:a={}}={}){if(!n)throw Error(`Unable to fire a "${t}" event - please provide a DOM element.`);let o={...a,...r},{target:{value:s,files:c,...l}={}}=o;s!==void 0&&setNativeValue(n,s),c!==void 0&&Object.defineProperty(n,"files",{configurable:!0,enumerable:!0,writable:!0,value:c}),Object.assign(n,l);let u=e(n),d=u[i]||u.Event,f;if(typeof d==`function`)f=new d(t,o);else{f=u.document.createEvent(i);let{bubbles:e,cancelable:n,detail:r,...a}=o;f.initEvent(t,e,n,r),Object.keys(a).forEach(e=>{f[e]=a[e]})}return[`dataTransfer`,`clipboardData`].forEach(e=>{let t=o[e];typeof t==`object`&&(typeof u.DataTransfer==`function`?Object.defineProperty(f,e,{value:Object.getOwnPropertyNames(t).reduce((e,n)=>(Object.defineProperty(e,n,{value:t[n]}),e),new u.DataTransfer)}):Object.defineProperty(f,e,{value:t}))}),f}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(Nt).forEach(e=>{let{EventType:t,defaultInit:n}=Nt[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(Pt).forEach(e=>{let t=Pt[e];Z[e]=(...e)=>Z[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=m().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},$={debug,logTestingPlaygroundURL,ariaSnapshot:h},It=typeof document<`u`&&document.body?getQueriesForElement(document.body,X,$):Object.keys(X).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),$),Lt={getElementError,wrapAllByQueryWithSuggestion,wrapSingleQueryWithSuggestion,getMultipleElementsFoundError,queryAllByAttribute,queryByAttribute,makeSingleQuery,makeGetAllQuery,makeFindQuery,buildQueries};export{h as ariaSnapshot,buildQueries,v as configure,Q as createEvent,b as diffAriaSnapshots,lt as findAllByAltText,et as findAllByDisplayValue,De as findAllByLabelText,Re as findAllByPlaceholderText,Tt as findAllByRole,Y as findAllByTestId,Ke as findAllByText,_t as findAllByTitle,ut as findByAltText,tt as findByDisplayValue,Oe as findByLabelText,ze as findByPlaceholderText,Et as findByRole,jt as findByTestId,qe as findByText,vt as findByTitle,Z as fireEvent,st as getAllByAltText,Qe as getAllByDisplayValue,ke as getAllByLabelText,Ie as getAllByPlaceholderText,Ct as getAllByRole,kt as getAllByTestId,We as getAllByText,ht as getAllByTitle,ct as getByAltText,$e as getByDisplayValue,Ae as getByLabelText,Le as getByPlaceholderText,wt as getByRole,At as getByTestId,Ge as getByText,gt 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,X as queries,at as queryAllByAltText,queryAllByAttribute,Xe as queryAllByDisplayValue,je as queryAllByLabelText,Pe as queryAllByPlaceholderText,xt as queryAllByRole,Dt as queryAllByTestId,He as queryAllByText,pt as queryAllByTitle,ot as queryByAltText,queryByAttribute,Ze as queryByDisplayValue,Te as queryByLabelText,Fe as queryByPlaceholderText,St as queryByRole,Ot as queryByTestId,Ue as queryByText,mt as queryByTitle,Lt as queryHelpers,It as screen,waitFor,waitForElementToBeRemoved,wrapAllByQueryWithSuggestion,wrapSingleQueryWithSuggestion};
|
package/package.json
CHANGED