diff --git a/.github/workflows/build_and_deploy_docs.yml b/.github/workflows/build_and_deploy_docs.yml index 0e0ca09c..02469cf0 100644 --- a/.github/workflows/build_and_deploy_docs.yml +++ b/.github/workflows/build_and_deploy_docs.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - sdk: [ stable ] + sdk: [ 2.13.4 ] steps: - uses: actions/checkout@v2 - uses: dart-lang/setup-dart@v1 @@ -26,7 +26,7 @@ jobs: - id: build-docs name: Build Docs run: pub global activate dartdoc && dartdoc --show-undocumented-categories - if: ${{ matrix.sdk == 'stable' }} + if: ${{ matrix.sdk == '2.13.4' }} - id: deploy-docs name: Deploy Docs 🚀 diff --git a/.github/workflows/dart_ci.yml b/.github/workflows/dart_ci.yml index 8200ea5f..1db02c47 100644 --- a/.github/workflows/dart_ci.yml +++ b/.github/workflows/dart_ci.yml @@ -37,15 +37,15 @@ jobs: - name: Run tests (DDC) run: | - pub run build_runner test -- -P concurrent-tests - pub run build_runner test -- -P non-concurrent-tests + dart run build_runner test -- -P concurrent-tests + dart run build_runner test -- -P non-concurrent-tests timeout-minutes: 10 if: ${{ always() && steps.install.outcome == 'success' }} - name: Run tests (dart2js) run: | - pub run build_runner test -r -- -P concurrent-tests --file-reporter json:reports/${{ matrix.sdk }}/dart2js/concurrent/test-results.json - pub run build_runner test -r -- -P non-concurrent-tests --file-reporter json:reports/${{ matrix.sdk }}/dart2js/non-concurrent/test-results.json + dart run build_runner test -r -- -P concurrent-tests --file-reporter json:reports/${{ matrix.sdk }}/dart2js/concurrent/test-results.json + dart run build_runner test -r -- -P non-concurrent-tests --file-reporter json:reports/${{ matrix.sdk }}/dart2js/non-concurrent/test-results.json timeout-minutes: 10 if: ${{ always() && steps.install.outcome == 'success' }} diff --git a/js_src/package.json b/js_src/package.json index c1fbb197..da5ece65 100644 --- a/js_src/package.json +++ b/js_src/package.json @@ -18,7 +18,7 @@ "core-js": "3", "@testing-library/dom": "^7.30.0", "@testing-library/react": "^11.2.5", - "@testing-library/user-event": "^13.1.9", + "@testing-library/user-event": "^13.5.0", "react": "^17.0.0", "react-dom": "^17.0.0" }, diff --git a/lib/js/react-testing-library.js b/lib/js/react-testing-library.js index 61c12a73..b3ad1e22 100644 --- a/lib/js/react-testing-library.js +++ b/lib/js/react-testing-library.js @@ -2,33 +2,12 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) : typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.rtl = {}, global.React, global.ReactDOM)); -}(this, (function (exports, l$1, m$1) { 'use strict'; +}(this, (function (exports, l, m) { 'use strict'; function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); - } - - var l__default = /*#__PURE__*/_interopDefaultLegacy(l$1); - var l__namespace = /*#__PURE__*/_interopNamespace(l$1); - var m__default = /*#__PURE__*/_interopDefaultLegacy(m$1); + var l__default = /*#__PURE__*/_interopDefaultLegacy(l); + var m__default = /*#__PURE__*/_interopDefaultLegacy(m); var global$2 = (typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : @@ -274,42 +253,6 @@ return _extends.apply(this, arguments); } - function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { - try { - var info = gen[key](arg); - var value = info.value; - } catch (error) { - reject(error); - return; - } - - if (info.done) { - resolve(value); - } else { - Promise.resolve(value).then(_next, _throw); - } - } - - function _asyncToGenerator(fn) { - return function () { - var self = this, - args = arguments; - return new Promise(function (resolve, reject) { - var gen = fn.apply(self, args); - - function _next(value) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); - } - - function _throw(err) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); - } - - _next(undefined); - }); - }; - } - function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } @@ -1086,6 +1029,42 @@ var regenerator = runtime_1; + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } + } + + function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; + } + var colorName = { "aliceblue": [240, 248, 255], "antiquewhite": [250, 235, 215], @@ -3448,45 +3427,11 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ - var b=60103,c=60106,d=60107,e=60108,f$7=60114,g=60109,h=60110,k=60112,l=60113,m=60120,n=60115,p=60116,q=60121,r=60122,u=60117,v=60129,w=60131; - if("function"===typeof Symbol&&Symbol.for){var x=Symbol.for;b=x("react.element");c=x("react.portal");d=x("react.fragment");e=x("react.strict_mode");f$7=x("react.profiler");g=x("react.provider");h=x("react.context");k=x("react.forward_ref");l=x("react.suspense");m=x("react.suspense_list");n=x("react.memo");p=x("react.lazy");q=x("react.block");r=x("react.server.block");u=x("react.fundamental");v=x("react.debug_trace_mode");w=x("react.legacy_hidden");} - function y(a){if("object"===typeof a&&null!==a){var t=a.$$typeof;switch(t){case b:switch(a=a.type,a){case d:case f$7:case e:case l:case m:return a;default:switch(a=a&&a.$$typeof,a){case h:case k:case p:case n:case g:return a;default:return t}}case c:return t}}}var z=g,A=b,B=k,C=d,D=p,E=n,F=c,G=f$7,H=e,I=l;var ContextConsumer=h;var ContextProvider=z;var Element=A;var ForwardRef=B;var Fragment=C;var Lazy=D;var Memo=E;var Portal=F;var Profiler=G;var StrictMode=H; - var Suspense=I;var isAsyncMode=function(){return !1};var isConcurrentMode=function(){return !1};var isContextConsumer=function(a){return y(a)===h};var isContextProvider=function(a){return y(a)===g};var isElement$1=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};var isForwardRef=function(a){return y(a)===k};var isFragment=function(a){return y(a)===d};var isLazy=function(a){return y(a)===p};var isMemo=function(a){return y(a)===n}; - var isPortal=function(a){return y(a)===c};var isProfiler=function(a){return y(a)===f$7};var isStrictMode=function(a){return y(a)===e};var isSuspense=function(a){return y(a)===l};var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f$7||a===v||a===e||a===l||a===m||a===w||"object"===typeof a&&null!==a&&(a.$$typeof===p||a.$$typeof===n||a.$$typeof===g||a.$$typeof===h||a.$$typeof===k||a.$$typeof===u||a.$$typeof===q||a[0]===r)?!0:!1}; - var typeOf=y; - - var reactIs_production_min = { - ContextConsumer: ContextConsumer, - ContextProvider: ContextProvider, - Element: Element, - ForwardRef: ForwardRef, - Fragment: Fragment, - Lazy: Lazy, - Memo: Memo, - Portal: Portal, - Profiler: Profiler, - StrictMode: StrictMode, - Suspense: Suspense, - isAsyncMode: isAsyncMode, - isConcurrentMode: isConcurrentMode, - isContextConsumer: isContextConsumer, - isContextProvider: isContextProvider, - isElement: isElement$1, - isForwardRef: isForwardRef, - isFragment: isFragment, - isLazy: isLazy, - isMemo: isMemo, - isPortal: isPortal, - isProfiler: isProfiler, - isStrictMode: isStrictMode, - isSuspense: isSuspense, - isValidElementType: isValidElementType, - typeOf: typeOf - }; + if("function"===typeof Symbol&&Symbol.for){var x=Symbol.for;x("react.element");x("react.portal");x("react.fragment");x("react.strict_mode");x("react.profiler");x("react.provider");x("react.context");x("react.forward_ref");x("react.suspense");x("react.suspense_list");x("react.memo");x("react.lazy");x("react.block");x("react.server.block");x("react.fundamental");x("react.debug_trace_mode");x("react.legacy_hidden");} var reactIs_development = createCommonjsModule(function (module, exports) { - if (process$1.env.NODE_ENV !== "production") { + { (function() { // ATTENTION @@ -3701,9 +3646,7 @@ var reactIs = createCommonjsModule(function (module) { - if (process$1.env.NODE_ENV === 'production') { - module.exports = reactIs_production_min; - } else { + { module.exports = reactIs_development; } }); @@ -4665,7 +4608,17 @@ var SetLike$1 = typeof Set === "undefined" ? Set : SetLike; - // https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html + function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest(); } + + function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + + function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); } + + function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + + function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + + function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } var localNameToRoleMappings = { article: "article", aside: "complementary", @@ -4744,7 +4697,7 @@ "aria-keyshortcuts", "aria-label", "aria-labelledby", "aria-live", "aria-owns", "aria-relevant", "aria-roledescription"].some(function (attributeName) { var _prohibitedAttributes; - return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) !== null && _prohibitedAttributes !== void 0 && _prohibitedAttributes.has(attributeName)); + return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) === null || _prohibitedAttributes === void 0 ? void 0 : _prohibitedAttributes.has(attributeName)); }); } @@ -4844,13 +4797,13 @@ } function getExplicitRole(element) { - var role = element.getAttribute("role"); - - if (role !== null) { - var explicitRole = role.trim().split(" ")[0]; // String.prototype.split(sep, limit) will always return an array with at least one member - // as long as limit is either undefined or > 0 + if (element.hasAttribute("role")) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute check + var _trim$split = element.getAttribute("role").trim().split(" "), + _trim$split2 = _slicedToArray(_trim$split, 1), + explicitRole = _trim$split2[0]; - if (explicitRole.length > 0) { + if (explicitRole !== undefined && explicitRole.length > 0) { return explicitRole; } } @@ -4880,9 +4833,6 @@ function isHTMLInputElement(node) { return isElement(node) && getLocalName(node) === "input"; } - function isHTMLOptGroupElement(node) { - return isElement(node) && getLocalName(node) === "optgroup"; - } function isHTMLSelectElement(node) { return isElement(node) && getLocalName(node) === "select"; } @@ -5157,8 +5107,7 @@ if (labelsProperty !== undefined) { return arrayFrom$1(labelsProperty); - } // polyfill - + } if (!isLabelableElement(element)) { return null; @@ -5321,12 +5270,6 @@ if (nameFromAlt !== null) { return nameFromAlt; } - } else if (isHTMLOptGroupElement(node)) { - var nameFromLabel = useAttribute(node, "label"); - - if (nameFromLabel !== null) { - return nameFromLabel; - } } if (isHTMLInputElement(node) && (node.type === "button" || node.type === "submit" || node.type === "reset")) { @@ -5348,19 +5291,22 @@ } } - var labels = getLabels$1(node); + if (isHTMLInputElement(node) || isHTMLSelectElement(node) || isHTMLTextAreaElement(node)) { + var input = node; + var labels = getLabels$1(input); - if (labels !== null && labels.length !== 0) { - consultedNodes.add(node); - return arrayFrom$1(labels).map(function (element) { - return computeTextAlternative(element, { - isEmbeddedInLabel: true, - isReferenced: false, - recursion: true - }); - }).filter(function (label) { - return label.length > 0; - }).join(" "); + if (labels !== null && labels.length !== 0) { + consultedNodes.add(input); + return arrayFrom$1(labels).map(function (element) { + return computeTextAlternative(element, { + isEmbeddedInLabel: true, + isReferenced: false, + recursion: true + }); + }).filter(function (label) { + return label.length > 0; + }).join(" "); + } } // https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation // TODO: wpt test consider label elements but html-aam does not mention them // We follow existing implementations over spec @@ -5564,10 +5510,9 @@ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global$1 = - // eslint-disable-next-line es/no-global-this -- safe + /* global globalThis -- safe */ check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || - // eslint-disable-next-line no-restricted-globals -- safe check(typeof self == 'object' && self) || check(typeof global$1 == 'object' && global$1) || // eslint-disable-next-line no-new-func -- fallback @@ -5583,23 +5528,21 @@ // Detect IE8's incomplete defineProperty implementation var descriptors = !fails(function () { - // eslint-disable-next-line es/no-object-defineproperty -- required for testing return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7; }); - var $propertyIsEnumerable$1 = {}.propertyIsEnumerable; - // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var nativePropertyIsEnumerable$1 = {}.propertyIsEnumerable; var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug - var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable$1.call({ 1: 2 }, 1); + var NASHORN_BUG = getOwnPropertyDescriptor$1 && !nativePropertyIsEnumerable$1.call({ 1: 2 }, 1); // `Object.prototype.propertyIsEnumerable` method implementation // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable var f$6 = NASHORN_BUG ? function propertyIsEnumerable(V) { var descriptor = getOwnPropertyDescriptor$1(this, V); return !!descriptor && descriptor.enumerable; - } : $propertyIsEnumerable$1; + } : nativePropertyIsEnumerable$1; var objectPropertyIsEnumerable = { f: f$6 @@ -5663,16 +5606,10 @@ throw TypeError("Can't convert object to primitive value"); }; - // `ToObject` abstract operation - // https://tc39.es/ecma262/#sec-toobject - var toObject$1 = function (argument) { - return Object(requireObjectCoercible(argument)); - }; - var hasOwnProperty$1 = {}.hasOwnProperty; - var has$1 = Object.hasOwn || function hasOwn(it, key) { - return hasOwnProperty$1.call(toObject$1(it), key); + var has$1 = function (it, key) { + return hasOwnProperty$1.call(it, key); }; var document$1 = global$1.document; @@ -5685,22 +5622,20 @@ // Thank's IE8 for his funny defineProperty var ie8DomDefine = !descriptors && !fails(function () { - // eslint-disable-next-line es/no-object-defineproperty -- requied for testing return Object.defineProperty(documentCreateElement('div'), 'a', { get: function () { return 7; } }).a != 7; }); - // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe - var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; + var nativeGetOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor - var f$5 = descriptors ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) { + var f$5 = descriptors ? nativeGetOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) { O = toIndexedObject(O); P = toPrimitive(P, true); if (ie8DomDefine) try { - return $getOwnPropertyDescriptor$1(O, P); + return nativeGetOwnPropertyDescriptor$1(O, P); } catch (error) { /* empty */ } if (has$1(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]); }; @@ -5766,17 +5701,16 @@ } return it; }; - // eslint-disable-next-line es/no-object-defineproperty -- safe - var $defineProperty$1 = Object.defineProperty; + var nativeDefineProperty$1 = Object.defineProperty; // `Object.defineProperty` method // https://tc39.es/ecma262/#sec-object.defineproperty - var f$4 = descriptors ? $defineProperty$1 : function defineProperty(O, P, Attributes) { + var f$4 = descriptors ? nativeDefineProperty$1 : function defineProperty(O, P, Attributes) { anObject(O); P = toPrimitive(P, true); anObject(Attributes); if (ie8DomDefine) try { - return $defineProperty$1(O, P, Attributes); + return nativeDefineProperty$1(O, P, Attributes); } catch (error) { /* empty */ } if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported'); if ('value' in Attributes) O[P] = Attributes.value; @@ -5921,7 +5855,6 @@ }; var freezing = !fails(function () { - // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing return Object.isExtensible(Object.preventExtensions({})); }); @@ -5933,7 +5866,6 @@ var METADATA = uid('meta'); var id = 0; - // eslint-disable-next-line es/no-object-isextensible -- safe var isExtensible = Object.isExtensible || function () { return true; }; @@ -6004,12 +5936,14 @@ (module.exports = function (key, value) { return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); })('versions', []).push({ - version: '3.15.1', + version: '3.9.1', mode: 'pure' , copyright: '© 2021 Denis Pushkarev (zloirock.ru)' }); }); + var engineIsNode = classofRaw(global$1.process) == 'process'; + var aFunction = function (variable) { return typeof variable == 'function' ? variable : undefined; }; @@ -6028,7 +5962,7 @@ if (v8) { match = v8.split('.'); - version = match[0] < 4 ? 1 : match[0] + match[1]; + version = match[0] + match[1]; } else if (engineUserAgent) { match = engineUserAgent.match(/Edge\/(\d+)/); if (!match || match[1] >= 74) { @@ -6039,21 +5973,16 @@ var engineV8Version = version && +version; - /* eslint-disable es/no-symbol -- required for testing */ - - // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () { - var symbol = Symbol(); - // Chrome 38 Symbol has incorrect toString conversion - // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances - return !String(symbol) || !(Object(symbol) instanceof Symbol) || + /* global Symbol -- required for testing */ + return !Symbol.sham && + // Chrome 38 Symbol has incorrect toString conversion // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances - !Symbol.sham && engineV8Version && engineV8Version < 41; + (engineIsNode ? engineV8Version === 38 : engineV8Version > 37 && engineV8Version < 41); }); - /* eslint-disable es/no-symbol -- required for testing */ - var useSymbolAsUid = nativeSymbol + /* global Symbol -- safe */ && !Symbol.sham && typeof Symbol.iterator == 'symbol'; @@ -6073,12 +6002,12 @@ var iterators = {}; - var ITERATOR$4 = wellKnownSymbol('iterator'); + var ITERATOR$5 = wellKnownSymbol('iterator'); var ArrayPrototype$6 = Array.prototype; // check on default Array iterator var isArrayIteratorMethod = function (it) { - return it !== undefined && (iterators.Array === it || ArrayPrototype$6[ITERATOR$4] === it); + return it !== undefined && (iterators.Array === it || ArrayPrototype$6[ITERATOR$5] === it); }; var ceil = Math.ceil; @@ -6128,10 +6057,10 @@ : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result; }; - var ITERATOR$3 = wellKnownSymbol('iterator'); + var ITERATOR$4 = wellKnownSymbol('iterator'); var getIteratorMethod$1 = function (it) { - if (it != undefined) return it[ITERATOR$3] + if (it != undefined) return it[ITERATOR$4] || it['@@iterator'] || iterators[classof(it)]; }; @@ -6227,9 +6156,14 @@ } }; + // `ToObject` abstract operation + // https://tc39.es/ecma262/#sec-toobject + var toObject$1 = function (argument) { + return Object(requireObjectCoercible(argument)); + }; + // `IsArray` abstract operation // https://tc39.es/ecma262/#sec-isarray - // eslint-disable-next-line es/no-array-isarray -- safe var isArray$5 = Array.isArray || function isArray(arg) { return classofRaw(arg) == 'Array'; }; @@ -6320,7 +6254,7 @@ var functionToString = Function.toString; - // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper + // this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper if (typeof sharedStore.inspectSource != 'function') { sharedStore.inspectSource = function (it) { return functionToString.call(it); @@ -6339,7 +6273,6 @@ return keys$6[key] || (keys$6[key] = uid(key)); }; - var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; var WeakMap$1 = global$1.WeakMap; var set$3, get, has; @@ -6356,13 +6289,12 @@ }; }; - if (nativeWeakMap || sharedStore.state) { + if (nativeWeakMap) { var store = sharedStore.state || (sharedStore.state = new WeakMap$1()); var wmget = store.get; var wmhas = store.has; var wmset = store.set; set$3 = function (it, metadata) { - if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); metadata.facade = it; wmset.call(store, it, metadata); return metadata; @@ -6377,7 +6309,6 @@ var STATE = sharedKey('state'); hiddenKeys$1[STATE] = true; set$3 = function (it, metadata) { - if (has$1(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); metadata.facade = it; createNonEnumerableProperty(it, STATE, metadata); return metadata; @@ -6531,14 +6462,12 @@ // `Object.keys` method // https://tc39.es/ecma262/#sec-object.keys - // eslint-disable-next-line es/no-object-keys -- safe var objectKeys = Object.keys || function keys(O) { return objectKeysInternal(O, enumBugKeys); }; // `Object.defineProperties` method // https://tc39.es/ecma262/#sec-object.defineproperties - // eslint-disable-next-line es/no-object-defineproperties -- safe var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) { anObject(O); var keys = objectKeys(Properties); @@ -6637,7 +6566,6 @@ var correctPrototypeGetter = !fails(function () { function F() { /* empty */ } F.prototype.constructor = null; - // eslint-disable-next-line es/no-object-getprototypeof -- required for testing return Object.getPrototypeOf(new F()) !== F.prototype; }); @@ -6646,7 +6574,6 @@ // `Object.getPrototypeOf` method // https://tc39.es/ecma262/#sec-object.getprototypeof - // eslint-disable-next-line es/no-object-getprototypeof -- safe var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) { O = toObject$1(O); if (has$1(O, IE_PROTO)) return O[IE_PROTO]; @@ -6655,7 +6582,7 @@ } return O instanceof Object ? ObjectPrototype$1 : null; }; - var ITERATOR$2 = wellKnownSymbol('iterator'); + var ITERATOR$3 = wellKnownSymbol('iterator'); var BUGGY_SAFARI_ITERATORS$1 = false; var returnThis$2 = function () { return this; }; @@ -6664,7 +6591,6 @@ // https://tc39.es/ecma262/#sec-%iteratorprototype%-object var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator; - /* eslint-disable es/no-array-prototype-keys -- safe */ if ([].keys) { arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next` @@ -6678,15 +6604,14 @@ var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails(function () { var test = {}; // FF44- legacy iterators case - return IteratorPrototype$2[ITERATOR$2].call(test) !== test; + return IteratorPrototype$2[ITERATOR$3].call(test) !== test; }); if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {}; - // `%IteratorPrototype%[@@iterator]()` method - // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator - if ((NEW_ITERATOR_PROTOTYPE) && !has$1(IteratorPrototype$2, ITERATOR$2)) { - createNonEnumerableProperty(IteratorPrototype$2, ITERATOR$2, returnThis$2); + // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() + if ((NEW_ITERATOR_PROTOTYPE) && !has$1(IteratorPrototype$2, ITERATOR$3)) { + createNonEnumerableProperty(IteratorPrototype$2, ITERATOR$3, returnThis$2); } var iteratorsCore = { @@ -6721,13 +6646,11 @@ // `Object.setPrototypeOf` method // https://tc39.es/ecma262/#sec-object.setprototypeof // Works with __proto__ only. Old v8 can't work with null proto objects. - // eslint-disable-next-line es/no-object-setprototypeof -- safe Object.setPrototypeOf || ('__proto__' in {} ? function () { var CORRECT_SETTER = false; var test = {}; var setter; try { - // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set; setter.call(test, []); CORRECT_SETTER = test instanceof Array; @@ -6743,7 +6666,7 @@ var IteratorPrototype = iteratorsCore.IteratorPrototype; var BUGGY_SAFARI_ITERATORS = iteratorsCore.BUGGY_SAFARI_ITERATORS; - var ITERATOR$1 = wellKnownSymbol('iterator'); + var ITERATOR$2 = wellKnownSymbol('iterator'); var KEYS = 'keys'; var VALUES = 'values'; var ENTRIES = 'entries'; @@ -6766,7 +6689,7 @@ var TO_STRING_TAG = NAME + ' Iterator'; var INCORRECT_VALUES_NAME = false; var IterablePrototype = Iterable.prototype; - var nativeIterator = IterablePrototype[ITERATOR$1] + var nativeIterator = IterablePrototype[ITERATOR$2] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT]; var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); @@ -6783,15 +6706,15 @@ } } - // fix Array.prototype.{ values, @@iterator }.name in V8 / FF + // fix Array#{values, @@iterator}.name in V8 / FF if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { INCORRECT_VALUES_NAME = true; defaultIterator = function values() { return nativeIterator.call(this); }; } // define iterator - if ((FORCED) && IterablePrototype[ITERATOR$1] !== defaultIterator) { - createNonEnumerableProperty(IterablePrototype, ITERATOR$1, defaultIterator); + if ((FORCED) && IterablePrototype[ITERATOR$2] !== defaultIterator) { + createNonEnumerableProperty(IterablePrototype, ITERATOR$2, defaultIterator); } iterators[NAME] = defaultIterator; @@ -6897,9 +6820,8 @@ }; redefineAll(C.prototype, { - // `{ Map, Set }.prototype.clear()` methods - // https://tc39.es/ecma262/#sec-map.prototype.clear - // https://tc39.es/ecma262/#sec-set.prototype.clear + // 23.1.3.1 Map.prototype.clear() + // 23.2.3.2 Set.prototype.clear() clear: function clear() { var that = this; var state = getInternalState(that); @@ -6915,9 +6837,8 @@ if (descriptors) state.size = 0; else that.size = 0; }, - // `{ Map, Set }.prototype.delete(key)` methods - // https://tc39.es/ecma262/#sec-map.prototype.delete - // https://tc39.es/ecma262/#sec-set.prototype.delete + // 23.1.3.3 Map.prototype.delete(key) + // 23.2.3.4 Set.prototype.delete(value) 'delete': function (key) { var that = this; var state = getInternalState(that); @@ -6935,9 +6856,8 @@ else that.size--; } return !!entry; }, - // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods - // https://tc39.es/ecma262/#sec-map.prototype.foreach - // https://tc39.es/ecma262/#sec-set.prototype.foreach + // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) + // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) forEach: function forEach(callbackfn /* , that = undefined */) { var state = getInternalState(this); var boundFunction = functionBindContext(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); @@ -6948,29 +6868,25 @@ while (entry && entry.removed) entry = entry.previous; } }, - // `{ Map, Set}.prototype.has(key)` methods - // https://tc39.es/ecma262/#sec-map.prototype.has - // https://tc39.es/ecma262/#sec-set.prototype.has + // 23.1.3.7 Map.prototype.has(key) + // 23.2.3.7 Set.prototype.has(value) has: function has(key) { return !!getEntry(this, key); } }); redefineAll(C.prototype, IS_MAP ? { - // `Map.prototype.get(key)` method - // https://tc39.es/ecma262/#sec-map.prototype.get + // 23.1.3.6 Map.prototype.get(key) get: function get(key) { var entry = getEntry(this, key); return entry && entry.value; }, - // `Map.prototype.set(key, value)` method - // https://tc39.es/ecma262/#sec-map.prototype.set + // 23.1.3.9 Map.prototype.set(key, value) set: function set(key, value) { return define(this, key === 0 ? 0 : key, value); } } : { - // `Set.prototype.add(value)` method - // https://tc39.es/ecma262/#sec-set.prototype.add + // 23.2.3.1 Set.prototype.add(value) add: function add(value) { return define(this, value = value === 0 ? 0 : value, value); } @@ -6986,15 +6902,8 @@ var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator'; var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME); var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME); - // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods - // https://tc39.es/ecma262/#sec-map.prototype.entries - // https://tc39.es/ecma262/#sec-map.prototype.keys - // https://tc39.es/ecma262/#sec-map.prototype.values - // https://tc39.es/ecma262/#sec-map.prototype-@@iterator - // https://tc39.es/ecma262/#sec-set.prototype.entries - // https://tc39.es/ecma262/#sec-set.prototype.keys - // https://tc39.es/ecma262/#sec-set.prototype.values - // https://tc39.es/ecma262/#sec-set.prototype-@@iterator + // add .keys, .values, .entries, [@@iterator] + // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 defineIterator(C, CONSTRUCTOR_NAME, function (iterated, kind) { setInternalState$3(this, { type: ITERATOR_NAME, @@ -7021,9 +6930,7 @@ return { value: [entry.key, entry.value], done: false }; }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); - // `{ Map, Set }.prototype[@@species]` accessors - // https://tc39.es/ecma262/#sec-get-map-@@species - // https://tc39.es/ecma262/#sec-get-set-@@species + // add [@@species], 23.1.2.2, 23.2.2.2 setSpecies(CONSTRUCTOR_NAME); } }; @@ -7690,7 +7597,6 @@ // `Object.getOwnPropertyNames` method // https://tc39.es/ecma262/#sec-object.getownpropertynames - // eslint-disable-next-line es/no-object-getownpropertynames -- safe var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { return objectKeysInternal(O, hiddenKeys); }; @@ -7699,9 +7605,7 @@ f: f$3 }; - /* eslint-disable es/no-object-getownpropertynames -- safe */ - - var $getOwnPropertyNames$1 = objectGetOwnPropertyNames.f; + var nativeGetOwnPropertyNames$1 = objectGetOwnPropertyNames.f; var toString = {}.toString; @@ -7710,7 +7614,7 @@ var getWindowNames = function (it) { try { - return $getOwnPropertyNames$1(it); + return nativeGetOwnPropertyNames$1(it); } catch (error) { return windowNames.slice(); } @@ -7720,14 +7624,13 @@ var f$2 = function getOwnPropertyNames(it) { return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) - : $getOwnPropertyNames$1(toIndexedObject(it)); + : nativeGetOwnPropertyNames$1(toIndexedObject(it)); }; var objectGetOwnPropertyNamesExternal = { f: f$2 }; - // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe var f$1 = Object.getOwnPropertySymbols; var objectGetOwnPropertySymbols = { @@ -8088,6 +7991,7 @@ var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) { try { return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value); + // 7.4.6 IteratorClose(iterator, completion) } catch (error) { iteratorClose(iterator); throw error; @@ -8127,7 +8031,7 @@ return result; }; - var ITERATOR = wellKnownSymbol('iterator'); + var ITERATOR$1 = wellKnownSymbol('iterator'); var SAFE_CLOSING = false; try { @@ -8140,10 +8044,10 @@ SAFE_CLOSING = true; } }; - iteratorWithReturn[ITERATOR] = function () { + iteratorWithReturn[ITERATOR$1] = function () { return this; }; - // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing + // eslint-disable-next-line no-throw-literal -- required for testing Array.from(iteratorWithReturn, function () { throw 2; }); } catch (error) { /* empty */ } @@ -8152,7 +8056,7 @@ var ITERATION_SUPPORT = false; try { var object = {}; - object[ITERATOR] = function () { + object[ITERATOR$1] = function () { return { next: function () { return { done: ITERATION_SUPPORT = true }; @@ -8165,7 +8069,6 @@ }; var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) { - // eslint-disable-next-line es/no-array-from -- required for testing Array.from(iterable); }); @@ -8259,16 +8162,14 @@ module.exports["default"] = module.exports, module.exports.__esModule = true; }); - // eslint-disable-next-line es/no-object-assign -- safe - var $assign = Object.assign; - // eslint-disable-next-line es/no-object-defineproperty -- required for testing + var nativeAssign = Object.assign; var defineProperty = Object.defineProperty; // `Object.assign` method // https://tc39.es/ecma262/#sec-object.assign - var objectAssign$1 = !$assign || fails(function () { + var objectAssign$1 = !nativeAssign || fails(function () { // should have correct order of operations (Edge bug) - if (descriptors && $assign({ b: 1 }, $assign(defineProperty({}, 'a', { + if (descriptors && nativeAssign({ b: 1 }, nativeAssign(defineProperty({}, 'a', { enumerable: true, get: function () { defineProperty(this, 'b', { @@ -8280,12 +8181,12 @@ // should work with symbols and should have deterministic property order (V8 bug) var A = {}; var B = {}; - // eslint-disable-next-line es/no-symbol -- safe + /* global Symbol -- required for testing */ var symbol = Symbol(); var alphabet = 'abcdefghijklmnopqrst'; A[symbol] = 7; alphabet.split('').forEach(function (chr) { B[chr] = chr; }); - return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet; + return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet; }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length` var T = toObject$1(target); var argumentsLength = arguments.length; @@ -8303,11 +8204,10 @@ if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key]; } } return T; - } : $assign; + } : nativeAssign; // `Object.assign` method // https://tc39.es/ecma262/#sec-object.assign - // eslint-disable-next-line es/no-object-assign -- required for testing _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign$1 }, { assign: objectAssign$1 }); @@ -8351,12 +8251,10 @@ // https://tc39.es/ecma262/#sec-array.prototype.foreach var arrayForEach = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) { return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - // eslint-disable-next-line es/no-array-prototype-foreach -- safe } : [].forEach; // `Array.prototype.forEach` method // https://tc39.es/ecma262/#sec-array.prototype.foreach - // eslint-disable-next-line es/no-array-prototype-foreach -- safe _export({ target: 'Array', proto: true, forced: [].forEach != arrayForEach }, { forEach: arrayForEach }); @@ -14022,21 +13920,10 @@ // https://github.com/tc39/proposal-using-statement defineWellKnownSymbol('dispose'); - // `Symbol.matcher` well-known symbol - // https://github.com/tc39/proposal-pattern-matching - defineWellKnownSymbol('matcher'); - - // `Symbol.metadata` well-known symbol - // https://github.com/tc39/proposal-decorators - defineWellKnownSymbol('metadata'); - // `Symbol.observable` well-known symbol // https://github.com/tc39/proposal-observable defineWellKnownSymbol('observable'); - // TODO: remove from `core-js@4` - - // `Symbol.patternMatch` well-known symbol // https://github.com/tc39/proposal-pattern-matching defineWellKnownSymbol('patternMatch'); @@ -14048,26 +13935,35 @@ // TODO: Remove from `core-js@4` - // TODO: Remove from `core-js@4` - var symbol$1 = symbol$4; var symbol = symbol$1; + var ITERATOR = wellKnownSymbol('iterator'); + + var isIterable$1 = function (it) { + var O = Object(it); + return O[ITERATOR] !== undefined + || '@@iterator' in O + // eslint-disable-next-line no-prototype-builtins -- safe + || iterators.hasOwnProperty(classof(O)); + }; + + var isIterable_1 = isIterable$1; + + var isIterable = isIterable_1; + var iterableToArrayLimit = createCommonjsModule(function (module) { function _iterableToArrayLimit(arr, i) { - var _i = arr == null ? null : typeof symbol !== "undefined" && getIteratorMethod(arr) || arr["@@iterator"]; - - if (_i == null) return; + if (typeof symbol === "undefined" || !isIterable(Object(arr))) return; var _arr = []; var _n = true; var _d = false; - - var _s, _e; + var _e = undefined; try { - for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { + for (var _i = getIterator(arr), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; @@ -14230,7 +14126,6 @@ }); } - // eslint-disable-next-line es/no-json -- safe if (!path.JSON) path.JSON = { stringify: JSON.stringify }; // eslint-disable-next-line no-unused-vars -- required for `.length` @@ -14286,7 +14181,7 @@ var iterableToArray = createCommonjsModule(function (module) { function _iterableToArray(iter) { - if (typeof symbol !== "undefined" && getIteratorMethod(iter) != null || iter["@@iterator"] != null) return from(iter); + if (typeof symbol !== "undefined" && isIterable(Object(iter))) return from(iter); } module.exports = _iterableToArray; @@ -15053,12 +14948,13 @@ var TEXT_NODE = 3; // Currently this fn only supports jest timers, but it could support other test runners in the future. function runWithRealTimers(callback) { - return hasJestTimers() ? runWithJestRealTimers(callback).callbackReturnValue : // istanbul ignore next - callback(); - } + // istanbul ignore else + if (typeof jest !== 'undefined') { + return runWithJestRealTimers(callback).callbackReturnValue; + } // istanbul ignore next - function hasJestTimers() { - return typeof jest !== 'undefined' && jest !== null && typeof jest.useRealTimers === 'function'; + + return callback(); } function runWithJestRealTimers(callback) { @@ -15099,8 +14995,13 @@ } function jestFakeTimersAreEnabled() { - return hasJestTimers() ? runWithJestRealTimers(function () {}).usedFakeTimers : // istanbul ignore next - false; + // istanbul ignore else + if (typeof jest !== 'undefined') { + return runWithJestRealTimers(function () {}).usedFakeTimers; + } // istanbul ignore next + + + return false; } // we only run our tests in node, and setImmediate is supported in node. // istanbul ignore next @@ -15146,8 +15047,6 @@ throw new Error("It looks like you passed a Promise object instead of a DOM node. Did you do something like `fireEvent.click(screen.findBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`, or await the findBy query `fireEvent.click(await screen.findBy...`?"); } else if (Array.isArray(node)) { throw new Error("It looks like you passed an Array instead of a DOM node. Did you do something like `fireEvent.click(screen.getAllBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`?"); - } else if (typeof node.debug === 'function' && typeof node.logTestingPlaygroundURL === 'function') { - throw new Error("It looks like you passed a `screen` object. Did you do something like `fireEvent.click(screen, ...` when you meant to use a query, e.g. `fireEvent.click(screen.getBy..., `?"); } else { // The user passed something unusual to a calling function throw new Error("Unable to find the \"window\" object for the given node. Please file an issue with the code that's causing you to see this error: https://github.com/testing-library/dom-testing-library/issues/new"); @@ -15464,7 +15363,7 @@ }).join(''); } - function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } @@ -16363,7 +16262,7 @@ }); } - var queryAllLabelsByText = function queryAllLabelsByText(container, text, _temp) { + function queryAllLabelsByText(container, text, _temp) { var _ref2 = _temp === void 0 ? {} : _temp, _ref2$exact = _ref2.exact, exact = _ref2$exact === void 0 ? true : _ref2$exact, @@ -16386,9 +16285,9 @@ var node = _ref4.node; return node; }); - }; + } - var queryAllByLabelText = function queryAllByLabelText(container, text, _temp2) { + function queryAllByLabelText(container, text, _temp2) { var _ref5 = _temp2 === void 0 ? {} : _temp2, _ref5$selector = _ref5.selector, selector = _ref5$selector === void 0 ? '*' : _ref5$selector, @@ -16414,7 +16313,7 @@ labelList.filter(function (label) { return Boolean(label.formControl); }).forEach(function (label) { - if (matcher(label.content, label.formControl, text, matchNormalizer) && label.formControl) labelledElements.push(label.formControl); + if (matcher(label.content, label.formControl, text, matchNormalizer)) labelledElements.push(label.formControl); }); var labelsValue = labelList.filter(function (label) { return Boolean(label.content); @@ -16436,17 +16335,14 @@ } return labelledElements; - }, []).concat( // TODO: Remove ignore after `queryAllByAttribute` will be moved to TS - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error - queryAllByAttribute('aria-label', container, text, { + }, []).concat(queryAllByAttribute('aria-label', container, text, { exact: exact, normalizer: matchNormalizer })); return Array.from(new Set(matchingLabelledElements)).filter(function (element) { return element.matches(selector); }); - }; // the getAll* query would normally look like this: + } // the getAll* query would normally look like this: // const getAllByLabelText = makeGetAllQuery( // queryAllByLabelText, // (c, text) => `Unable to find a label with the text of: ${text}`, @@ -16511,17 +16407,14 @@ var getByLabelTextWithSuggestions = wrapSingleQueryWithSuggestion(getByLabelText, getAllByLabelText.name, 'get'); var queryAllByLabelTextWithSuggestions = wrapAllByQueryWithSuggestion(queryAllByLabelText, queryAllByLabelText.name, 'queryAll'); - var queryAllByPlaceholderText = function queryAllByPlaceholderText() { + function queryAllByPlaceholderText() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - checkContainerType(args[0]); // TODO: Remove ignore after `queryAllByAttribute` will be moved to TS - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error - + checkContainerType.apply(void 0, args); return queryAllByAttribute.apply(void 0, ['placeholder'].concat(args)); - }; + } var getMultipleError$6 = function getMultipleError(c, text) { return "Found multiple elements with the placeholder text of: " + text; @@ -16540,7 +16433,7 @@ findAllByPlaceholderText = _buildQueries$6[3], findByPlaceholderText = _buildQueries$6[4]; - var queryAllByText = function queryAllByText(container, text, _temp) { + function queryAllByText(container, text, _temp) { var _ref = _temp === void 0 ? {} : _temp, _ref$selector = _ref.selector, selector = _ref$selector === void 0 ? '*' : _ref$selector, @@ -16565,13 +16458,12 @@ baseArray = [container]; } - return [].concat(baseArray, Array.from(container.querySelectorAll(selector))) // TODO: `matches` according lib.dom.d.ts can get only `string` but according our code it can handle also boolean :) - .filter(function (node) { + return [].concat(baseArray, Array.from(container.querySelectorAll(selector))).filter(function (node) { return !ignore || !node.matches(ignore); }).filter(function (node) { return matcher(getNodeText(node), node, text, matchNormalizer); }); - }; + } var getMultipleError$5 = function getMultipleError(c, text) { return "Found multiple elements with the text: " + text; @@ -16590,7 +16482,7 @@ findAllByText = _buildQueries$5[3], findByText = _buildQueries$5[4]; - var queryAllByDisplayValue = function queryAllByDisplayValue(container, value, _temp) { + function queryAllByDisplayValue(container, value, _temp) { var _ref = _temp === void 0 ? {} : _temp, _ref$exact = _ref.exact, exact = _ref$exact === void 0 ? true : _ref$exact, @@ -16617,7 +16509,7 @@ return matcher(node.value, node, value, matchNormalizer); } }); - }; + } var getMultipleError$4 = function getMultipleError(c, value) { return "Found multiple elements with the display value: " + value + "."; @@ -16636,7 +16528,7 @@ findAllByDisplayValue = _buildQueries$4[3], findByDisplayValue = _buildQueries$4[4]; - var queryAllByAltText = function queryAllByAltText(container, alt, _temp) { + function queryAllByAltText(container, alt, _temp) { var _ref = _temp === void 0 ? {} : _temp, _ref$exact = _ref.exact, exact = _ref$exact === void 0 ? true : _ref$exact, @@ -16654,7 +16546,7 @@ return Array.from(container.querySelectorAll('img,input,area')).filter(function (node) { return matcher(node.getAttribute('alt'), node, alt, matchNormalizer); }); - }; + } var getMultipleError$3 = function getMultipleError(c, alt) { return "Found multiple elements with the alt text: " + alt; @@ -16679,7 +16571,7 @@ return node.tagName.toLowerCase() === 'title' && ((_node$parentElement = node.parentElement) == null ? void 0 : _node$parentElement.tagName.toLowerCase()) === 'svg'; }; - var queryAllByTitle = function queryAllByTitle(container, text, _temp) { + function queryAllByTitle(container, text, _temp) { var _ref = _temp === void 0 ? {} : _temp, _ref$exact = _ref.exact, exact = _ref$exact === void 0 ? true : _ref$exact, @@ -16697,7 +16589,7 @@ return Array.from(container.querySelectorAll('[title], svg > title')).filter(function (node) { return matcher(node.getAttribute('title'), node, text, matchNormalizer) || isSvgTitle(node) && matcher(getNodeText(node), node, text, matchNormalizer); }); - }; + } var getMultipleError$2 = function getMultipleError(c, title) { return "Found multiple elements with the title: " + title + "."; @@ -16936,17 +16828,14 @@ return getConfig().testIdAttribute; }; - var queryAllByTestId = function queryAllByTestId() { + function queryAllByTestId() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - checkContainerType(args[0]); // TODO: Remove ignore after `queryAllByAttribute` will be moved to TS - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error - + checkContainerType.apply(void 0, args); return queryAllByAttribute.apply(void 0, [getTestIdAttribute()].concat(args)); - }; + } var getMultipleError = function getMultipleError(c, id) { return "Found multiple elements by: [" + getTestIdAttribute() + "=\"" + id + "\"]"; @@ -17893,9 +17782,6 @@ doubleClick: 'dblClick' }; - var _excluded = ["value", "files"], - _excluded2 = ["bubbles", "cancelable", "detail"]; - function fireEvent$1(element, event) { return getConfig().eventWrapper(function () { if (!event) { @@ -17928,7 +17814,7 @@ var value = _eventInit$target.value, files = _eventInit$target.files, - targetProperties = _objectWithoutPropertiesLoose(_eventInit$target, _excluded); + targetProperties = _objectWithoutPropertiesLoose(_eventInit$target, ["value", "files"]); if (value !== undefined) { setNativeValue(node, value); @@ -17961,7 +17847,7 @@ var bubbles = eventInit.bubbles, cancelable = eventInit.cancelable, detail = eventInit.detail, - otherInit = _objectWithoutPropertiesLoose(eventInit, _excluded2); + otherInit = _objectWithoutPropertiesLoose(eventInit, ["bubbles", "cancelable", "detail"]); event.initEvent(eventName, bubbles, cancelable, detail); Object.keys(otherInit).forEach(function (eventKey) { @@ -18276,7 +18162,7 @@ * LICENSE file in the root directory of this source tree. */ - var scheduler_production_min = createCommonjsModule(function (module, exports) { + createCommonjsModule(function (module, exports) { var f,g,h,k;if("object"===typeof performance&&"function"===typeof performance.now){var l=performance;exports.unstable_now=function(){return l.now()};}else {var p=Date,q=p.now();exports.unstable_now=function(){return p.now()-q};} if("undefined"===typeof window||"function"!==typeof MessageChannel){var t=null,u=null,w=function(){if(null!==t)try{var a=exports.unstable_now();t(!0,a);t=null;}catch(b){throw setTimeout(w,0),b;}};f=function(a){null!==t?setTimeout(f,0,a):(t=a,setTimeout(w,0));};g=function(a,b){u=setTimeout(a,b);};h=function(){clearTimeout(u);};exports.unstable_shouldYield=function(){return !1};k=exports.unstable_forceFrameRate=function(){};}else {var x=window.setTimeout,y=window.clearTimeout;if("undefined"!==typeof console){var z= window.cancelAnimationFrame;"function"!==typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");"function"!==typeof z&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");}var A=!1,B=null,C=-1,D=5,E=0;exports.unstable_shouldYield=function(){return exports.unstable_now()>= @@ -18293,7 +18179,7 @@ var scheduler_development = createCommonjsModule(function (module, exports) { - if (process$1.env.NODE_ENV !== "production") { + { (function() { var enableSchedulerDebugging = false; @@ -18919,9 +18805,7 @@ var scheduler = createCommonjsModule(function (module) { - if (process$1.env.NODE_ENV === 'production') { - module.exports = scheduler_production_min; - } else { + { module.exports = scheduler_development; } }); @@ -18935,7 +18819,7 @@ * LICENSE file in the root directory of this source tree. */ - var reactDomTestUtils_production_min = createCommonjsModule(function (module, exports) { + createCommonjsModule(function (module, exports) { function p(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c {}).usedFakeTimers : // istanbul ignore next - false; + // istanbul ignore else + if (typeof jest !== 'undefined') { + return runWithJestRealTimers(() => {}).usedFakeTimers; + } // istanbul ignore next + + + return false; } // we only run our tests in node, and setImmediate is supported in node. // istanbul ignore next @@ -22175,8 +22064,6 @@ throw new Error(`It looks like you passed a Promise object instead of a DOM node. Did you do something like \`fireEvent.click(screen.findBy...\` when you meant to use a \`getBy\` query \`fireEvent.click(screen.getBy...\`, or await the findBy query \`fireEvent.click(await screen.findBy...\`?`); } else if (Array.isArray(node)) { throw new Error(`It looks like you passed an Array instead of a DOM node. Did you do something like \`fireEvent.click(screen.getAllBy...\` when you meant to use a \`getBy\` query \`fireEvent.click(screen.getBy...\`?`); - } else if (typeof node.debug === 'function' && typeof node.logTestingPlaygroundURL === 'function') { - throw new Error(`It looks like you passed a \`screen\` object. Did you do something like \`fireEvent.click(screen, ...\` when you meant to use a query, e.g. \`fireEvent.click(screen.getBy..., \`?`); } else { // The user passed something unusual to a calling function throw new Error(`Unable to find the "window" object for the given node. Please file an issue with the code that's causing you to see this error: https://github.com/testing-library/dom-testing-library/issues/new`); @@ -22266,6 +22153,18 @@ hasPointerEvents: hasPointerEvents_2 }, '__esModule', {value: true}); + var hasFormSubmit_1 = createCommonjsModule(function (module, exports) { + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.hasFormSubmit = void 0; + + const hasFormSubmit = form => !!(form && (form.querySelector('input[type="submit"]') || form.querySelector('button[type="submit"]'))); + + exports.hasFormSubmit = hasFormSubmit; + }); + var utils = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, "__esModule", { @@ -22583,6 +22482,19 @@ } }); }); + + + + Object.keys(hasFormSubmit_1).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === hasFormSubmit_1[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function () { + return hasFormSubmit_1[key]; + } + }); + }); }); var hover_2 = hover; @@ -22604,8 +22516,10 @@ return parentElements; } - function hover(element, init) { - if (!(0, utils.hasPointerEvents)(element)) { + function hover(element, init, { + skipPointerEventsCheck = false + } = {}) { + if (!skipPointerEventsCheck && !(0, utils.hasPointerEvents)(element)) { throw new Error('unable to hover element as it has or inherits pointer-events set to "none".'); } @@ -22633,8 +22547,10 @@ } } - function unhover(element, init) { - if (!(0, utils.hasPointerEvents)(element)) { + function unhover(element, init, { + skipPointerEventsCheck = false + } = {}) { + if (!skipPointerEventsCheck && !(0, utils.hasPointerEvents)(element)) { throw new Error('unable to unhover element as it has or inherits pointer-events set to "none".'); } @@ -22804,13 +22720,17 @@ function click(element, init, { skipHover = false, - clickCount = 0 + clickCount = 0, + skipPointerEventsCheck = false } = {}) { - if (!(0, utils.hasPointerEvents)(element)) { + if (!skipPointerEventsCheck && !(0, utils.hasPointerEvents)(element)) { throw new Error('unable to click element as it has or inherits pointer-events set to "none".'); - } + } // We just checked for `pointerEvents`. We can always skip this one in `hover`. + - if (!skipHover) (0, hover_1.hover)(element, init); + if (!skipHover) (0, hover_1.hover)(element, init, { + skipPointerEventsCheck: true + }); if ((0, utils.isElementType)(element, 'label')) { clickLabel(element, init, { @@ -22841,19 +22761,25 @@ } } - function dblClick(element, init) { - if (!(0, utils.hasPointerEvents)(element)) { + function dblClick(element, init, { + skipPointerEventsCheck = false + } = {}) { + if (!skipPointerEventsCheck && !(0, utils.hasPointerEvents)(element)) { throw new Error('unable to double-click element as it has or inherits pointer-events set to "none".'); } - (0, hover_1.hover)(element, init); + (0, hover_1.hover)(element, init, { + skipPointerEventsCheck + }); click(element, init, { skipHover: true, - clickCount: 0 + clickCount: 0, + skipPointerEventsCheck }); click(element, init, { skipHover: true, - clickCount: 1 + clickCount: 1, + skipPointerEventsCheck }); _dom.fireEvent.dblClick(element, (0, utils.getMouseEventOptions)('dblclick', init, 2)); @@ -22865,7 +22791,23 @@ }, '__esModule', {value: true}); var getNextKeyDef_2 = getNextKeyDef; + var bracketDict; + + (function (bracketDict) { + bracketDict["{"] = "}"; + bracketDict["["] = "]"; + })(bracketDict || (bracketDict = {})); + + var legacyModifiers; + (function (legacyModifiers) { + legacyModifiers["alt"] = "alt"; + legacyModifiers["ctrl"] = "ctrl"; + legacyModifiers["meta"] = "meta"; + legacyModifiers["shift"] = "shift"; + })(legacyModifiers || (legacyModifiers = {})); + + var legacyKeyMap; /** * Get the next key from keyMap * @@ -22873,103 +22815,148 @@ * Everything else will be interpreted as a typed character - e.g. `a`. * Brackets `{` and `[` can be escaped by doubling - e.g. `foo[[bar` translates to `foo[bar`. * Keeping the key pressed can be written as `{key>}`. + * When keeping the key pressed you can choose how long (how many keydown and keypress) the key is pressed `{key>3}`. + * You can then release the key per `{key>3/}` or keep it pressed and continue with the next key. * Modifiers like `{shift}` imply being kept pressed. This can be turned of per `{shift/}`. */ - function getNextKeyDef(text, options) { - var _text$slice$match; - const startBracket = ['{', '['].includes(text[0]) ? text[0] : ''; - const startModifier = startBracket && text[1] === '/' ? '/' : ''; - const descriptorStart = startBracket.length + startModifier.length; - const descriptor = startBracket ? text[descriptorStart] === startBracket ? startBracket : (_text$slice$match = text.slice(descriptorStart).match(/^\w+/)) == null ? void 0 : _text$slice$match[0] : text[descriptorStart]; + (function (legacyKeyMap) { + legacyKeyMap["ctrl"] = "Control"; + legacyKeyMap["del"] = "Delete"; + legacyKeyMap["esc"] = "Escape"; + legacyKeyMap["space"] = " "; + })(legacyKeyMap || (legacyKeyMap = {})); - if (!descriptor) { - throw new Error(getErrorMessage('key descriptor', text[descriptorStart], text)); - } + function getNextKeyDef(text, options) { + var _options$keyboardMap$; - const descriptorEnd = descriptorStart + descriptor.length; - const endModifier = startBracket && descriptor !== startBracket && ['/', '>'].includes(text[descriptorEnd]) ? text[descriptorEnd] : ''; - const endBracket = !startBracket || descriptor === startBracket ? '' : startBracket === '{' ? '}' : ']'; + const { + type, + descriptor, + consumedLength, + releasePrevious, + releaseSelf, + repeat + } = readNextDescriptor(text); + const keyDef = (_options$keyboardMap$ = options.keyboardMap.find(def => { + if (type === '[') { + var _def$code; + + return ((_def$code = def.code) == null ? void 0 : _def$code.toLowerCase()) === descriptor.toLowerCase(); + } else if (type === '{') { + var _def$key; + + const key = mapLegacyKey(descriptor); + return ((_def$key = def.key) == null ? void 0 : _def$key.toLowerCase()) === key.toLowerCase(); + } + + return def.key === descriptor; + })) != null ? _options$keyboardMap$ : { + key: 'Unknown', + code: 'Unknown', + [type === '[' ? 'code' : 'key']: descriptor + }; + return { + keyDef, + consumedLength, + releasePrevious, + releaseSelf, + repeat + }; + } - if (endBracket && text[descriptorEnd + endModifier.length] !== endBracket) { - throw new Error(getErrorMessage('closing bracket', text[descriptorEnd + endModifier.length], text)); - } + function readNextDescriptor(text) { + let pos = 0; + const startBracket = text[pos] in bracketDict ? text[pos] : ''; + pos += startBracket.length; // `foo{{bar` is an escaped char at position 3, + // but `foo{{{>5}bar` should be treated as `{` pressed down for 5 keydowns. - const modifiers = { - consumedLength: [startBracket, startModifier, descriptor, endModifier, endBracket].map(c => c.length).reduce((a, b) => a + b), - releasePrevious: startModifier === '/', - releaseSelf: hasReleaseSelf(startBracket, descriptor, endModifier) + const startBracketRepeated = startBracket ? text.match(new RegExp(`^\\${startBracket}+`))[0].length : 0; + const isEscapedChar = startBracketRepeated === 2 || startBracket === '{' && startBracketRepeated > 3; + const type = isEscapedChar ? '' : startBracket; + return { + type, + ...(type === '' ? readPrintableChar(text, pos) : readTag(text, pos, type)) }; + } - if (isPrintableCharacter(startBracket, descriptor)) { - var _options$keyboardMap$; + function readPrintableChar(text, pos) { + const descriptor = text[pos]; + assertDescriptor(descriptor, text, pos); + pos += descriptor.length; + return { + consumedLength: pos, + descriptor, + releasePrevious: false, + releaseSelf: true, + repeat: 1 + }; + } - return { ...modifiers, - keyDef: (_options$keyboardMap$ = options.keyboardMap.find(k => k.key === descriptor)) != null ? _options$keyboardMap$ : { - key: descriptor, - code: 'Unknown' - } - }; - } else if (startBracket === '{') { - var _options$keyboardMap$2; + function readTag(text, pos, startBracket) { + var _text$slice$match, _text$slice$match$, _text$slice$match2; - const key = mapLegacyKey(descriptor); - return { ...modifiers, - keyDef: (_options$keyboardMap$2 = options.keyboardMap.find(k => { - var _k$key; + const releasePreviousModifier = text[pos] === '/' ? '/' : ''; + pos += releasePreviousModifier.length; + const descriptor = (_text$slice$match = text.slice(pos).match(/^\w+/)) == null ? void 0 : _text$slice$match[0]; + assertDescriptor(descriptor, text, pos); + pos += descriptor.length; + const repeatModifier = (_text$slice$match$ = (_text$slice$match2 = text.slice(pos).match(/^>\d+/)) == null ? void 0 : _text$slice$match2[0]) != null ? _text$slice$match$ : ''; + pos += repeatModifier.length; + const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : ''; + pos += releaseSelfModifier.length; + const expectedEndBracket = bracketDict[startBracket]; + const endBracket = text[pos] === expectedEndBracket ? expectedEndBracket : ''; - return ((_k$key = k.key) == null ? void 0 : _k$key.toLowerCase()) === key.toLowerCase(); - })) != null ? _options$keyboardMap$2 : { - key: descriptor, - code: 'Unknown' - } - }; - } else { - var _options$keyboardMap$3; + if (!endBracket) { + throw new Error(getErrorMessage([!repeatModifier && 'repeat modifier', !releaseSelfModifier && 'release modifier', `"${expectedEndBracket}"`].filter(Boolean).join(' or '), text[pos], text)); + } - return { ...modifiers, - keyDef: (_options$keyboardMap$3 = options.keyboardMap.find(k => { - var _k$code; + pos += endBracket.length; + return { + consumedLength: pos, + descriptor, + releasePrevious: !!releasePreviousModifier, + repeat: repeatModifier ? Math.max(Number(repeatModifier.substr(1)), 1) : 1, + releaseSelf: hasReleaseSelf(startBracket, descriptor, releaseSelfModifier, repeatModifier) + }; + } - return ((_k$code = k.code) == null ? void 0 : _k$code.toLowerCase()) === descriptor.toLowerCase(); - })) != null ? _options$keyboardMap$3 : { - key: 'Unknown', - code: descriptor - } - }; + function assertDescriptor(descriptor, text, pos) { + if (!descriptor) { + throw new Error(getErrorMessage('key descriptor', text[pos], text)); } } - function hasReleaseSelf(startBracket, descriptor, endModifier) { - if (endModifier === '/' || !startBracket) { - return true; + function getEnumValue(f, key) { + return f[key]; + } + + function hasReleaseSelf(startBracket, descriptor, releaseSelfModifier, repeatModifier) { + if (releaseSelfModifier) { + return releaseSelfModifier === '/'; } - if (startBracket === '{' && ['alt', 'ctrl', 'meta', 'shift'].includes(descriptor.toLowerCase())) { + if (repeatModifier) { return false; } - return endModifier !== '>'; + if (startBracket === '{' && getEnumValue(legacyModifiers, descriptor.toLowerCase())) { + return false; + } + + return true; } function mapLegacyKey(descriptor) { - var _ctrl$del$esc$space$d; - - return (_ctrl$del$esc$space$d = { - ctrl: 'Control', - del: 'Delete', - esc: 'Escape', - space: ' ' - }[descriptor]) != null ? _ctrl$del$esc$space$d : descriptor; - } + var _getEnumValue; - function isPrintableCharacter(startBracket, descriptor) { - return !startBracket || startBracket === descriptor || startBracket === '{' && descriptor.length === 1; + return (_getEnumValue = getEnumValue(legacyKeyMap, descriptor)) != null ? _getEnumValue : descriptor; } function getErrorMessage(expected, found, text) { return `Expected ${expected} but found "${found != null ? found : ''}" in "${text}" - See https://github.com/testing-library/user-event/blob/master/README.md#keyboardtext-options + See https://github.com/testing-library/user-event/blob/main/README.md#keyboardtext-options for more information about how userEvent parses your input.`; } @@ -22991,8 +22978,8 @@ * https://w3c.github.io/uievents-code/#key-arrowpad-section */ const keydownBehavior = [{ - // TODO: implement for textarea and contentEditable - matches: (keyDef, element) => (keyDef.key === 'ArrowLeft' || keyDef.key === 'ArrowRight') && (0, utils.isElementType)(element, 'input'), + // TODO: implement for contentEditable + matches: (keyDef, element) => (keyDef.key === 'ArrowLeft' || keyDef.key === 'ArrowRight') && (0, utils.isElementType)(element, ['input', 'textarea']), handle: (keyDef, element) => { var _ref; @@ -23059,9 +23046,9 @@ // apply the changes before firing the input event, so that input handlers can access the altered dom and selection if ((0, utils.isContentEditable)(element)) { applyNative(element, 'textContent', newValue); - } - /* istanbul ignore else */ - else if ((0, utils.isElementType)(element, ['input', 'textarea'])) { + } else + /* istanbul ignore else */ + if ((0, utils.isElementType)(element, ['input', 'textarea'])) { applyNative(element, 'value', newValue); } else { // TODO: properly type guard @@ -23098,6 +23085,10 @@ } } } + + const initial = Symbol('initial input value/textContent'); + const onBlur = Symbol('onBlur'); + /** * React tracks the changes on element properties. * This workaround tries to alter the DOM element without React noticing, @@ -23105,17 +23096,42 @@ * * @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104 */ - - function applyNative(element, propName, propValue) { const descriptor = Object.getOwnPropertyDescriptor(element, propName); const nativeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName); if (descriptor && nativeDescriptor) { Object.defineProperty(element, propName, nativeDescriptor); + } // Keep track of the initial value to determine if a change event should be dispatched. + // CONSTRAINT: We can not determine what happened between focus event and our first API call. + + + if (element[initial] === undefined) { + element[initial] = String(element[propName]); } - element[propName] = propValue; + element[propName] = propValue; // Add an event listener for the blur event to the capture phase on the window. + // CONSTRAINT: Currently there is no cross-platform solution to unshift the event handler stack. + // Our change event might occur after other event handlers on the blur event have been processed. + + if (!element[onBlur]) { + var _element$ownerDocumen; + + (_element$ownerDocumen = element.ownerDocument.defaultView) == null ? void 0 : _element$ownerDocumen.addEventListener('blur', element[onBlur] = () => { + const initV = element[initial]; // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + + delete element[onBlur]; // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + + delete element[initial]; + + if (String(element[propName]) !== initV) { + _dom.fireEvent.change(element); + } + }, { + capture: true, + once: true + }); + } if (descriptor) { Object.defineProperty(element, propName, descriptor); @@ -23202,6 +23218,21 @@ (0, utils.setSelectionRange)(element, newPos, newPos); } } + }, { + matches: (keyDef, element) => (keyDef.key === 'PageUp' || keyDef.key === 'PageDown') && (0, utils.isElementType)(element, ['input']), + handle: (keyDef, element) => { + // This could probably been improved by collapsing a selection range + if (keyDef.key === 'PageUp') { + (0, utils.setSelectionRange)(element, 0, 0); + } else { + var _getValue$length2, _getValue2; + + const newPos = (_getValue$length2 = (_getValue2 = (0, utils.getValue)(element)) == null ? void 0 : _getValue2.length) != null ? _getValue$length2 : + /* istanbul ignore next */ + 0; + (0, utils.setSelectionRange)(element, newPos, newPos); + } + } }, { matches: (keyDef, element) => keyDef.key === 'Delete' && (0, utils.isEditable)(element) && !(0, utils.isCursorAtEnd)(element), handle: (keDef, element, options, state) => { @@ -23458,7 +23489,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); - exports.postKeyupBehavior = exports.keyupBehavior = exports.preKeyupBehavior = exports.keypressBehavior = exports.keydownBehavior = exports.preKeydownBehavior = void 0; + exports.preKeyupBehavior = exports.preKeydownBehavior = exports.postKeyupBehavior = exports.keyupBehavior = exports.keypressBehavior = exports.keydownBehavior = void 0; @@ -23526,6 +23557,15 @@ }]; exports.keydownBehavior = keydownBehavior; const keypressBehavior = [{ + matches: (keyDef, element) => keyDef.key === 'Enter' && (0, utils.isElementType)(element, 'input') && ['checkbox', 'radio'].includes(element.type), + handle: (keyDef, element) => { + const form = element.form; + + if ((0, utils.hasFormSubmit)(form)) { + _dom.fireEvent.submit(form); + } + } + }, { matches: (keyDef, element) => keyDef.key === 'Enter' && ((0, utils.isClickableInput)(element) || // Links with href defined should handle Enter the same as a click (0, utils.isElementType)(element, 'a') && Boolean(element.href)), handle: (keyDef, element, options, state) => { @@ -23536,7 +23576,7 @@ handle: (keyDef, element) => { const form = element.form; - if (form && (form.querySelectorAll('input').length === 1 || form.querySelector('input[type="submit"]') || form.querySelector('button[type="submit"]'))) { + if (form && (form.querySelectorAll('input').length === 1 || (0, utils.hasFormSubmit)(form))) { _dom.fireEvent.submit(form); } } @@ -23582,7 +23622,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); - exports.postKeyupBehavior = exports.keyupBehavior = exports.preKeyupBehavior = exports.keypressBehavior = exports.keydownBehavior = exports.preKeydownBehavior = exports.replaceBehavior = void 0; + exports.replaceBehavior = exports.preKeyupBehavior = exports.preKeydownBehavior = exports.postKeyupBehavior = exports.keyupBehavior = exports.keypressBehavior = exports.keydownBehavior = void 0; @@ -23639,6 +23679,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } async function keyboardImplementation(text, options, state) { + var _state$repeatKey; + const { document } = options; @@ -23649,14 +23691,16 @@ keyDef, consumedLength, releasePrevious, - releaseSelf - } = (0, getNextKeyDef_1.getNextKeyDef)(text, options); + releaseSelf, + repeat + } = (_state$repeatKey = state.repeatKey) != null ? _state$repeatKey : (0, getNextKeyDef_1.getNextKeyDef)(text, options); const replace = applyPlugins(plugins.replaceBehavior, keyDef, getCurrentElement(), options, state); if (!replace) { - const pressed = state.pressed.find(p => p.keyDef === keyDef); + const pressed = state.pressed.find(p => p.keyDef === keyDef); // Release the key automatically if it was pressed before. + // Do not release the key on iterations on `state.repeatKey`. - if (pressed) { + if (pressed && !state.repeatKey) { keyup(keyDef, getCurrentElement, options, state, pressed.unpreventedDefault); } @@ -23665,15 +23709,29 @@ if (unpreventedDefault && hasKeyPress(keyDef, state)) { keypress(keyDef, getCurrentElement, options, state); - } + } // Release the key only on the last iteration on `state.repeatKey`. + - if (releaseSelf) { + if (releaseSelf && repeat <= 1) { keyup(keyDef, getCurrentElement, options, state, unpreventedDefault); } } } - if (text.length > consumedLength) { + if (repeat > 1) { + state.repeatKey = { + // don't consume again on the next iteration + consumedLength: 0, + keyDef, + releasePrevious, + releaseSelf, + repeat: repeat - 1 + }; + } else { + delete state.repeatKey; + } + + if (text.length > consumedLength || repeat > 1) { if (options.delay > 0) { await (0, utils.wait)(options.delay); } @@ -23873,10 +23931,6 @@ key: 'OS', location: types.DOM_KEY_LOCATION.RIGHT, keyCode: 91 - }, { - code: 'Escape', - key: 'CapsLock', - keyCode: 20 }, { code: 'CapsLock', key: 'CapsLock', @@ -23924,6 +23978,14 @@ code: 'Delete', key: 'Delete', keyCode: 46 + }, { + code: 'PageUp', + key: 'PageUp', + keyCode: 33 + }, { + code: 'PageDown', + key: 'PageDown', + keyCode: 34 } // TODO: add mappings ]; exports.defaultKeyMap = defaultKeyMap; @@ -23935,6 +23997,12 @@ value: true }); exports.specialCharMap = void 0; + + /** + * @deprecated This list of strings with special meaning is no longer necessary + * as we've introduced a standardized way to describe any keystroke for `userEvent`. + * @see https://testing-library.com/docs/ecosystem-user-event#keyboardtext-options + */ const specialCharMap = { arrowLeft: '{arrowleft}', arrowRight: '{arrowright}', @@ -23948,7 +24016,9 @@ end: '{end}', selectAll: '{selectall}', space: '{space}', - whitespace: ' ' + whitespace: ' ', + pageUp: '{pageUp}', + pageDown: '{pageDown}' }; exports.specialCharMap = specialCharMap; }); @@ -24049,14 +24119,14 @@ if (element.disabled) return; if (!skipClick) (0, click_1.click)(element); // The focused element could change between each event, so get the currently active element each time - const currentElement = () => (0, utils.getActiveElement)(element.ownerDocument); // by default, a new element has it's selection start and end at 0 + const currentElement = () => (0, utils.getActiveElement)(element.ownerDocument); // by default, a new element has its selection start and end at 0 // but most of the time when people call "type", they expect it to type // at the end of the current input value. So, if the selection start // and end are both the default of 0, then we'll go ahead and change // them to the length of the current value. // the only time it would make sense to pass the initialSelectionStart or // initialSelectionEnd is if you have an input with a value and want to - // explicitely start typing with the cursor at 0. Not super common. + // explicitly start typing with the cursor at 0. Not super common. const value = (0, utils.getValue)(currentElement()); @@ -24419,7 +24489,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); - exports.deselectOptions = exports.selectOptions = void 0; + exports.selectOptions = exports.deselectOptions = void 0; @@ -24431,7 +24501,9 @@ - function selectOptionsBase(newValue, select, values, init) { + function selectOptionsBase(newValue, select, values, init, { + skipPointerEventsCheck = false + } = {}) { if (!newValue && !select.multiple) { throw (0, _dom.getConfig)().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select); } @@ -24456,7 +24528,7 @@ if ((0, utils.isElementType)(select, 'select')) { if (select.multiple) { for (const option of selectedOptions) { - const withPointerEvents = (0, utils.hasPointerEvents)(option); // events fired for multiple select are weird. Can't use hover... + const withPointerEvents = skipPointerEventsCheck ? true : (0, utils.hasPointerEvents)(option); // events fired for multiple select are weird. Can't use hover... if (withPointerEvents) { _dom.fireEvent.pointerOver(option, init); @@ -24491,10 +24563,12 @@ } } } else if (selectedOptions.length === 1) { - const withPointerEvents = (0, utils.hasPointerEvents)(select); // the click to open the select options + const withPointerEvents = skipPointerEventsCheck ? true : (0, utils.hasPointerEvents)(select); // the click to open the select options if (withPointerEvents) { - (0, click_1.click)(select, init); + (0, click_1.click)(select, init, { + skipPointerEventsCheck + }); } else { (0, focus_1.focus)(select); } @@ -24523,9 +24597,15 @@ } } else if (select.getAttribute('role') === 'listbox') { selectedOptions.forEach(option => { - (0, hover_1.hover)(option, init); - (0, click_1.click)(option, init); - (0, hover_1.unhover)(option, init); + (0, hover_1.hover)(option, init, { + skipPointerEventsCheck + }); + (0, click_1.click)(option, init, { + skipPointerEventsCheck + }); + (0, hover_1.unhover)(option, init, { + skipPointerEventsCheck + }); }); } else { throw (0, _dom.getConfig)().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select); @@ -24622,13 +24702,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = void 0; Object.defineProperty(exports, "specialChars", { enumerable: true, get: function () { return keyboard_1.specialCharMap; } }); - exports.default = void 0; @@ -25322,6 +25402,8 @@ exports.eventAliasMap = eventAliasMap; }); + // Copyright 2021 Workiva Inc. + configure({ testIdAttribute: 'data-test-id', getElementError: buildJsGetElementError diff --git a/lib/src/user_event/user_event.dart b/lib/src/user_event/user_event.dart index 314aa123..dfe86499 100644 --- a/lib/src/user_event/user_event.dart +++ b/lib/src/user_event/user_event.dart @@ -63,6 +63,15 @@ abstract class UserEvent { /// [UIEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail) /// for more information. /// + /// ### [skipPointerEventsCheck] + /// + /// Attempting to interact with an element that has `'pointer-events: none'` + /// set will throw an error. Use [skipPointerEventsCheck] to prevent that error + /// from being thrown by skipping the check of whether any element in the + /// DOM-tree has `'pointer-events: none'` set. In addition, the underlying + /// check for pointer events is costly in general and very costly when rendering + /// large DOM-trees. Can be used to speed up tests. + /// /// ## Example /// /// ```html @@ -107,8 +116,13 @@ abstract class UserEvent { Map eventInit, bool skipHover = false, int clickCount = 0, + bool skipPointerEventsCheck = false, }) { - final options = {'skipHover': skipHover, 'clickCount': clickCount}; + final options = { + 'skipHover': skipHover, + 'clickCount': clickCount, + 'skipPointerEventsCheck': skipPointerEventsCheck, + }; eventHandlerErrorCatcher(() { getProperty(_userEvent, 'click')( element, @@ -133,6 +147,15 @@ abstract class UserEvent { /// UserEvent.dblClick(element, eventInit: {'shiftKey': true}); /// ``` /// + /// ### [skipPointerEventsCheck] + /// + /// Attempting to interact with an element that has `'pointer-events: none'` + /// set will throw an error. Use [skipPointerEventsCheck] to prevent that error + /// from being thrown by skipping the check of whether any element in the + /// DOM-tree has `'pointer-events: none'` set. In addition, the underlying + /// check for pointer events is costly in general and very costly when rendering + /// large DOM-trees. Can be used to speed up tests. + /// /// ## Example /// /// ```jsx @@ -179,11 +202,16 @@ abstract class UserEvent { /// {@macro RenderSupportsReactAndOverReactCallout} /// /// {@category UserActions} - static void dblClick(Element element, {Map eventInit}) { + static void dblClick(Element element, {Map eventInit, bool skipPointerEventsCheck = false}) { + final options = { + 'skipPointerEventsCheck': skipPointerEventsCheck, + }; + eventHandlerErrorCatcher(() { getProperty(_userEvent, 'dblClick')( element, _jsifyEventData(eventInit), + jsifyAndAllowInterop(options), ); }); } @@ -815,6 +843,15 @@ abstract class UserEvent { /// /// Use [clickInit] to initialize the click events that occur as a part of the selection. /// + /// ### [skipPointerEventsCheck] + /// + /// Attempting to interact with an element that has `'pointer-events: none'` + /// set will throw an error. Use [skipPointerEventsCheck] to prevent that error + /// from being thrown by skipping the check of whether any element in the + /// DOM-tree has `'pointer-events: none'` set. In addition, the underlying + /// check for pointer events is costly in general and very costly when rendering + /// large DOM-trees. Can be used to speed up tests. + /// /// ## Example /// /// ```html @@ -877,12 +914,18 @@ abstract class UserEvent { SelectElement selectElement, List values, { Map clickInit, + bool skipPointerEventsCheck = false, }) { + final options = { + 'skipPointerEventsCheck': skipPointerEventsCheck, + }; + eventHandlerErrorCatcher(() { getProperty(_userEvent, 'selectOptions')( selectElement, values, _jsifyEventData(clickInit), + jsifyAndAllowInterop(options), ); }); } @@ -903,6 +946,15 @@ abstract class UserEvent { /// /// Use [clickInit] to initialize the click events that occur as a part of the selection. /// + /// ### [skipPointerEventsCheck] + /// + /// Attempting to interact with an element that has `'pointer-events: none'` + /// set will throw an error. Use [skipPointerEventsCheck] to prevent that error + /// from being thrown by skipping the check of whether any element in the + /// DOM-tree has `'pointer-events: none'` set. In addition, the underlying + /// check for pointer events is costly in general and very costly when rendering + /// large DOM-trees. Can be used to speed up tests. + /// /// ## Example: /// /// ```html @@ -965,12 +1017,18 @@ abstract class UserEvent { SelectElement selectElement, List values, { Map clickInit, + bool skipPointerEventsCheck = false, }) { + final options = { + 'skipPointerEventsCheck': skipPointerEventsCheck, + }; + eventHandlerErrorCatcher(() { getProperty(_userEvent, 'deselectOptions')( selectElement, values, _jsifyEventData(clickInit), + jsifyAndAllowInterop(options), ); }); } @@ -1087,6 +1145,15 @@ abstract class UserEvent { /// /// Use [eventInit] to initialize the `onMouseOver` event. /// + /// ### [skipPointerEventsCheck] + /// + /// Attempting to interact with an element that has `'pointer-events: none'` + /// set will throw an error. Use [skipPointerEventsCheck] to prevent that error + /// from being thrown by skipping the check of whether any element in the + /// DOM-tree has `'pointer-events: none'` set. In addition, the underlying + /// check for pointer events is costly in general and very costly when rendering + /// large DOM-trees. Can be used to speed up tests. + /// /// ## Example /// /// ```html @@ -1143,9 +1210,21 @@ abstract class UserEvent { /// {@macro RenderSupportsReactAndOverReactCallout} /// /// {@category UserActions} - static void hover(Element element, {Map eventInit}) { + static void hover( + Element element, { + Map eventInit, + bool skipPointerEventsCheck = false, + }) { + final options = { + 'skipPointerEventsCheck': skipPointerEventsCheck, + }; + eventHandlerErrorCatcher(() { - getProperty(_userEvent, 'hover')(element, _jsifyEventData(eventInit)); + getProperty(_userEvent, 'hover')( + element, + _jsifyEventData(eventInit), + jsifyAndAllowInterop(options), + ); }); } @@ -1161,6 +1240,15 @@ abstract class UserEvent { /// /// Use [eventInit] to initialize the `onMouseOut` event. /// + /// ### [skipPointerEventsCheck] + /// + /// Attempting to interact with an element that has `'pointer-events: none'` + /// set will throw an error. Use [skipPointerEventsCheck] to prevent that error + /// from being thrown by skipping the check of whether any element in the + /// DOM-tree has `'pointer-events: none'` set. In addition, the underlying + /// check for pointer events is costly in general and very costly when rendering + /// large DOM-trees. Can be used to speed up tests. + /// /// ## Example /// /// ```html @@ -1223,9 +1311,17 @@ abstract class UserEvent { /// {@macro RenderSupportsReactAndOverReactCallout} /// /// {@category UserActions} - static void unhover(Element element, {Map eventInit}) { + static void unhover(Element element, {Map eventInit, bool skipPointerEventsCheck = false}) { + final options = { + 'skipPointerEventsCheck': skipPointerEventsCheck, + }; + eventHandlerErrorCatcher(() { - getProperty(_userEvent, 'unhover')(element, _jsifyEventData(eventInit)); + getProperty(_userEvent, 'unhover')( + element, + _jsifyEventData(eventInit), + jsifyAndAllowInterop(options), + ); }); } diff --git a/test/unit/user_event/click_test.dart b/test/unit/user_event/click_test.dart index 26cd7eb7..1ec1ec9f 100644 --- a/test/unit/user_event/click_test.dart +++ b/test/unit/user_event/click_test.dart @@ -97,6 +97,24 @@ void main() { _verifyClickEvent(clickCount: clickCount); }); + test('skipPointerEventsCheck', () { + var wasClicked = false; + + view.rerender(react.button({ + 'style': {'pointerEvents': 'none'}, + 'onClick': (_) { + wasClicked = true; + } + }, 'oh hai') as ReactElement); + + UserEvent.click( + view.getByRole('button'), + skipPointerEventsCheck: true, + ); + + expect(wasClicked, isTrue); + }); + testEventHandlerErrors( ['onClick'], UserEvent.click, @@ -137,6 +155,25 @@ void main() { _verifyDblClickEvent(hasEventInit: true); }); + test('skipPointerEventsCheck', () { + var wasClicked = false; + + view.rerender(react.button({ + 'data-test-id': 'the-local-button', + 'style': {'pointerEvents': 'none'}, + 'onDoubleClick': (_) { + wasClicked = true; + } + }, 'oh hai') as ReactElement); + + UserEvent.dblClick( + view.getByRole('button'), + skipPointerEventsCheck: true, + ); + + expect(wasClicked, isTrue); + }); + testEventHandlerErrors( ['onDoubleClick'], UserEvent.dblClick, diff --git a/test/unit/user_event/hover_test.dart b/test/unit/user_event/hover_test.dart index 3add73dd..b7816ebc 100644 --- a/test/unit/user_event/hover_test.dart +++ b/test/unit/user_event/hover_test.dart @@ -18,7 +18,7 @@ import 'dart:html'; import 'package:react/hooks.dart' show useState; import 'package:react/react.dart' as react; -import 'package:react/react_client.dart' show ReactElement; +import 'package:react/react_client.dart' show ReactDartFunctionComponentFactoryProxy, ReactElement; import 'package:react_testing_library/matchers.dart'; import 'package:react_testing_library/react_testing_library.dart' as rtl; import 'package:react_testing_library/user_event.dart'; @@ -33,27 +33,9 @@ void main() { setUp(() { calls = []; - - final HoverTestComponent = react.registerFunctionComponent((props) { - final isShown = useState(false); - return react.div({}, [ - react.button({ - 'onMouseOver': (e) { - isShown.set(true); - calls.add((e as react.SyntheticMouseEvent).nativeEvent as MouseEvent); - }, - 'onMouseOut': (e) { - isShown.set(false); - calls.add((e as react.SyntheticMouseEvent).nativeEvent as MouseEvent); - } - }, [ - 'Hover over me!' - ]), - if (isShown.value) react.span({}, ['Hello!']) else null, - ]); - }); - - view = rtl.render(react.div({}, [HoverTestComponent({})]) as ReactElement); + view = rtl.render(react.div({}, [ + HoverTestComponent({'calls': calls}) + ]) as ReactElement); // Sanity check. expect(view.queryByText('Hello!'), isNull); }); @@ -92,6 +74,20 @@ void main() { _verifyHoverEvent(hasEventInit: true); }); + test('skipPointerEventsCheck', () { + view.rerender(react.div({ + 'style': {'pointerEvents': 'none'} + }, [ + HoverTestComponent({'calls': calls}) + ]) as ReactElement); + + UserEvent.hover(view.getByRole('button'), skipPointerEventsCheck: true); + expect(view.getByText('Hello!'), isInTheDocument); + + UserEvent.unhover(view.getByRole('button'), skipPointerEventsCheck: true); + expect(view.queryByText('Hello!'), isNull); + }); + testEventHandlerErrors( ['onMouseOver', 'onMouseOut'], UserEvent.hover, @@ -100,3 +96,22 @@ void main() { ); }); } + +ReactDartFunctionComponentFactoryProxy HoverTestComponent = react.registerFunctionComponent((props) { + final isShown = useState(false); + return react.div({}, [ + react.button({ + 'onMouseOver': (e) { + isShown.set(true); + props['calls'].add((e as react.SyntheticMouseEvent).nativeEvent as MouseEvent); + }, + 'onMouseOut': (e) { + isShown.set(false); + props['calls'].add((e as react.SyntheticMouseEvent).nativeEvent as MouseEvent); + } + }, [ + 'Hover over me!' + ]), + if (isShown.value) react.span({}, ['Hello!']) else null, + ]); +}); diff --git a/test/unit/user_event/select_options_test.dart b/test/unit/user_event/select_options_test.dart index 305a515d..2131adea 100644 --- a/test/unit/user_event/select_options_test.dart +++ b/test/unit/user_event/select_options_test.dart @@ -94,6 +94,26 @@ void main() { ); _verifySelectEvent(hasClickInit: true); }); + + test('skipPointerEventsCheck', () { + var wasClicked = false; + view.rerender(react.select({ + 'style': {'pointer-events': 'none'}, + 'id': 'root', + 'onClick': (event) { + wasClicked = true; + }, + 'multiple': isMultiSelect, + }, [ + react.option({'value': '1'}, 'A'), + react.option({'value': '2'}, 'B'), + react.option({'value': '3'}, 'C'), + ]) as ReactElement); + + UserEvent.selectOptions(select, isMultiSelect ? ['1', '3'] : ['3'], skipPointerEventsCheck: true); + + expect(wasClicked, isTrue); + }); } group('single select', _selectOptionsTestHelper); @@ -179,6 +199,31 @@ void main() { _verifyDeselectEvent(hasClickInit: true); }); + test('skipPointerEventsCheck', () { + var wasClicked = false; + view.rerender(react.select({ + 'style': {'pointer-events': 'none'}, + 'id': 'root', + 'onClick': (event) { + wasClicked = true; + }, + 'multiple': true, + 'defaultValue': ['1', '2', '3'], + }, [ + react.option({'value': '1'}, 'A'), + react.option({'value': '2'}, 'B'), + react.option({'value': '3'}, 'C'), + ]) as ReactElement); + + UserEvent.deselectOptions( + select, + [view.getByText('A'), view.getByText('C')], + skipPointerEventsCheck: true, + ); + + expect(wasClicked, isTrue); + }); + testEventHandlerErrors( ['onChange'], (el) => UserEvent.deselectOptions(el as SelectElement, ['3']),