mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 05:32:18 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
3183
web/node_modules/@testing-library/dom/dist/@testing-library/dom.cjs.js
generated
vendored
Normal file
3183
web/node_modules/@testing-library/dom/dist/@testing-library/dom.cjs.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
3075
web/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js
generated
vendored
Normal file
3075
web/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
17488
web/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.js
generated
vendored
Normal file
17488
web/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
web/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.js.map
generated
vendored
Normal file
1
web/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
web/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.min.js
generated
vendored
Normal file
2
web/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
web/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.min.js.map
generated
vendored
Normal file
1
web/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
142
web/node_modules/@testing-library/dom/dist/DOMElementFilter.js
generated
vendored
Normal file
142
web/node_modules/@testing-library/dom/dist/DOMElementFilter.js
generated
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = createDOMElementFilter;
|
||||
exports.test = void 0;
|
||||
|
||||
/**
|
||||
* Source: https://github.com/facebook/jest/blob/e7bb6a1e26ffab90611b2593912df15b69315611/packages/pretty-format/src/plugins/DOMElement.ts
|
||||
*/
|
||||
|
||||
/* eslint-disable -- trying to stay as close to the original as possible */
|
||||
|
||||
/* istanbul ignore file */
|
||||
function escapeHTML(str) {
|
||||
return str.replace(/</g, '<').replace(/>/g, '>');
|
||||
} // Return empty string if keys is empty.
|
||||
|
||||
|
||||
const printProps = (keys, props, config, indentation, depth, refs, printer) => {
|
||||
const indentationNext = indentation + config.indent;
|
||||
const colors = config.colors;
|
||||
return keys.map(key => {
|
||||
const value = props[key];
|
||||
let printed = printer(value, config, indentationNext, depth, refs);
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (printed.indexOf('\n') !== -1) {
|
||||
printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
|
||||
}
|
||||
|
||||
printed = '{' + printed + '}';
|
||||
}
|
||||
|
||||
return config.spacingInner + indentation + colors.prop.open + key + colors.prop.close + '=' + colors.value.open + printed + colors.value.close;
|
||||
}).join('');
|
||||
}; // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#node_type_constants
|
||||
|
||||
|
||||
const NodeTypeTextNode = 3; // Return empty string if children is empty.
|
||||
|
||||
const printChildren = (children, config, indentation, depth, refs, printer) => children.map(child => {
|
||||
const printedChild = typeof child === 'string' ? printText(child, config) : printer(child, config, indentation, depth, refs);
|
||||
|
||||
if (printedChild === '' && typeof child === 'object' && child !== null && child.nodeType !== NodeTypeTextNode) {
|
||||
// A plugin serialized this Node to '' meaning we should ignore it.
|
||||
return '';
|
||||
}
|
||||
|
||||
return config.spacingOuter + indentation + printedChild;
|
||||
}).join('');
|
||||
|
||||
const printText = (text, config) => {
|
||||
const contentColor = config.colors.content;
|
||||
return contentColor.open + escapeHTML(text) + contentColor.close;
|
||||
};
|
||||
|
||||
const printComment = (comment, config) => {
|
||||
const commentColor = config.colors.comment;
|
||||
return commentColor.open + '<!--' + escapeHTML(comment) + '-->' + commentColor.close;
|
||||
}; // Separate the functions to format props, children, and element,
|
||||
// so a plugin could override a particular function, if needed.
|
||||
// Too bad, so sad: the traditional (but unnecessary) space
|
||||
// in a self-closing tagColor requires a second test of printedProps.
|
||||
|
||||
|
||||
const printElement = (type, printedProps, printedChildren, config, indentation) => {
|
||||
const tagColor = config.colors.tag;
|
||||
return tagColor.open + '<' + type + (printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open) + (printedChildren ? '>' + tagColor.close + printedChildren + config.spacingOuter + indentation + tagColor.open + '</' + type : (printedProps && !config.min ? '' : ' ') + '/') + '>' + tagColor.close;
|
||||
};
|
||||
|
||||
const printElementAsLeaf = (type, config) => {
|
||||
const tagColor = config.colors.tag;
|
||||
return tagColor.open + '<' + type + tagColor.close + ' …' + tagColor.open + ' />' + tagColor.close;
|
||||
};
|
||||
|
||||
const ELEMENT_NODE = 1;
|
||||
const TEXT_NODE = 3;
|
||||
const COMMENT_NODE = 8;
|
||||
const FRAGMENT_NODE = 11;
|
||||
const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
|
||||
|
||||
const testNode = val => {
|
||||
const constructorName = val.constructor.name;
|
||||
const {
|
||||
nodeType,
|
||||
tagName
|
||||
} = val;
|
||||
const isCustomElement = typeof tagName === 'string' && tagName.includes('-') || typeof val.hasAttribute === 'function' && val.hasAttribute('is');
|
||||
return nodeType === ELEMENT_NODE && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE && constructorName === 'Text' || nodeType === COMMENT_NODE && constructorName === 'Comment' || nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment';
|
||||
};
|
||||
|
||||
const test = val => {
|
||||
var _val$constructor;
|
||||
|
||||
return (val == null ? void 0 : (_val$constructor = val.constructor) == null ? void 0 : _val$constructor.name) && testNode(val);
|
||||
};
|
||||
|
||||
exports.test = test;
|
||||
|
||||
function nodeIsText(node) {
|
||||
return node.nodeType === TEXT_NODE;
|
||||
}
|
||||
|
||||
function nodeIsComment(node) {
|
||||
return node.nodeType === COMMENT_NODE;
|
||||
}
|
||||
|
||||
function nodeIsFragment(node) {
|
||||
return node.nodeType === FRAGMENT_NODE;
|
||||
}
|
||||
|
||||
function createDOMElementFilter(filterNode) {
|
||||
return {
|
||||
test: val => {
|
||||
var _val$constructor2;
|
||||
|
||||
return (val == null ? void 0 : (_val$constructor2 = val.constructor) == null ? void 0 : _val$constructor2.name) && testNode(val);
|
||||
},
|
||||
serialize: (node, config, indentation, depth, refs, printer) => {
|
||||
if (nodeIsText(node)) {
|
||||
return printText(node.data, config);
|
||||
}
|
||||
|
||||
if (nodeIsComment(node)) {
|
||||
return printComment(node.data, config);
|
||||
}
|
||||
|
||||
const type = nodeIsFragment(node) ? `DocumentFragment` : node.tagName.toLowerCase();
|
||||
|
||||
if (++depth > config.maxDepth) {
|
||||
return printElementAsLeaf(type, config);
|
||||
}
|
||||
|
||||
return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes).map(attr => attr.name).sort(), nodeIsFragment(node) ? {} : Array.from(node.attributes).reduce((props, attribute) => {
|
||||
props[attribute.name] = attribute.value;
|
||||
return props;
|
||||
}, {}), config, indentation + config.indent, depth, refs, printer), printChildren(Array.prototype.slice.call(node.childNodes || node.children).filter(filterNode), config, indentation + config.indent, depth, refs, printer), config, indentation);
|
||||
}
|
||||
};
|
||||
}
|
70
web/node_modules/@testing-library/dom/dist/config.js
generated
vendored
Normal file
70
web/node_modules/@testing-library/dom/dist/config.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.runWithExpensiveErrorDiagnosticsDisabled = runWithExpensiveErrorDiagnosticsDisabled;
|
||||
exports.configure = configure;
|
||||
exports.getConfig = getConfig;
|
||||
|
||||
var _prettyDom = require("./pretty-dom");
|
||||
|
||||
// It would be cleaner for this to live inside './queries', but
|
||||
// other parts of the code assume that all exports from
|
||||
// './queries' are query functions.
|
||||
let config = {
|
||||
testIdAttribute: 'data-testid',
|
||||
asyncUtilTimeout: 1000,
|
||||
// this is to support React's async `act` function.
|
||||
// forcing react-testing-library to wrap all async functions would've been
|
||||
// a total nightmare (consider wrapping every findBy* query and then also
|
||||
// updating `within` so those would be wrapped too. Total nightmare).
|
||||
// so we have this config option that's really only intended for
|
||||
// react-testing-library to use. For that reason, this feature will remain
|
||||
// undocumented.
|
||||
asyncWrapper: cb => cb(),
|
||||
eventWrapper: cb => cb(),
|
||||
// default value for the `hidden` option in `ByRole` queries
|
||||
defaultHidden: false,
|
||||
// showOriginalStackTrace flag to show the full error stack traces for async errors
|
||||
showOriginalStackTrace: false,
|
||||
// throw errors w/ suggestions for better queries. Opt in so off by default.
|
||||
throwSuggestions: false,
|
||||
|
||||
// called when getBy* queries fail. (message, container) => Error
|
||||
getElementError(message, container) {
|
||||
const prettifiedDOM = (0, _prettyDom.prettyDOM)(container);
|
||||
const error = new Error([message, prettifiedDOM.length > 0 ? `Ignored nodes: comments, <script />, <style />\n${(0, _prettyDom.prettyDOM)(container)}` : null].filter(Boolean).join('\n\n'));
|
||||
error.name = 'TestingLibraryElementError';
|
||||
return error;
|
||||
},
|
||||
|
||||
_disableExpensiveErrorDiagnostics: false,
|
||||
computedStyleSupportsPseudoElements: false
|
||||
};
|
||||
|
||||
function runWithExpensiveErrorDiagnosticsDisabled(callback) {
|
||||
try {
|
||||
config._disableExpensiveErrorDiagnostics = true;
|
||||
return callback();
|
||||
} finally {
|
||||
config._disableExpensiveErrorDiagnostics = false;
|
||||
}
|
||||
}
|
||||
|
||||
function configure(newConfig) {
|
||||
if (typeof newConfig === 'function') {
|
||||
// Pass the existing config out to the provided function
|
||||
// and accept a delta in return
|
||||
newConfig = newConfig(config);
|
||||
} // Merge the incoming config delta
|
||||
|
||||
|
||||
config = { ...config,
|
||||
...newConfig
|
||||
};
|
||||
}
|
||||
|
||||
function getConfig() {
|
||||
return config;
|
||||
}
|
659
web/node_modules/@testing-library/dom/dist/event-map.js
generated
vendored
Normal file
659
web/node_modules/@testing-library/dom/dist/event-map.js
generated
vendored
Normal file
|
@ -0,0 +1,659 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.eventAliasMap = exports.eventMap = void 0;
|
||||
const eventMap = {
|
||||
// Clipboard Events
|
||||
copy: {
|
||||
EventType: 'ClipboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
cut: {
|
||||
EventType: 'ClipboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
paste: {
|
||||
EventType: 'ClipboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
// Composition Events
|
||||
compositionEnd: {
|
||||
EventType: 'CompositionEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
compositionStart: {
|
||||
EventType: 'CompositionEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
compositionUpdate: {
|
||||
EventType: 'CompositionEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
// Keyboard Events
|
||||
keyDown: {
|
||||
EventType: 'KeyboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
charCode: 0,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
keyPress: {
|
||||
EventType: 'KeyboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
charCode: 0,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
keyUp: {
|
||||
EventType: 'KeyboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
charCode: 0,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
// Focus Events
|
||||
focus: {
|
||||
EventType: 'FocusEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
blur: {
|
||||
EventType: 'FocusEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
focusIn: {
|
||||
EventType: 'FocusEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
focusOut: {
|
||||
EventType: 'FocusEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
// Form Events
|
||||
change: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
input: {
|
||||
EventType: 'InputEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
invalid: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: true
|
||||
}
|
||||
},
|
||||
submit: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
}
|
||||
},
|
||||
reset: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
}
|
||||
},
|
||||
// Mouse Events
|
||||
click: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
button: 0,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
contextMenu: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
dblClick: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
drag: {
|
||||
EventType: 'DragEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
dragEnd: {
|
||||
EventType: 'DragEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
dragEnter: {
|
||||
EventType: 'DragEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
dragExit: {
|
||||
EventType: 'DragEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
dragLeave: {
|
||||
EventType: 'DragEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
dragOver: {
|
||||
EventType: 'DragEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
dragStart: {
|
||||
EventType: 'DragEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
drop: {
|
||||
EventType: 'DragEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseDown: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseEnter: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseLeave: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseMove: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseOut: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseOver: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseUp: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
// Selection Events
|
||||
select: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
// Touch Events
|
||||
touchCancel: {
|
||||
EventType: 'TouchEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
touchEnd: {
|
||||
EventType: 'TouchEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
touchMove: {
|
||||
EventType: 'TouchEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
touchStart: {
|
||||
EventType: 'TouchEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
// UI Events
|
||||
resize: {
|
||||
EventType: 'UIEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
scroll: {
|
||||
EventType: 'UIEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
// Wheel Events
|
||||
wheel: {
|
||||
EventType: 'WheelEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
// Media Events
|
||||
abort: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
canPlay: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
canPlayThrough: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
durationChange: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
emptied: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
encrypted: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
ended: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
loadedData: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
loadedMetadata: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
loadStart: {
|
||||
EventType: 'ProgressEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
pause: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
play: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
playing: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
progress: {
|
||||
EventType: 'ProgressEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
rateChange: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
seeked: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
seeking: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
stalled: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
suspend: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
timeUpdate: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
volumeChange: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
waiting: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
// Image Events
|
||||
load: {
|
||||
EventType: 'UIEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
error: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
// Animation Events
|
||||
animationStart: {
|
||||
EventType: 'AnimationEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
animationEnd: {
|
||||
EventType: 'AnimationEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
animationIteration: {
|
||||
EventType: 'AnimationEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
// Transition Events
|
||||
transitionEnd: {
|
||||
EventType: 'TransitionEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
}
|
||||
},
|
||||
// pointer events
|
||||
pointerOver: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerEnter: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
pointerDown: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerMove: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerUp: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerCancel: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerOut: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerLeave: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
gotPointerCapture: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
lostPointerCapture: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
// history events
|
||||
popState: {
|
||||
EventType: 'PopStateEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.eventMap = eventMap;
|
||||
const eventAliasMap = {
|
||||
doubleClick: 'dblClick'
|
||||
};
|
||||
exports.eventAliasMap = eventAliasMap;
|
154
web/node_modules/@testing-library/dom/dist/events.js
generated
vendored
Normal file
154
web/node_modules/@testing-library/dom/dist/events.js
generated
vendored
Normal file
|
@ -0,0 +1,154 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.fireEvent = fireEvent;
|
||||
exports.createEvent = createEvent;
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
var _eventMap = require("./event-map");
|
||||
|
||||
function fireEvent(element, event) {
|
||||
return (0, _config.getConfig)().eventWrapper(() => {
|
||||
if (!event) {
|
||||
throw new Error(`Unable to fire an event - please provide an event object.`);
|
||||
}
|
||||
|
||||
if (!element) {
|
||||
throw new Error(`Unable to fire a "${event.type}" event - please provide a DOM element.`);
|
||||
}
|
||||
|
||||
return element.dispatchEvent(event);
|
||||
});
|
||||
}
|
||||
|
||||
function createEvent(eventName, node, init, {
|
||||
EventType = 'Event',
|
||||
defaultInit = {}
|
||||
} = {}) {
|
||||
if (!node) {
|
||||
throw new Error(`Unable to fire a "${eventName}" event - please provide a DOM element.`);
|
||||
}
|
||||
|
||||
const eventInit = { ...defaultInit,
|
||||
...init
|
||||
};
|
||||
const {
|
||||
target: {
|
||||
value,
|
||||
files,
|
||||
...targetProperties
|
||||
} = {}
|
||||
} = eventInit;
|
||||
|
||||
if (value !== undefined) {
|
||||
setNativeValue(node, value);
|
||||
}
|
||||
|
||||
if (files !== undefined) {
|
||||
// input.files is a read-only property so this is not allowed:
|
||||
// input.files = [file]
|
||||
// so we have to use this workaround to set the property
|
||||
Object.defineProperty(node, 'files', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
value: files
|
||||
});
|
||||
}
|
||||
|
||||
Object.assign(node, targetProperties);
|
||||
const window = (0, _helpers.getWindowFromNode)(node);
|
||||
const EventConstructor = window[EventType] || window.Event;
|
||||
let event;
|
||||
/* istanbul ignore else */
|
||||
|
||||
if (typeof EventConstructor === 'function') {
|
||||
event = new EventConstructor(eventName, eventInit);
|
||||
} else {
|
||||
// IE11 polyfill from https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
|
||||
event = window.document.createEvent(EventType);
|
||||
const {
|
||||
bubbles,
|
||||
cancelable,
|
||||
detail,
|
||||
...otherInit
|
||||
} = eventInit;
|
||||
event.initEvent(eventName, bubbles, cancelable, detail);
|
||||
Object.keys(otherInit).forEach(eventKey => {
|
||||
event[eventKey] = otherInit[eventKey];
|
||||
});
|
||||
} // DataTransfer is not supported in jsdom: https://github.com/jsdom/jsdom/issues/1568
|
||||
|
||||
|
||||
const dataTransferProperties = ['dataTransfer', 'clipboardData'];
|
||||
dataTransferProperties.forEach(dataTransferKey => {
|
||||
const dataTransferValue = eventInit[dataTransferKey];
|
||||
|
||||
if (typeof dataTransferValue === 'object') {
|
||||
/* istanbul ignore if */
|
||||
if (typeof window.DataTransfer === 'function') {
|
||||
Object.defineProperty(event, dataTransferKey, {
|
||||
value: Object.getOwnPropertyNames(dataTransferValue).reduce((acc, propName) => {
|
||||
Object.defineProperty(acc, propName, {
|
||||
value: dataTransferValue[propName]
|
||||
});
|
||||
return acc;
|
||||
}, new window.DataTransfer())
|
||||
});
|
||||
} else {
|
||||
Object.defineProperty(event, dataTransferKey, {
|
||||
value: dataTransferValue
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return event;
|
||||
}
|
||||
|
||||
Object.keys(_eventMap.eventMap).forEach(key => {
|
||||
const {
|
||||
EventType,
|
||||
defaultInit
|
||||
} = _eventMap.eventMap[key];
|
||||
const eventName = key.toLowerCase();
|
||||
|
||||
createEvent[key] = (node, init) => createEvent(eventName, node, init, {
|
||||
EventType,
|
||||
defaultInit
|
||||
});
|
||||
|
||||
fireEvent[key] = (node, init) => fireEvent(node, createEvent[key](node, init));
|
||||
}); // function written after some investigation here:
|
||||
// https://github.com/facebook/react/issues/10135#issuecomment-401496776
|
||||
|
||||
function setNativeValue(element, value) {
|
||||
const {
|
||||
set: valueSetter
|
||||
} = Object.getOwnPropertyDescriptor(element, 'value') || {};
|
||||
const prototype = Object.getPrototypeOf(element);
|
||||
const {
|
||||
set: prototypeValueSetter
|
||||
} = Object.getOwnPropertyDescriptor(prototype, 'value') || {};
|
||||
|
||||
if (prototypeValueSetter && valueSetter !== prototypeValueSetter) {
|
||||
prototypeValueSetter.call(element, value);
|
||||
}
|
||||
/* istanbul ignore next (I don't want to bother) */
|
||||
else if (valueSetter) {
|
||||
valueSetter.call(element, value);
|
||||
} else {
|
||||
throw new Error('The given element does not have a value setter');
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(_eventMap.eventAliasMap).forEach(aliasKey => {
|
||||
const key = _eventMap.eventAliasMap[aliasKey];
|
||||
|
||||
fireEvent[aliasKey] = (...args) => fireEvent[key](...args);
|
||||
});
|
||||
/* eslint complexity:["error", 9] */
|
16
web/node_modules/@testing-library/dom/dist/get-node-text.js
generated
vendored
Normal file
16
web/node_modules/@testing-library/dom/dist/get-node-text.js
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getNodeText = getNodeText;
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
function getNodeText(node) {
|
||||
if (node.matches('input[type=submit], input[type=button]')) {
|
||||
return node.value;
|
||||
}
|
||||
|
||||
return Array.from(node.childNodes).filter(child => child.nodeType === _helpers.TEXT_NODE && Boolean(child.textContent)).map(c => c.textContent).join('');
|
||||
}
|
30
web/node_modules/@testing-library/dom/dist/get-queries-for-element.js
generated
vendored
Normal file
30
web/node_modules/@testing-library/dom/dist/get-queries-for-element.js
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getQueriesForElement = getQueriesForElement;
|
||||
|
||||
var defaultQueries = _interopRequireWildcard(require("./queries"));
|
||||
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
|
||||
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; }
|
||||
|
||||
/**
|
||||
* @typedef {{[key: string]: Function}} FuncMap
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} element container
|
||||
* @param {FuncMap} queries object of functions
|
||||
* @param {Object} initialValue for reducer
|
||||
* @returns {FuncMap} returns object of functions bound to container
|
||||
*/
|
||||
function getQueriesForElement(element, queries = defaultQueries, initialValue = {}) {
|
||||
return Object.keys(queries).reduce((helpers, key) => {
|
||||
const fn = queries[key];
|
||||
helpers[key] = fn.bind(null, element);
|
||||
return helpers;
|
||||
}, initialValue);
|
||||
}
|
60
web/node_modules/@testing-library/dom/dist/get-user-code-frame.js
generated
vendored
Normal file
60
web/node_modules/@testing-library/dom/dist/get-user-code-frame.js
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getUserCodeFrame = getUserCodeFrame;
|
||||
// We try to load node dependencies
|
||||
let chalk = null;
|
||||
let readFileSync = null;
|
||||
let codeFrameColumns = null;
|
||||
|
||||
try {
|
||||
const nodeRequire = module && module.require;
|
||||
readFileSync = nodeRequire.call(module, 'fs').readFileSync;
|
||||
codeFrameColumns = nodeRequire.call(module, '@babel/code-frame').codeFrameColumns;
|
||||
chalk = nodeRequire.call(module, 'chalk');
|
||||
} catch {// We're in a browser environment
|
||||
} // frame has the form "at myMethod (location/to/my/file.js:10:2)"
|
||||
|
||||
|
||||
function getCodeFrame(frame) {
|
||||
const locationStart = frame.indexOf('(') + 1;
|
||||
const locationEnd = frame.indexOf(')');
|
||||
const frameLocation = frame.slice(locationStart, locationEnd);
|
||||
const frameLocationElements = frameLocation.split(':');
|
||||
const [filename, line, column] = [frameLocationElements[0], parseInt(frameLocationElements[1], 10), parseInt(frameLocationElements[2], 10)];
|
||||
let rawFileContents = '';
|
||||
|
||||
try {
|
||||
rawFileContents = readFileSync(filename, 'utf-8');
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
|
||||
const codeFrame = codeFrameColumns(rawFileContents, {
|
||||
start: {
|
||||
line,
|
||||
column
|
||||
}
|
||||
}, {
|
||||
highlightCode: true,
|
||||
linesBelow: 0
|
||||
});
|
||||
return `${chalk.dim(frameLocation)}\n${codeFrame}\n`;
|
||||
}
|
||||
|
||||
function getUserCodeFrame() {
|
||||
// If we couldn't load dependencies, we can't generate the user trace
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (!readFileSync || !codeFrameColumns) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const err = new Error();
|
||||
const firstClientCodeFrame = err.stack.split('\n').slice(1) // Remove first line which has the form "Error: TypeError"
|
||||
.find(frame => !frame.includes('node_modules/')); // Ignore frames from 3rd party libraries
|
||||
|
||||
return getCodeFrame(firstClientCodeFrame);
|
||||
}
|
72
web/node_modules/@testing-library/dom/dist/helpers.js
generated
vendored
Normal file
72
web/node_modules/@testing-library/dom/dist/helpers.js
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getWindowFromNode = getWindowFromNode;
|
||||
exports.getDocument = getDocument;
|
||||
exports.checkContainerType = checkContainerType;
|
||||
exports.jestFakeTimersAreEnabled = jestFakeTimersAreEnabled;
|
||||
exports.TEXT_NODE = void 0;
|
||||
// Constant node.nodeType for text nodes, see:
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants
|
||||
const TEXT_NODE = 3;
|
||||
exports.TEXT_NODE = TEXT_NODE;
|
||||
|
||||
function jestFakeTimersAreEnabled() {
|
||||
/* istanbul ignore else */
|
||||
if (typeof jest !== 'undefined' && jest !== null) {
|
||||
return (// legacy timers
|
||||
setTimeout._isMockFunction === true || // modern timers
|
||||
Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
|
||||
);
|
||||
} // istanbul ignore next
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getDocument() {
|
||||
/* istanbul ignore if */
|
||||
if (typeof window === 'undefined') {
|
||||
throw new Error('Could not find default container');
|
||||
}
|
||||
|
||||
return window.document;
|
||||
}
|
||||
|
||||
function getWindowFromNode(node) {
|
||||
if (node.defaultView) {
|
||||
// node is document
|
||||
return node.defaultView;
|
||||
} else if (node.ownerDocument && node.ownerDocument.defaultView) {
|
||||
// node is a DOM node
|
||||
return node.ownerDocument.defaultView;
|
||||
} else if (node.window) {
|
||||
// node is window
|
||||
return node.window;
|
||||
} else if (node.then instanceof Function) {
|
||||
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`);
|
||||
}
|
||||
}
|
||||
|
||||
function checkContainerType(container) {
|
||||
if (!container || !(typeof container.querySelector === 'function') || !(typeof container.querySelectorAll === 'function')) {
|
||||
throw new TypeError(`Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName(container)}.`);
|
||||
}
|
||||
|
||||
function getTypeName(object) {
|
||||
if (typeof object === 'object') {
|
||||
return object === null ? 'null' : object.constructor.name;
|
||||
}
|
||||
|
||||
return typeof object;
|
||||
}
|
||||
}
|
211
web/node_modules/@testing-library/dom/dist/index.js
generated
vendored
Normal file
211
web/node_modules/@testing-library/dom/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,211 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
within: true,
|
||||
queries: true,
|
||||
queryHelpers: true,
|
||||
getDefaultNormalizer: true,
|
||||
getRoles: true,
|
||||
logRoles: true,
|
||||
isInaccessible: true,
|
||||
configure: true,
|
||||
getConfig: true
|
||||
};
|
||||
Object.defineProperty(exports, "within", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _getQueriesForElement.getQueriesForElement;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getDefaultNormalizer", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _matches.getDefaultNormalizer;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getRoles", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _roleHelpers.getRoles;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "logRoles", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _roleHelpers.logRoles;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isInaccessible", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _roleHelpers.isInaccessible;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "configure", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _config.configure;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getConfig", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _config.getConfig;
|
||||
}
|
||||
});
|
||||
exports.queryHelpers = exports.queries = void 0;
|
||||
|
||||
var _getQueriesForElement = require("./get-queries-for-element");
|
||||
|
||||
Object.keys(_getQueriesForElement).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _getQueriesForElement[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _getQueriesForElement[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var queries = _interopRequireWildcard(require("./queries"));
|
||||
|
||||
exports.queries = queries;
|
||||
Object.keys(queries).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === queries[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return queries[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var queryHelpers = _interopRequireWildcard(require("./query-helpers"));
|
||||
|
||||
exports.queryHelpers = queryHelpers;
|
||||
Object.keys(queryHelpers).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === queryHelpers[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return queryHelpers[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _waitFor = require("./wait-for");
|
||||
|
||||
Object.keys(_waitFor).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _waitFor[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _waitFor[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _waitForElementToBeRemoved = require("./wait-for-element-to-be-removed");
|
||||
|
||||
Object.keys(_waitForElementToBeRemoved).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _waitForElementToBeRemoved[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _waitForElementToBeRemoved[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _matches = require("./matches");
|
||||
|
||||
var _getNodeText = require("./get-node-text");
|
||||
|
||||
Object.keys(_getNodeText).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _getNodeText[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _getNodeText[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _events = require("./events");
|
||||
|
||||
Object.keys(_events).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _events[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _events[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _screen = require("./screen");
|
||||
|
||||
Object.keys(_screen).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _screen[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _screen[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _roleHelpers = require("./role-helpers");
|
||||
|
||||
var _prettyDom = require("./pretty-dom");
|
||||
|
||||
Object.keys(_prettyDom).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _prettyDom[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _prettyDom[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
var _suggestions = require("./suggestions");
|
||||
|
||||
Object.keys(_suggestions).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _suggestions[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _suggestions[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
|
||||
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; }
|
76
web/node_modules/@testing-library/dom/dist/label-helpers.js
generated
vendored
Normal file
76
web/node_modules/@testing-library/dom/dist/label-helpers.js
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getLabels = getLabels;
|
||||
exports.getRealLabels = getRealLabels;
|
||||
exports.getLabelContent = getLabelContent;
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
const labelledNodeNames = ['button', 'meter', 'output', 'progress', 'select', 'textarea', 'input'];
|
||||
|
||||
function getTextContent(node) {
|
||||
if (labelledNodeNames.includes(node.nodeName.toLowerCase())) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (node.nodeType === _helpers.TEXT_NODE) return node.textContent;
|
||||
return Array.from(node.childNodes).map(childNode => getTextContent(childNode)).join('');
|
||||
}
|
||||
|
||||
function getLabelContent(element) {
|
||||
let textContent;
|
||||
|
||||
if (element.tagName.toLowerCase() === 'label') {
|
||||
textContent = getTextContent(element);
|
||||
} else {
|
||||
textContent = element.value || element.textContent;
|
||||
}
|
||||
|
||||
return textContent;
|
||||
} // Based on https://github.com/eps1lon/dom-accessibility-api/pull/352
|
||||
|
||||
|
||||
function getRealLabels(element) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- types are not aware of older browsers that don't implement `labels`
|
||||
if (element.labels !== undefined) {
|
||||
var _labels;
|
||||
|
||||
return (_labels = element.labels) != null ? _labels : [];
|
||||
}
|
||||
|
||||
if (!isLabelable(element)) return [];
|
||||
const labels = element.ownerDocument.querySelectorAll('label');
|
||||
return Array.from(labels).filter(label => label.control === element);
|
||||
}
|
||||
|
||||
function isLabelable(element) {
|
||||
return /BUTTON|METER|OUTPUT|PROGRESS|SELECT|TEXTAREA/.test(element.tagName) || element.tagName === 'INPUT' && element.getAttribute('type') !== 'hidden';
|
||||
}
|
||||
|
||||
function getLabels(container, element, {
|
||||
selector = '*'
|
||||
} = {}) {
|
||||
const ariaLabelledBy = element.getAttribute('aria-labelledby');
|
||||
const labelsId = ariaLabelledBy ? ariaLabelledBy.split(' ') : [];
|
||||
return labelsId.length ? labelsId.map(labelId => {
|
||||
const labellingElement = container.querySelector(`[id="${labelId}"]`);
|
||||
return labellingElement ? {
|
||||
content: getLabelContent(labellingElement),
|
||||
formControl: null
|
||||
} : {
|
||||
content: '',
|
||||
formControl: null
|
||||
};
|
||||
}) : Array.from(getRealLabels(element)).map(label => {
|
||||
const textToMatch = getLabelContent(label);
|
||||
const formControlSelector = 'button, input, meter, output, progress, select, textarea';
|
||||
const labelledFormControl = Array.from(label.querySelectorAll(formControlSelector)).filter(formControlElement => formControlElement.matches(selector))[0];
|
||||
return {
|
||||
content: textToMatch,
|
||||
formControl: labelledFormControl
|
||||
};
|
||||
});
|
||||
}
|
94
web/node_modules/@testing-library/dom/dist/matches.js
generated
vendored
Normal file
94
web/node_modules/@testing-library/dom/dist/matches.js
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.fuzzyMatches = fuzzyMatches;
|
||||
exports.matches = matches;
|
||||
exports.getDefaultNormalizer = getDefaultNormalizer;
|
||||
exports.makeNormalizer = makeNormalizer;
|
||||
|
||||
function assertNotNullOrUndefined(matcher) {
|
||||
if (matcher === null || matcher === undefined) {
|
||||
throw new Error( // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- implicitly converting `T` to `string`
|
||||
`It looks like ${matcher} was passed instead of a matcher. Did you do something like getByText(${matcher})?`);
|
||||
}
|
||||
}
|
||||
|
||||
function fuzzyMatches(textToMatch, node, matcher, normalizer) {
|
||||
if (typeof textToMatch !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
assertNotNullOrUndefined(matcher);
|
||||
const normalizedText = normalizer(textToMatch);
|
||||
|
||||
if (typeof matcher === 'string' || typeof matcher === 'number') {
|
||||
return normalizedText.toLowerCase().includes(matcher.toString().toLowerCase());
|
||||
} else if (typeof matcher === 'function') {
|
||||
return matcher(normalizedText, node);
|
||||
} else {
|
||||
return matcher.test(normalizedText);
|
||||
}
|
||||
}
|
||||
|
||||
function matches(textToMatch, node, matcher, normalizer) {
|
||||
if (typeof textToMatch !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
assertNotNullOrUndefined(matcher);
|
||||
const normalizedText = normalizer(textToMatch);
|
||||
|
||||
if (matcher instanceof Function) {
|
||||
return matcher(normalizedText, node);
|
||||
} else if (matcher instanceof RegExp) {
|
||||
return matcher.test(normalizedText);
|
||||
} else {
|
||||
return normalizedText === String(matcher);
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaultNormalizer({
|
||||
trim = true,
|
||||
collapseWhitespace = true
|
||||
} = {}) {
|
||||
return text => {
|
||||
let normalizedText = text;
|
||||
normalizedText = trim ? normalizedText.trim() : normalizedText;
|
||||
normalizedText = collapseWhitespace ? normalizedText.replace(/\s+/g, ' ') : normalizedText;
|
||||
return normalizedText;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Constructs a normalizer to pass to functions in matches.js
|
||||
* @param {boolean|undefined} trim The user-specified value for `trim`, without
|
||||
* any defaulting having been applied
|
||||
* @param {boolean|undefined} collapseWhitespace The user-specified value for
|
||||
* `collapseWhitespace`, without any defaulting having been applied
|
||||
* @param {Function|undefined} normalizer The user-specified normalizer
|
||||
* @returns {Function} A normalizer
|
||||
*/
|
||||
|
||||
|
||||
function makeNormalizer({
|
||||
trim,
|
||||
collapseWhitespace,
|
||||
normalizer
|
||||
}) {
|
||||
if (normalizer) {
|
||||
// User has specified a custom normalizer
|
||||
if (typeof trim !== 'undefined' || typeof collapseWhitespace !== 'undefined') {
|
||||
// They've also specified a value for trim or collapseWhitespace
|
||||
throw new 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 normalizer;
|
||||
} else {
|
||||
// No custom normalizer specified. Just use default.
|
||||
return getDefaultNormalizer({
|
||||
trim,
|
||||
collapseWhitespace
|
||||
});
|
||||
}
|
||||
}
|
101
web/node_modules/@testing-library/dom/dist/pretty-dom.js
generated
vendored
Normal file
101
web/node_modules/@testing-library/dom/dist/pretty-dom.js
generated
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.prettyDOM = prettyDOM;
|
||||
exports.prettyFormat = exports.logDOM = void 0;
|
||||
|
||||
var prettyFormat = _interopRequireWildcard(require("pretty-format"));
|
||||
|
||||
exports.prettyFormat = prettyFormat;
|
||||
|
||||
var _DOMElementFilter = _interopRequireDefault(require("./DOMElementFilter"));
|
||||
|
||||
var _getUserCodeFrame = require("./get-user-code-frame");
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
var _shared = require("./shared");
|
||||
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
|
||||
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; }
|
||||
|
||||
function inCypress(dom) {
|
||||
const window = dom.ownerDocument && dom.ownerDocument.defaultView || undefined;
|
||||
return typeof global !== 'undefined' && global.Cypress || typeof window !== 'undefined' && window.Cypress;
|
||||
}
|
||||
|
||||
const inNode = () => typeof process !== 'undefined' && process.versions !== undefined && process.versions.node !== undefined;
|
||||
|
||||
const getMaxLength = dom => inCypress(dom) ? 0 : typeof process !== 'undefined' && process.env.DEBUG_PRINT_LIMIT || 7000;
|
||||
|
||||
const {
|
||||
DOMCollection
|
||||
} = prettyFormat.plugins; // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#node_type_constants
|
||||
|
||||
const ELEMENT_NODE = 1;
|
||||
const COMMENT_NODE = 8; // https://github.com/facebook/jest/blob/615084195ae1ae61ddd56162c62bbdda17587569/packages/pretty-format/src/plugins/DOMElement.ts#L50
|
||||
|
||||
function filterCommentsAndDefaultIgnoreTagsTags(value) {
|
||||
return value.nodeType !== COMMENT_NODE && ( // value.nodeType === ELEMENT_NODE => !value.matches(DEFAULT_IGNORE_TAGS)
|
||||
value.nodeType !== ELEMENT_NODE || !value.matches(_shared.DEFAULT_IGNORE_TAGS));
|
||||
}
|
||||
|
||||
function prettyDOM(dom, maxLength, options = {}) {
|
||||
if (!dom) {
|
||||
dom = (0, _helpers.getDocument)().body;
|
||||
}
|
||||
|
||||
if (typeof maxLength !== 'number') {
|
||||
maxLength = getMaxLength(dom);
|
||||
}
|
||||
|
||||
if (maxLength === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (dom.documentElement) {
|
||||
dom = dom.documentElement;
|
||||
}
|
||||
|
||||
let domTypeName = typeof dom;
|
||||
|
||||
if (domTypeName === 'object') {
|
||||
domTypeName = dom.constructor.name;
|
||||
} else {
|
||||
// To don't fall with `in` operator
|
||||
dom = {};
|
||||
}
|
||||
|
||||
if (!('outerHTML' in dom)) {
|
||||
throw new TypeError(`Expected an element or document but got ${domTypeName}`);
|
||||
}
|
||||
|
||||
const {
|
||||
filterNode = filterCommentsAndDefaultIgnoreTagsTags,
|
||||
...prettyFormatOptions
|
||||
} = options;
|
||||
const debugContent = prettyFormat.format(dom, {
|
||||
plugins: [(0, _DOMElementFilter.default)(filterNode), DOMCollection],
|
||||
printFunctionName: false,
|
||||
highlight: inNode(),
|
||||
...prettyFormatOptions
|
||||
});
|
||||
return maxLength !== undefined && dom.outerHTML.length > maxLength ? `${debugContent.slice(0, maxLength)}...` : debugContent;
|
||||
}
|
||||
|
||||
const logDOM = (...args) => {
|
||||
const userCodeFrame = (0, _getUserCodeFrame.getUserCodeFrame)();
|
||||
|
||||
if (userCodeFrame) {
|
||||
console.log(`${prettyDOM(...args)}\n\n${userCodeFrame}`);
|
||||
} else {
|
||||
console.log(prettyDOM(...args));
|
||||
}
|
||||
};
|
||||
|
||||
exports.logDOM = logDOM;
|
57
web/node_modules/@testing-library/dom/dist/queries/all-utils.js
generated
vendored
Normal file
57
web/node_modules/@testing-library/dom/dist/queries/all-utils.js
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _matches = require("../matches");
|
||||
|
||||
Object.keys(_matches).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _matches[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _matches[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _getNodeText = require("../get-node-text");
|
||||
|
||||
Object.keys(_getNodeText).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _getNodeText[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _getNodeText[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _queryHelpers = require("../query-helpers");
|
||||
|
||||
Object.keys(_queryHelpers).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _queryHelpers[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _queryHelpers[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _config = require("../config");
|
||||
|
||||
Object.keys(_config).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _config[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _config[key];
|
||||
}
|
||||
});
|
||||
});
|
41
web/node_modules/@testing-library/dom/dist/queries/alt-text.js
generated
vendored
Normal file
41
web/node_modules/@testing-library/dom/dist/queries/alt-text.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findByAltText = exports.findAllByAltText = exports.getAllByAltText = exports.getByAltText = exports.queryAllByAltText = exports.queryByAltText = void 0;
|
||||
|
||||
var _queryHelpers = require("../query-helpers");
|
||||
|
||||
var _helpers = require("../helpers");
|
||||
|
||||
var _allUtils = require("./all-utils");
|
||||
|
||||
const queryAllByAltText = (container, alt, {
|
||||
exact = true,
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
} = {}) => {
|
||||
(0, _helpers.checkContainerType)(container);
|
||||
const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
|
||||
const matchNormalizer = (0, _allUtils.makeNormalizer)({
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
});
|
||||
return Array.from(container.querySelectorAll('img,input,area')).filter(node => matcher(node.getAttribute('alt'), node, alt, matchNormalizer));
|
||||
};
|
||||
|
||||
const getMultipleError = (c, alt) => `Found multiple elements with the alt text: ${alt}`;
|
||||
|
||||
const getMissingError = (c, alt) => `Unable to find an element with the alt text: ${alt}`;
|
||||
|
||||
const queryAllByAltTextWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByAltText, queryAllByAltText.name, 'queryAll');
|
||||
exports.queryAllByAltText = queryAllByAltTextWithSuggestions;
|
||||
const [queryByAltText, getAllByAltText, getByAltText, findAllByAltText, findByAltText] = (0, _allUtils.buildQueries)(queryAllByAltText, getMultipleError, getMissingError);
|
||||
exports.findByAltText = findByAltText;
|
||||
exports.findAllByAltText = findAllByAltText;
|
||||
exports.getByAltText = getByAltText;
|
||||
exports.getAllByAltText = getAllByAltText;
|
||||
exports.queryByAltText = queryByAltText;
|
48
web/node_modules/@testing-library/dom/dist/queries/display-value.js
generated
vendored
Normal file
48
web/node_modules/@testing-library/dom/dist/queries/display-value.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findByDisplayValue = exports.findAllByDisplayValue = exports.getAllByDisplayValue = exports.getByDisplayValue = exports.queryAllByDisplayValue = exports.queryByDisplayValue = void 0;
|
||||
|
||||
var _queryHelpers = require("../query-helpers");
|
||||
|
||||
var _helpers = require("../helpers");
|
||||
|
||||
var _allUtils = require("./all-utils");
|
||||
|
||||
const queryAllByDisplayValue = (container, value, {
|
||||
exact = true,
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
} = {}) => {
|
||||
(0, _helpers.checkContainerType)(container);
|
||||
const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
|
||||
const matchNormalizer = (0, _allUtils.makeNormalizer)({
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
});
|
||||
return Array.from(container.querySelectorAll(`input,textarea,select`)).filter(node => {
|
||||
if (node.tagName === 'SELECT') {
|
||||
const selectedOptions = Array.from(node.options).filter(option => option.selected);
|
||||
return selectedOptions.some(optionNode => matcher((0, _allUtils.getNodeText)(optionNode), optionNode, value, matchNormalizer));
|
||||
} else {
|
||||
return matcher(node.value, node, value, matchNormalizer);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getMultipleError = (c, value) => `Found multiple elements with the display value: ${value}.`;
|
||||
|
||||
const getMissingError = (c, value) => `Unable to find an element with the display value: ${value}.`;
|
||||
|
||||
const queryAllByDisplayValueWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByDisplayValue, queryAllByDisplayValue.name, 'queryAll');
|
||||
exports.queryAllByDisplayValue = queryAllByDisplayValueWithSuggestions;
|
||||
const [queryByDisplayValue, getAllByDisplayValue, getByDisplayValue, findAllByDisplayValue, findByDisplayValue] = (0, _allUtils.buildQueries)(queryAllByDisplayValue, getMultipleError, getMissingError);
|
||||
exports.findByDisplayValue = findByDisplayValue;
|
||||
exports.findAllByDisplayValue = findAllByDisplayValue;
|
||||
exports.getByDisplayValue = getByDisplayValue;
|
||||
exports.getAllByDisplayValue = getAllByDisplayValue;
|
||||
exports.queryByDisplayValue = queryByDisplayValue;
|
109
web/node_modules/@testing-library/dom/dist/queries/index.js
generated
vendored
Normal file
109
web/node_modules/@testing-library/dom/dist/queries/index.js
generated
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _labelText = require("./label-text");
|
||||
|
||||
Object.keys(_labelText).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _labelText[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _labelText[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _placeholderText = require("./placeholder-text");
|
||||
|
||||
Object.keys(_placeholderText).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _placeholderText[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _placeholderText[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _text = require("./text");
|
||||
|
||||
Object.keys(_text).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _text[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _text[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _displayValue = require("./display-value");
|
||||
|
||||
Object.keys(_displayValue).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _displayValue[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _displayValue[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _altText = require("./alt-text");
|
||||
|
||||
Object.keys(_altText).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _altText[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _altText[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _title = require("./title");
|
||||
|
||||
Object.keys(_title).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _title[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _title[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _role = require("./role");
|
||||
|
||||
Object.keys(_role).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _role[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _role[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _testId = require("./test-id");
|
||||
|
||||
Object.keys(_testId).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _testId[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _testId[key];
|
||||
}
|
||||
});
|
||||
});
|
152
web/node_modules/@testing-library/dom/dist/queries/label-text.js
generated
vendored
Normal file
152
web/node_modules/@testing-library/dom/dist/queries/label-text.js
generated
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findByLabelText = exports.findAllByLabelText = exports.getByLabelText = exports.getAllByLabelText = exports.queryByLabelText = exports.queryAllByLabelText = void 0;
|
||||
|
||||
var _config = require("../config");
|
||||
|
||||
var _helpers = require("../helpers");
|
||||
|
||||
var _labelHelpers = require("../label-helpers");
|
||||
|
||||
var _allUtils = require("./all-utils");
|
||||
|
||||
function queryAllLabels(container) {
|
||||
return Array.from(container.querySelectorAll('label,input')).map(node => {
|
||||
return {
|
||||
node,
|
||||
textToMatch: (0, _labelHelpers.getLabelContent)(node)
|
||||
};
|
||||
}).filter(({
|
||||
textToMatch
|
||||
}) => textToMatch !== null);
|
||||
}
|
||||
|
||||
const queryAllLabelsByText = (container, text, {
|
||||
exact = true,
|
||||
trim,
|
||||
collapseWhitespace,
|
||||
normalizer
|
||||
} = {}) => {
|
||||
const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
|
||||
const matchNormalizer = (0, _allUtils.makeNormalizer)({
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
});
|
||||
const textToMatchByLabels = queryAllLabels(container);
|
||||
return textToMatchByLabels.filter(({
|
||||
node,
|
||||
textToMatch
|
||||
}) => matcher(textToMatch, node, text, matchNormalizer)).map(({
|
||||
node
|
||||
}) => node);
|
||||
};
|
||||
|
||||
const queryAllByLabelText = (container, text, {
|
||||
selector = '*',
|
||||
exact = true,
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
} = {}) => {
|
||||
(0, _helpers.checkContainerType)(container);
|
||||
const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
|
||||
const matchNormalizer = (0, _allUtils.makeNormalizer)({
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
});
|
||||
const matchingLabelledElements = Array.from(container.querySelectorAll('*')).filter(element => {
|
||||
return (0, _labelHelpers.getRealLabels)(element).length || element.hasAttribute('aria-labelledby');
|
||||
}).reduce((labelledElements, labelledElement) => {
|
||||
const labelList = (0, _labelHelpers.getLabels)(container, labelledElement, {
|
||||
selector
|
||||
});
|
||||
labelList.filter(label => Boolean(label.formControl)).forEach(label => {
|
||||
if (matcher(label.content, label.formControl, text, matchNormalizer) && label.formControl) labelledElements.push(label.formControl);
|
||||
});
|
||||
const labelsValue = labelList.filter(label => Boolean(label.content)).map(label => label.content);
|
||||
if (matcher(labelsValue.join(' '), labelledElement, text, matchNormalizer)) labelledElements.push(labelledElement);
|
||||
|
||||
if (labelsValue.length > 1) {
|
||||
labelsValue.forEach((labelValue, index) => {
|
||||
if (matcher(labelValue, labelledElement, text, matchNormalizer)) labelledElements.push(labelledElement);
|
||||
const labelsFiltered = [...labelsValue];
|
||||
labelsFiltered.splice(index, 1);
|
||||
|
||||
if (labelsFiltered.length > 1) {
|
||||
if (matcher(labelsFiltered.join(' '), labelledElement, text, matchNormalizer)) labelledElements.push(labelledElement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
(0, _allUtils.queryAllByAttribute)('aria-label', container, text, {
|
||||
exact,
|
||||
normalizer: matchNormalizer
|
||||
}));
|
||||
return Array.from(new Set(matchingLabelledElements)).filter(element => element.matches(selector));
|
||||
}; // the getAll* query would normally look like this:
|
||||
// const getAllByLabelText = makeGetAllQuery(
|
||||
// queryAllByLabelText,
|
||||
// (c, text) => `Unable to find a label with the text of: ${text}`,
|
||||
// )
|
||||
// however, we can give a more helpful error message than the generic one,
|
||||
// so we're writing this one out by hand.
|
||||
|
||||
|
||||
const getAllByLabelText = (container, text, ...rest) => {
|
||||
const els = queryAllByLabelText(container, text, ...rest);
|
||||
|
||||
if (!els.length) {
|
||||
const labels = queryAllLabelsByText(container, text, ...rest);
|
||||
|
||||
if (labels.length) {
|
||||
const tagNames = labels.map(label => getTagNameOfElementAssociatedWithLabelViaFor(container, label)).filter(tagName => !!tagName);
|
||||
|
||||
if (tagNames.length) {
|
||||
throw (0, _config.getConfig)().getElementError(tagNames.map(tagName => `Found a label with the text of: ${text}, however the element associated with this label (<${tagName} />) is non-labellable [https://html.spec.whatwg.org/multipage/forms.html#category-label]. If you really need to label a <${tagName} />, you can use aria-label or aria-labelledby instead.`).join('\n\n'), container);
|
||||
} else {
|
||||
throw (0, _config.getConfig)().getElementError(`Found a label with the text of: ${text}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`, container);
|
||||
}
|
||||
} else {
|
||||
throw (0, _config.getConfig)().getElementError(`Unable to find a label with the text of: ${text}`, container);
|
||||
}
|
||||
}
|
||||
|
||||
return els;
|
||||
};
|
||||
|
||||
function getTagNameOfElementAssociatedWithLabelViaFor(container, label) {
|
||||
const htmlFor = label.getAttribute('for');
|
||||
|
||||
if (!htmlFor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const element = container.querySelector(`[id="${htmlFor}"]`);
|
||||
return element ? element.tagName.toLowerCase() : null;
|
||||
} // the reason mentioned above is the same reason we're not using buildQueries
|
||||
|
||||
|
||||
const getMultipleError = (c, text) => `Found multiple elements with the text of: ${text}`;
|
||||
|
||||
const queryByLabelText = (0, _allUtils.wrapSingleQueryWithSuggestion)((0, _allUtils.makeSingleQuery)(queryAllByLabelText, getMultipleError), queryAllByLabelText.name, 'query');
|
||||
exports.queryByLabelText = queryByLabelText;
|
||||
const getByLabelText = (0, _allUtils.makeSingleQuery)(getAllByLabelText, getMultipleError);
|
||||
const findAllByLabelText = (0, _allUtils.makeFindQuery)((0, _allUtils.wrapAllByQueryWithSuggestion)(getAllByLabelText, getAllByLabelText.name, 'findAll'));
|
||||
exports.findAllByLabelText = findAllByLabelText;
|
||||
const findByLabelText = (0, _allUtils.makeFindQuery)((0, _allUtils.wrapSingleQueryWithSuggestion)(getByLabelText, getAllByLabelText.name, 'find'));
|
||||
exports.findByLabelText = findByLabelText;
|
||||
const getAllByLabelTextWithSuggestions = (0, _allUtils.wrapAllByQueryWithSuggestion)(getAllByLabelText, getAllByLabelText.name, 'getAll');
|
||||
exports.getAllByLabelText = getAllByLabelTextWithSuggestions;
|
||||
const getByLabelTextWithSuggestions = (0, _allUtils.wrapSingleQueryWithSuggestion)(getByLabelText, getAllByLabelText.name, 'get');
|
||||
exports.getByLabelText = getByLabelTextWithSuggestions;
|
||||
const queryAllByLabelTextWithSuggestions = (0, _allUtils.wrapAllByQueryWithSuggestion)(queryAllByLabelText, queryAllByLabelText.name, 'queryAll');
|
||||
exports.queryAllByLabelText = queryAllByLabelTextWithSuggestions;
|
33
web/node_modules/@testing-library/dom/dist/queries/placeholder-text.js
generated
vendored
Normal file
33
web/node_modules/@testing-library/dom/dist/queries/placeholder-text.js
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findByPlaceholderText = exports.findAllByPlaceholderText = exports.getAllByPlaceholderText = exports.getByPlaceholderText = exports.queryAllByPlaceholderText = exports.queryByPlaceholderText = void 0;
|
||||
|
||||
var _queryHelpers = require("../query-helpers");
|
||||
|
||||
var _helpers = require("../helpers");
|
||||
|
||||
var _allUtils = require("./all-utils");
|
||||
|
||||
const queryAllByPlaceholderText = (...args) => {
|
||||
(0, _helpers.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
|
||||
|
||||
return (0, _allUtils.queryAllByAttribute)('placeholder', ...args);
|
||||
};
|
||||
|
||||
const getMultipleError = (c, text) => `Found multiple elements with the placeholder text of: ${text}`;
|
||||
|
||||
const getMissingError = (c, text) => `Unable to find an element with the placeholder text of: ${text}`;
|
||||
|
||||
const queryAllByPlaceholderTextWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByPlaceholderText, queryAllByPlaceholderText.name, 'queryAll');
|
||||
exports.queryAllByPlaceholderText = queryAllByPlaceholderTextWithSuggestions;
|
||||
const [queryByPlaceholderText, getAllByPlaceholderText, getByPlaceholderText, findAllByPlaceholderText, findByPlaceholderText] = (0, _allUtils.buildQueries)(queryAllByPlaceholderText, getMultipleError, getMissingError);
|
||||
exports.findByPlaceholderText = findByPlaceholderText;
|
||||
exports.findAllByPlaceholderText = findAllByPlaceholderText;
|
||||
exports.getByPlaceholderText = getByPlaceholderText;
|
||||
exports.getAllByPlaceholderText = getAllByPlaceholderText;
|
||||
exports.queryByPlaceholderText = queryByPlaceholderText;
|
226
web/node_modules/@testing-library/dom/dist/queries/role.js
generated
vendored
Normal file
226
web/node_modules/@testing-library/dom/dist/queries/role.js
generated
vendored
Normal file
|
@ -0,0 +1,226 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findByRole = exports.findAllByRole = exports.getByRole = exports.getAllByRole = exports.queryAllByRole = exports.queryByRole = void 0;
|
||||
|
||||
var _domAccessibilityApi = require("dom-accessibility-api");
|
||||
|
||||
var _ariaQuery = require("aria-query");
|
||||
|
||||
var _roleHelpers = require("../role-helpers");
|
||||
|
||||
var _queryHelpers = require("../query-helpers");
|
||||
|
||||
var _helpers = require("../helpers");
|
||||
|
||||
var _allUtils = require("./all-utils");
|
||||
|
||||
function queryAllByRole(container, role, {
|
||||
exact = true,
|
||||
collapseWhitespace,
|
||||
hidden = (0, _allUtils.getConfig)().defaultHidden,
|
||||
name,
|
||||
trim,
|
||||
normalizer,
|
||||
queryFallbacks = false,
|
||||
selected,
|
||||
checked,
|
||||
pressed,
|
||||
level,
|
||||
expanded
|
||||
} = {}) {
|
||||
(0, _helpers.checkContainerType)(container);
|
||||
const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
|
||||
const matchNormalizer = (0, _allUtils.makeNormalizer)({
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
});
|
||||
|
||||
if (selected !== undefined) {
|
||||
var _allRoles$get;
|
||||
|
||||
// guard against unknown roles
|
||||
if (((_allRoles$get = _ariaQuery.roles.get(role)) == null ? void 0 : _allRoles$get.props['aria-selected']) === undefined) {
|
||||
throw new Error(`"aria-selected" is not supported on role "${role}".`);
|
||||
}
|
||||
}
|
||||
|
||||
if (checked !== undefined) {
|
||||
var _allRoles$get2;
|
||||
|
||||
// guard against unknown roles
|
||||
if (((_allRoles$get2 = _ariaQuery.roles.get(role)) == null ? void 0 : _allRoles$get2.props['aria-checked']) === undefined) {
|
||||
throw new Error(`"aria-checked" is not supported on role "${role}".`);
|
||||
}
|
||||
}
|
||||
|
||||
if (pressed !== undefined) {
|
||||
var _allRoles$get3;
|
||||
|
||||
// guard against unknown roles
|
||||
if (((_allRoles$get3 = _ariaQuery.roles.get(role)) == null ? void 0 : _allRoles$get3.props['aria-pressed']) === undefined) {
|
||||
throw new Error(`"aria-pressed" is not supported on role "${role}".`);
|
||||
}
|
||||
}
|
||||
|
||||
if (level !== undefined) {
|
||||
// guard against using `level` option with any role other than `heading`
|
||||
if (role !== 'heading') {
|
||||
throw new Error(`Role "${role}" cannot have "level" property.`);
|
||||
}
|
||||
}
|
||||
|
||||
if (expanded !== undefined) {
|
||||
var _allRoles$get4;
|
||||
|
||||
// guard against unknown roles
|
||||
if (((_allRoles$get4 = _ariaQuery.roles.get(role)) == null ? void 0 : _allRoles$get4.props['aria-expanded']) === undefined) {
|
||||
throw new Error(`"aria-expanded" is not supported on role "${role}".`);
|
||||
}
|
||||
}
|
||||
|
||||
const subtreeIsInaccessibleCache = new WeakMap();
|
||||
|
||||
function cachedIsSubtreeInaccessible(element) {
|
||||
if (!subtreeIsInaccessibleCache.has(element)) {
|
||||
subtreeIsInaccessibleCache.set(element, (0, _roleHelpers.isSubtreeInaccessible)(element));
|
||||
}
|
||||
|
||||
return subtreeIsInaccessibleCache.get(element);
|
||||
}
|
||||
|
||||
return Array.from(container.querySelectorAll('*')).filter(node => {
|
||||
const isRoleSpecifiedExplicitly = node.hasAttribute('role');
|
||||
|
||||
if (isRoleSpecifiedExplicitly) {
|
||||
const roleValue = node.getAttribute('role');
|
||||
|
||||
if (queryFallbacks) {
|
||||
return roleValue.split(' ').filter(Boolean).some(text => matcher(text, node, role, matchNormalizer));
|
||||
} // if a custom normalizer is passed then let normalizer handle the role value
|
||||
|
||||
|
||||
if (normalizer) {
|
||||
return matcher(roleValue, node, role, matchNormalizer);
|
||||
} // other wise only send the first word to match
|
||||
|
||||
|
||||
const [firstWord] = roleValue.split(' ');
|
||||
return matcher(firstWord, node, role, matchNormalizer);
|
||||
}
|
||||
|
||||
const implicitRoles = (0, _roleHelpers.getImplicitAriaRoles)(node);
|
||||
return implicitRoles.some(implicitRole => matcher(implicitRole, node, role, matchNormalizer));
|
||||
}).filter(element => {
|
||||
if (selected !== undefined) {
|
||||
return selected === (0, _roleHelpers.computeAriaSelected)(element);
|
||||
}
|
||||
|
||||
if (checked !== undefined) {
|
||||
return checked === (0, _roleHelpers.computeAriaChecked)(element);
|
||||
}
|
||||
|
||||
if (pressed !== undefined) {
|
||||
return pressed === (0, _roleHelpers.computeAriaPressed)(element);
|
||||
}
|
||||
|
||||
if (expanded !== undefined) {
|
||||
return expanded === (0, _roleHelpers.computeAriaExpanded)(element);
|
||||
}
|
||||
|
||||
if (level !== undefined) {
|
||||
return level === (0, _roleHelpers.computeHeadingLevel)(element);
|
||||
} // don't care if aria attributes are unspecified
|
||||
|
||||
|
||||
return true;
|
||||
}).filter(element => {
|
||||
return hidden === false ? (0, _roleHelpers.isInaccessible)(element, {
|
||||
isSubtreeInaccessible: cachedIsSubtreeInaccessible
|
||||
}) === false : true;
|
||||
}).filter(element => {
|
||||
if (name === undefined) {
|
||||
// Don't care
|
||||
return true;
|
||||
}
|
||||
|
||||
return (0, _allUtils.matches)((0, _domAccessibilityApi.computeAccessibleName)(element, {
|
||||
computedStyleSupportsPseudoElements: (0, _allUtils.getConfig)().computedStyleSupportsPseudoElements
|
||||
}), element, name, text => text);
|
||||
});
|
||||
}
|
||||
|
||||
const getMultipleError = (c, role, {
|
||||
name
|
||||
} = {}) => {
|
||||
let nameHint = '';
|
||||
|
||||
if (name === undefined) {
|
||||
nameHint = '';
|
||||
} else if (typeof name === 'string') {
|
||||
nameHint = ` and name "${name}"`;
|
||||
} else {
|
||||
nameHint = ` and name \`${name}\``;
|
||||
}
|
||||
|
||||
return `Found multiple elements with the role "${role}"${nameHint}`;
|
||||
};
|
||||
|
||||
const getMissingError = (container, role, {
|
||||
hidden = (0, _allUtils.getConfig)().defaultHidden,
|
||||
name
|
||||
} = {}) => {
|
||||
if ((0, _allUtils.getConfig)()._disableExpensiveErrorDiagnostics) {
|
||||
return `Unable to find role="${role}"`;
|
||||
}
|
||||
|
||||
let roles = '';
|
||||
Array.from(container.children).forEach(childElement => {
|
||||
roles += (0, _roleHelpers.prettyRoles)(childElement, {
|
||||
hidden,
|
||||
includeName: name !== undefined
|
||||
});
|
||||
});
|
||||
let roleMessage;
|
||||
|
||||
if (roles.length === 0) {
|
||||
if (hidden === false) {
|
||||
roleMessage = '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';
|
||||
} else {
|
||||
roleMessage = 'There are no available roles.';
|
||||
}
|
||||
} else {
|
||||
roleMessage = `
|
||||
Here are the ${hidden === false ? 'accessible' : 'available'} roles:
|
||||
|
||||
${roles.replace(/\n/g, '\n ').replace(/\n\s\s\n/g, '\n\n')}
|
||||
`.trim();
|
||||
}
|
||||
|
||||
let nameHint = '';
|
||||
|
||||
if (name === undefined) {
|
||||
nameHint = '';
|
||||
} else if (typeof name === 'string') {
|
||||
nameHint = ` and name "${name}"`;
|
||||
} else {
|
||||
nameHint = ` and name \`${name}\``;
|
||||
}
|
||||
|
||||
return `
|
||||
Unable to find an ${hidden === false ? 'accessible ' : ''}element with the role "${role}"${nameHint}
|
||||
|
||||
${roleMessage}`.trim();
|
||||
};
|
||||
|
||||
const queryAllByRoleWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByRole, queryAllByRole.name, 'queryAll');
|
||||
exports.queryAllByRole = queryAllByRoleWithSuggestions;
|
||||
const [queryByRole, getAllByRole, getByRole, findAllByRole, findByRole] = (0, _allUtils.buildQueries)(queryAllByRole, getMultipleError, getMissingError);
|
||||
exports.findByRole = findByRole;
|
||||
exports.findAllByRole = findAllByRole;
|
||||
exports.getByRole = getByRole;
|
||||
exports.getAllByRole = getAllByRole;
|
||||
exports.queryByRole = queryByRole;
|
35
web/node_modules/@testing-library/dom/dist/queries/test-id.js
generated
vendored
Normal file
35
web/node_modules/@testing-library/dom/dist/queries/test-id.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findByTestId = exports.findAllByTestId = exports.getAllByTestId = exports.getByTestId = exports.queryAllByTestId = exports.queryByTestId = void 0;
|
||||
|
||||
var _helpers = require("../helpers");
|
||||
|
||||
var _queryHelpers = require("../query-helpers");
|
||||
|
||||
var _allUtils = require("./all-utils");
|
||||
|
||||
const getTestIdAttribute = () => (0, _allUtils.getConfig)().testIdAttribute;
|
||||
|
||||
const queryAllByTestId = (...args) => {
|
||||
(0, _helpers.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
|
||||
|
||||
return (0, _allUtils.queryAllByAttribute)(getTestIdAttribute(), ...args);
|
||||
};
|
||||
|
||||
const getMultipleError = (c, id) => `Found multiple elements by: [${getTestIdAttribute()}="${id}"]`;
|
||||
|
||||
const getMissingError = (c, id) => `Unable to find an element by: [${getTestIdAttribute()}="${id}"]`;
|
||||
|
||||
const queryAllByTestIdWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByTestId, queryAllByTestId.name, 'queryAll');
|
||||
exports.queryAllByTestId = queryAllByTestIdWithSuggestions;
|
||||
const [queryByTestId, getAllByTestId, getByTestId, findAllByTestId, findByTestId] = (0, _allUtils.buildQueries)(queryAllByTestId, getMultipleError, getMissingError);
|
||||
exports.findByTestId = findByTestId;
|
||||
exports.findAllByTestId = findAllByTestId;
|
||||
exports.getByTestId = getByTestId;
|
||||
exports.getAllByTestId = getAllByTestId;
|
||||
exports.queryByTestId = queryByTestId;
|
52
web/node_modules/@testing-library/dom/dist/queries/text.js
generated
vendored
Normal file
52
web/node_modules/@testing-library/dom/dist/queries/text.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findByText = exports.findAllByText = exports.getAllByText = exports.getByText = exports.queryAllByText = exports.queryByText = void 0;
|
||||
|
||||
var _queryHelpers = require("../query-helpers");
|
||||
|
||||
var _helpers = require("../helpers");
|
||||
|
||||
var _shared = require("../shared");
|
||||
|
||||
var _allUtils = require("./all-utils");
|
||||
|
||||
const queryAllByText = (container, text, {
|
||||
selector = '*',
|
||||
exact = true,
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
ignore = _shared.DEFAULT_IGNORE_TAGS,
|
||||
normalizer
|
||||
} = {}) => {
|
||||
(0, _helpers.checkContainerType)(container);
|
||||
const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
|
||||
const matchNormalizer = (0, _allUtils.makeNormalizer)({
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
});
|
||||
let baseArray = [];
|
||||
|
||||
if (typeof container.matches === 'function' && container.matches(selector)) {
|
||||
baseArray = [container];
|
||||
}
|
||||
|
||||
return [...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(node => !ignore || !node.matches(ignore)).filter(node => matcher((0, _allUtils.getNodeText)(node), node, text, matchNormalizer));
|
||||
};
|
||||
|
||||
const getMultipleError = (c, text) => `Found multiple elements with the text: ${text}`;
|
||||
|
||||
const getMissingError = (c, text) => `Unable to find an element with the text: ${text}. 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.`;
|
||||
|
||||
const queryAllByTextWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByText, queryAllByText.name, 'queryAll');
|
||||
exports.queryAllByText = queryAllByTextWithSuggestions;
|
||||
const [queryByText, getAllByText, getByText, findAllByText, findByText] = (0, _allUtils.buildQueries)(queryAllByText, getMultipleError, getMissingError);
|
||||
exports.findByText = findByText;
|
||||
exports.findAllByText = findAllByText;
|
||||
exports.getByText = getByText;
|
||||
exports.getAllByText = getAllByText;
|
||||
exports.queryByText = queryByText;
|
47
web/node_modules/@testing-library/dom/dist/queries/title.js
generated
vendored
Normal file
47
web/node_modules/@testing-library/dom/dist/queries/title.js
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findByTitle = exports.findAllByTitle = exports.getAllByTitle = exports.getByTitle = exports.queryAllByTitle = exports.queryByTitle = void 0;
|
||||
|
||||
var _queryHelpers = require("../query-helpers");
|
||||
|
||||
var _helpers = require("../helpers");
|
||||
|
||||
var _allUtils = require("./all-utils");
|
||||
|
||||
const isSvgTitle = node => {
|
||||
var _node$parentElement;
|
||||
|
||||
return node.tagName.toLowerCase() === 'title' && ((_node$parentElement = node.parentElement) == null ? void 0 : _node$parentElement.tagName.toLowerCase()) === 'svg';
|
||||
};
|
||||
|
||||
const queryAllByTitle = (container, text, {
|
||||
exact = true,
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
} = {}) => {
|
||||
(0, _helpers.checkContainerType)(container);
|
||||
const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
|
||||
const matchNormalizer = (0, _allUtils.makeNormalizer)({
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
});
|
||||
return Array.from(container.querySelectorAll('[title], svg > title')).filter(node => matcher(node.getAttribute('title'), node, text, matchNormalizer) || isSvgTitle(node) && matcher((0, _allUtils.getNodeText)(node), node, text, matchNormalizer));
|
||||
};
|
||||
|
||||
const getMultipleError = (c, title) => `Found multiple elements with the title: ${title}.`;
|
||||
|
||||
const getMissingError = (c, title) => `Unable to find an element with the title: ${title}.`;
|
||||
|
||||
const queryAllByTitleWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByTitle, queryAllByTitle.name, 'queryAll');
|
||||
exports.queryAllByTitle = queryAllByTitleWithSuggestions;
|
||||
const [queryByTitle, getAllByTitle, getByTitle, findAllByTitle, findByTitle] = (0, _allUtils.buildQueries)(queryAllByTitle, getMultipleError, getMissingError);
|
||||
exports.findByTitle = findByTitle;
|
||||
exports.findAllByTitle = findAllByTitle;
|
||||
exports.getByTitle = getByTitle;
|
||||
exports.getAllByTitle = getAllByTitle;
|
||||
exports.queryByTitle = queryByTitle;
|
164
web/node_modules/@testing-library/dom/dist/query-helpers.js
generated
vendored
Normal file
164
web/node_modules/@testing-library/dom/dist/query-helpers.js
generated
vendored
Normal file
|
@ -0,0 +1,164 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getElementError = getElementError;
|
||||
exports.getMultipleElementsFoundError = getMultipleElementsFoundError;
|
||||
exports.queryAllByAttribute = queryAllByAttribute;
|
||||
exports.queryByAttribute = queryByAttribute;
|
||||
exports.makeSingleQuery = makeSingleQuery;
|
||||
exports.makeGetAllQuery = makeGetAllQuery;
|
||||
exports.makeFindQuery = makeFindQuery;
|
||||
exports.buildQueries = buildQueries;
|
||||
exports.wrapSingleQueryWithSuggestion = exports.wrapAllByQueryWithSuggestion = void 0;
|
||||
|
||||
var _suggestions = require("./suggestions");
|
||||
|
||||
var _matches = require("./matches");
|
||||
|
||||
var _waitFor = require("./wait-for");
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
function getElementError(message, container) {
|
||||
return (0, _config.getConfig)().getElementError(message, container);
|
||||
}
|
||||
|
||||
function getMultipleElementsFoundError(message, container) {
|
||||
return getElementError(`${message}\n\n(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).`, container);
|
||||
}
|
||||
|
||||
function queryAllByAttribute(attribute, container, text, {
|
||||
exact = true,
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
} = {}) {
|
||||
const matcher = exact ? _matches.matches : _matches.fuzzyMatches;
|
||||
const matchNormalizer = (0, _matches.makeNormalizer)({
|
||||
collapseWhitespace,
|
||||
trim,
|
||||
normalizer
|
||||
});
|
||||
return Array.from(container.querySelectorAll(`[${attribute}]`)).filter(node => matcher(node.getAttribute(attribute), node, text, matchNormalizer));
|
||||
}
|
||||
|
||||
function queryByAttribute(attribute, container, text, ...args) {
|
||||
const els = queryAllByAttribute(attribute, container, text, ...args);
|
||||
|
||||
if (els.length > 1) {
|
||||
throw getMultipleElementsFoundError(`Found multiple elements by [${attribute}=${text}]`, container);
|
||||
}
|
||||
|
||||
return els[0] || null;
|
||||
} // this accepts a query function and returns a function which throws an error
|
||||
// if more than one elements is returned, otherwise it returns the first
|
||||
// element or null
|
||||
|
||||
|
||||
function makeSingleQuery(allQuery, getMultipleError) {
|
||||
return (container, ...args) => {
|
||||
const els = allQuery(container, ...args);
|
||||
|
||||
if (els.length > 1) {
|
||||
const elementStrings = els.map(element => getElementError(null, element).message).join('\n\n');
|
||||
throw getMultipleElementsFoundError(`${getMultipleError(container, ...args)}
|
||||
|
||||
Here are the matching elements:
|
||||
|
||||
${elementStrings}`, container);
|
||||
}
|
||||
|
||||
return els[0] || null;
|
||||
};
|
||||
}
|
||||
|
||||
function getSuggestionError(suggestion, container) {
|
||||
return (0, _config.getConfig)().getElementError(`A better query is available, try this:
|
||||
${suggestion.toString()}
|
||||
`, container);
|
||||
} // this accepts a query function and returns a function which throws an error
|
||||
// if an empty list of elements is returned
|
||||
|
||||
|
||||
function makeGetAllQuery(allQuery, getMissingError) {
|
||||
return (container, ...args) => {
|
||||
const els = allQuery(container, ...args);
|
||||
|
||||
if (!els.length) {
|
||||
throw (0, _config.getConfig)().getElementError(getMissingError(container, ...args), container);
|
||||
}
|
||||
|
||||
return els;
|
||||
};
|
||||
} // this accepts a getter query function and returns a function which calls
|
||||
// waitFor and passing a function which invokes the getter.
|
||||
|
||||
|
||||
function makeFindQuery(getter) {
|
||||
return (container, text, options, waitForOptions) => {
|
||||
return (0, _waitFor.waitFor)(() => {
|
||||
return getter(container, text, options);
|
||||
}, {
|
||||
container,
|
||||
...waitForOptions
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const wrapSingleQueryWithSuggestion = (query, queryAllByName, variant) => (container, ...args) => {
|
||||
const element = query(container, ...args);
|
||||
const [{
|
||||
suggest = (0, _config.getConfig)().throwSuggestions
|
||||
} = {}] = args.slice(-1);
|
||||
|
||||
if (element && suggest) {
|
||||
const suggestion = (0, _suggestions.getSuggestedQuery)(element, variant);
|
||||
|
||||
if (suggestion && !queryAllByName.endsWith(suggestion.queryName)) {
|
||||
throw getSuggestionError(suggestion.toString(), container);
|
||||
}
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
exports.wrapSingleQueryWithSuggestion = wrapSingleQueryWithSuggestion;
|
||||
|
||||
const wrapAllByQueryWithSuggestion = (query, queryAllByName, variant) => (container, ...args) => {
|
||||
const els = query(container, ...args);
|
||||
const [{
|
||||
suggest = (0, _config.getConfig)().throwSuggestions
|
||||
} = {}] = args.slice(-1);
|
||||
|
||||
if (els.length && suggest) {
|
||||
// get a unique list of all suggestion messages. We are only going to make a suggestion if
|
||||
// all the suggestions are the same
|
||||
const uniqueSuggestionMessages = [...new Set(els.map(element => {
|
||||
var _getSuggestedQuery;
|
||||
|
||||
return (_getSuggestedQuery = (0, _suggestions.getSuggestedQuery)(element, variant)) == null ? void 0 : _getSuggestedQuery.toString();
|
||||
}))];
|
||||
|
||||
if ( // only want to suggest if all the els have the same suggestion.
|
||||
uniqueSuggestionMessages.length === 1 && !queryAllByName.endsWith((0, _suggestions.getSuggestedQuery)(els[0], variant).queryName)) {
|
||||
throw getSuggestionError(uniqueSuggestionMessages[0], container);
|
||||
}
|
||||
}
|
||||
|
||||
return els;
|
||||
};
|
||||
|
||||
exports.wrapAllByQueryWithSuggestion = wrapAllByQueryWithSuggestion;
|
||||
|
||||
function buildQueries(queryAllBy, getMultipleError, getMissingError) {
|
||||
const queryBy = wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllBy, getMultipleError), queryAllBy.name, 'query');
|
||||
const getAllBy = makeGetAllQuery(queryAllBy, getMissingError);
|
||||
const getBy = makeSingleQuery(getAllBy, getMultipleError);
|
||||
const getByWithSuggestions = wrapSingleQueryWithSuggestion(getBy, queryAllBy.name, 'get');
|
||||
const getAllWithSuggestions = wrapAllByQueryWithSuggestion(getAllBy, queryAllBy.name.replace('query', 'get'), 'getAll');
|
||||
const findAllBy = makeFindQuery(wrapAllByQueryWithSuggestion(getAllBy, queryAllBy.name, 'findAll'));
|
||||
const findBy = makeFindQuery(wrapSingleQueryWithSuggestion(getBy, queryAllBy.name, 'find'));
|
||||
return [queryBy, getAllWithSuggestions, getByWithSuggestions, findAllBy, findBy];
|
||||
}
|
321
web/node_modules/@testing-library/dom/dist/role-helpers.js
generated
vendored
Normal file
321
web/node_modules/@testing-library/dom/dist/role-helpers.js
generated
vendored
Normal file
|
@ -0,0 +1,321 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getRoles = getRoles;
|
||||
exports.getImplicitAriaRoles = getImplicitAriaRoles;
|
||||
exports.isSubtreeInaccessible = isSubtreeInaccessible;
|
||||
exports.prettyRoles = prettyRoles;
|
||||
exports.isInaccessible = isInaccessible;
|
||||
exports.computeAriaSelected = computeAriaSelected;
|
||||
exports.computeAriaChecked = computeAriaChecked;
|
||||
exports.computeAriaPressed = computeAriaPressed;
|
||||
exports.computeAriaExpanded = computeAriaExpanded;
|
||||
exports.computeHeadingLevel = computeHeadingLevel;
|
||||
exports.logRoles = void 0;
|
||||
|
||||
var _ariaQuery = require("aria-query");
|
||||
|
||||
var _domAccessibilityApi = require("dom-accessibility-api");
|
||||
|
||||
var _prettyDom = require("./pretty-dom");
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
const elementRoleList = buildElementRoleList(_ariaQuery.elementRoles);
|
||||
/**
|
||||
* @param {Element} element -
|
||||
* @returns {boolean} - `true` if `element` and its subtree are inaccessible
|
||||
*/
|
||||
|
||||
function isSubtreeInaccessible(element) {
|
||||
if (element.hidden === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element.getAttribute('aria-hidden') === 'true') {
|
||||
return true;
|
||||
}
|
||||
|
||||
const window = element.ownerDocument.defaultView;
|
||||
|
||||
if (window.getComputedStyle(element).display === 'none') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Partial implementation https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion
|
||||
* which should only be used for elements with a non-presentational role i.e.
|
||||
* `role="none"` and `role="presentation"` will not be excluded.
|
||||
*
|
||||
* Implements aria-hidden semantics (i.e. parent overrides child)
|
||||
* Ignores "Child Presentational: True" characteristics
|
||||
*
|
||||
* @param {Element} element -
|
||||
* @param {object} [options] -
|
||||
* @param {function (element: Element): boolean} options.isSubtreeInaccessible -
|
||||
* can be used to return cached results from previous isSubtreeInaccessible calls
|
||||
* @returns {boolean} true if excluded, otherwise false
|
||||
*/
|
||||
|
||||
|
||||
function isInaccessible(element, options = {}) {
|
||||
const {
|
||||
isSubtreeInaccessible: isSubtreeInaccessibleImpl = isSubtreeInaccessible
|
||||
} = options;
|
||||
const window = element.ownerDocument.defaultView; // since visibility is inherited we can exit early
|
||||
|
||||
if (window.getComputedStyle(element).visibility === 'hidden') {
|
||||
return true;
|
||||
}
|
||||
|
||||
let currentElement = element;
|
||||
|
||||
while (currentElement) {
|
||||
if (isSubtreeInaccessibleImpl(currentElement)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
currentElement = currentElement.parentElement;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getImplicitAriaRoles(currentNode) {
|
||||
// eslint bug here:
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
for (const {
|
||||
match,
|
||||
roles
|
||||
} of elementRoleList) {
|
||||
if (match(currentNode)) {
|
||||
return [...roles];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function buildElementRoleList(elementRolesMap) {
|
||||
function makeElementSelector({
|
||||
name,
|
||||
attributes
|
||||
}) {
|
||||
return `${name}${attributes.map(({
|
||||
name: attributeName,
|
||||
value,
|
||||
constraints = []
|
||||
}) => {
|
||||
const shouldNotExist = constraints.indexOf('undefined') !== -1;
|
||||
|
||||
if (shouldNotExist) {
|
||||
return `:not([${attributeName}])`;
|
||||
} else if (value) {
|
||||
return `[${attributeName}="${value}"]`;
|
||||
} else {
|
||||
return `[${attributeName}]`;
|
||||
}
|
||||
}).join('')}`;
|
||||
}
|
||||
|
||||
function getSelectorSpecificity({
|
||||
attributes = []
|
||||
}) {
|
||||
return attributes.length;
|
||||
}
|
||||
|
||||
function bySelectorSpecificity({
|
||||
specificity: leftSpecificity
|
||||
}, {
|
||||
specificity: rightSpecificity
|
||||
}) {
|
||||
return rightSpecificity - leftSpecificity;
|
||||
}
|
||||
|
||||
function match(element) {
|
||||
return node => {
|
||||
let {
|
||||
attributes = []
|
||||
} = element; // https://github.com/testing-library/dom-testing-library/issues/814
|
||||
|
||||
const typeTextIndex = attributes.findIndex(attribute => attribute.value && attribute.name === 'type' && attribute.value === 'text');
|
||||
|
||||
if (typeTextIndex >= 0) {
|
||||
// not using splice to not mutate the attributes array
|
||||
attributes = [...attributes.slice(0, typeTextIndex), ...attributes.slice(typeTextIndex + 1)];
|
||||
|
||||
if (node.type !== 'text') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return node.matches(makeElementSelector({ ...element,
|
||||
attributes
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
let result = []; // eslint bug here:
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
for (const [element, roles] of elementRolesMap.entries()) {
|
||||
result = [...result, {
|
||||
match: match(element),
|
||||
roles: Array.from(roles),
|
||||
specificity: getSelectorSpecificity(element)
|
||||
}];
|
||||
}
|
||||
|
||||
return result.sort(bySelectorSpecificity);
|
||||
}
|
||||
|
||||
function getRoles(container, {
|
||||
hidden = false
|
||||
} = {}) {
|
||||
function flattenDOM(node) {
|
||||
return [node, ...Array.from(node.children).reduce((acc, child) => [...acc, ...flattenDOM(child)], [])];
|
||||
}
|
||||
|
||||
return flattenDOM(container).filter(element => {
|
||||
return hidden === false ? isInaccessible(element) === false : true;
|
||||
}).reduce((acc, node) => {
|
||||
let roles = []; // TODO: This violates html-aria which does not allow any role on every element
|
||||
|
||||
if (node.hasAttribute('role')) {
|
||||
roles = node.getAttribute('role').split(' ').slice(0, 1);
|
||||
} else {
|
||||
roles = getImplicitAriaRoles(node);
|
||||
}
|
||||
|
||||
return roles.reduce((rolesAcc, role) => Array.isArray(rolesAcc[role]) ? { ...rolesAcc,
|
||||
[role]: [...rolesAcc[role], node]
|
||||
} : { ...rolesAcc,
|
||||
[role]: [node]
|
||||
}, acc);
|
||||
}, {});
|
||||
}
|
||||
|
||||
function prettyRoles(dom, {
|
||||
hidden
|
||||
}) {
|
||||
const roles = getRoles(dom, {
|
||||
hidden
|
||||
}); // We prefer to skip generic role, we don't recommend it
|
||||
|
||||
return Object.entries(roles).filter(([role]) => role !== 'generic').map(([role, elements]) => {
|
||||
const delimiterBar = '-'.repeat(50);
|
||||
const elementsString = elements.map(el => {
|
||||
const nameString = `Name "${(0, _domAccessibilityApi.computeAccessibleName)(el, {
|
||||
computedStyleSupportsPseudoElements: (0, _config.getConfig)().computedStyleSupportsPseudoElements
|
||||
})}":\n`;
|
||||
const domString = (0, _prettyDom.prettyDOM)(el.cloneNode(false));
|
||||
return `${nameString}${domString}`;
|
||||
}).join('\n\n');
|
||||
return `${role}:\n\n${elementsString}\n\n${delimiterBar}`;
|
||||
}).join('\n');
|
||||
}
|
||||
|
||||
const logRoles = (dom, {
|
||||
hidden = false
|
||||
} = {}) => console.log(prettyRoles(dom, {
|
||||
hidden
|
||||
}));
|
||||
/**
|
||||
* @param {Element} element -
|
||||
* @returns {boolean | undefined} - false/true if (not)selected, undefined if not selectable
|
||||
*/
|
||||
|
||||
|
||||
exports.logRoles = logRoles;
|
||||
|
||||
function computeAriaSelected(element) {
|
||||
// implicit value from html-aam mappings: https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings
|
||||
// https://www.w3.org/TR/html-aam-1.0/#details-id-97
|
||||
if (element.tagName === 'OPTION') {
|
||||
return element.selected;
|
||||
} // explicit value
|
||||
|
||||
|
||||
return checkBooleanAttribute(element, 'aria-selected');
|
||||
}
|
||||
/**
|
||||
* @param {Element} element -
|
||||
* @returns {boolean | undefined} - false/true if (not)checked, undefined if not checked-able
|
||||
*/
|
||||
|
||||
|
||||
function computeAriaChecked(element) {
|
||||
// implicit value from html-aam mappings: https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings
|
||||
// https://www.w3.org/TR/html-aam-1.0/#details-id-56
|
||||
// https://www.w3.org/TR/html-aam-1.0/#details-id-67
|
||||
if ('indeterminate' in element && element.indeterminate) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if ('checked' in element) {
|
||||
return element.checked;
|
||||
} // explicit value
|
||||
|
||||
|
||||
return checkBooleanAttribute(element, 'aria-checked');
|
||||
}
|
||||
/**
|
||||
* @param {Element} element -
|
||||
* @returns {boolean | undefined} - false/true if (not)pressed, undefined if not press-able
|
||||
*/
|
||||
|
||||
|
||||
function computeAriaPressed(element) {
|
||||
// https://www.w3.org/TR/wai-aria-1.1/#aria-pressed
|
||||
return checkBooleanAttribute(element, 'aria-pressed');
|
||||
}
|
||||
/**
|
||||
* @param {Element} element -
|
||||
* @returns {boolean | undefined} - false/true if (not)expanded, undefined if not expand-able
|
||||
*/
|
||||
|
||||
|
||||
function computeAriaExpanded(element) {
|
||||
// https://www.w3.org/TR/wai-aria-1.1/#aria-expanded
|
||||
return checkBooleanAttribute(element, 'aria-expanded');
|
||||
}
|
||||
|
||||
function checkBooleanAttribute(element, attribute) {
|
||||
const attributeValue = element.getAttribute(attribute);
|
||||
|
||||
if (attributeValue === 'true') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (attributeValue === 'false') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
* @param {Element} element -
|
||||
* @returns {number | undefined} - number if implicit heading or aria-level present, otherwise undefined
|
||||
*/
|
||||
|
||||
|
||||
function computeHeadingLevel(element) {
|
||||
// https://w3c.github.io/html-aam/#el-h1-h6
|
||||
// https://w3c.github.io/html-aam/#el-h1-h6
|
||||
const implicitHeadingLevels = {
|
||||
H1: 1,
|
||||
H2: 2,
|
||||
H3: 3,
|
||||
H4: 4,
|
||||
H5: 5,
|
||||
H6: 6
|
||||
}; // explicit aria-level value
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#aria-level
|
||||
|
||||
const ariaLevelAttribute = element.getAttribute('aria-level') && Number(element.getAttribute('aria-level'));
|
||||
return ariaLevelAttribute || implicitHeadingLevels[element.tagName];
|
||||
}
|
63
web/node_modules/@testing-library/dom/dist/screen.js
generated
vendored
Normal file
63
web/node_modules/@testing-library/dom/dist/screen.js
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.screen = void 0;
|
||||
|
||||
var _lzString = require("lz-string");
|
||||
|
||||
var queries = _interopRequireWildcard(require("./queries"));
|
||||
|
||||
var _getQueriesForElement = require("./get-queries-for-element");
|
||||
|
||||
var _prettyDom = require("./pretty-dom");
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
|
||||
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; }
|
||||
|
||||
function unindent(string) {
|
||||
// remove white spaces first, to save a few bytes.
|
||||
// testing-playground will reformat on load any ways.
|
||||
return string.replace(/[ \t]*[\n][ \t]*/g, '\n');
|
||||
}
|
||||
|
||||
function encode(value) {
|
||||
return (0, _lzString.compressToEncodedURIComponent)(unindent(value));
|
||||
}
|
||||
|
||||
function getPlaygroundUrl(markup) {
|
||||
return `https://testing-playground.com/#markup=${encode(markup)}`;
|
||||
}
|
||||
|
||||
const debug = (element, maxLength, options) => Array.isArray(element) ? element.forEach(el => (0, _prettyDom.logDOM)(el, maxLength, options)) : (0, _prettyDom.logDOM)(element, maxLength, options);
|
||||
|
||||
const logTestingPlaygroundURL = (element = (0, _helpers.getDocument)().body) => {
|
||||
if (!element || !('innerHTML' in element)) {
|
||||
console.log(`The element you're providing isn't a valid DOM element.`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!element.innerHTML) {
|
||||
console.log(`The provided element doesn't have any children.`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Open this URL in your browser\n\n${getPlaygroundUrl(element.innerHTML)}`);
|
||||
};
|
||||
|
||||
const initialValue = {
|
||||
debug,
|
||||
logTestingPlaygroundURL
|
||||
};
|
||||
const screen = typeof document !== 'undefined' && document.body ? (0, _getQueriesForElement.getQueriesForElement)(document.body, queries, initialValue) : Object.keys(queries).reduce((helpers, key) => {
|
||||
helpers[key] = () => {
|
||||
throw new TypeError('For queries bound to document.body a global document has to be available... Learn more: https://testing-library.com/s/screen-global-error');
|
||||
};
|
||||
|
||||
return helpers;
|
||||
}, initialValue);
|
||||
exports.screen = screen;
|
8
web/node_modules/@testing-library/dom/dist/shared.js
generated
vendored
Normal file
8
web/node_modules/@testing-library/dom/dist/shared.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.DEFAULT_IGNORE_TAGS = void 0;
|
||||
const DEFAULT_IGNORE_TAGS = 'script, style';
|
||||
exports.DEFAULT_IGNORE_TAGS = DEFAULT_IGNORE_TAGS;
|
156
web/node_modules/@testing-library/dom/dist/suggestions.js
generated
vendored
Normal file
156
web/node_modules/@testing-library/dom/dist/suggestions.js
generated
vendored
Normal file
|
@ -0,0 +1,156 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getSuggestedQuery = getSuggestedQuery;
|
||||
|
||||
var _domAccessibilityApi = require("dom-accessibility-api");
|
||||
|
||||
var _matches = require("./matches");
|
||||
|
||||
var _getNodeText = require("./get-node-text");
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
var _roleHelpers = require("./role-helpers");
|
||||
|
||||
var _labelHelpers = require("./label-helpers");
|
||||
|
||||
var _shared = require("./shared");
|
||||
|
||||
const normalize = (0, _matches.getDefaultNormalizer)();
|
||||
|
||||
function escapeRegExp(string) {
|
||||
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||
}
|
||||
|
||||
function getRegExpMatcher(string) {
|
||||
return new RegExp(escapeRegExp(string.toLowerCase()), 'i');
|
||||
}
|
||||
|
||||
function makeSuggestion(queryName, element, content, {
|
||||
variant,
|
||||
name
|
||||
}) {
|
||||
let warning = '';
|
||||
const queryOptions = {};
|
||||
const queryArgs = [['Role', 'TestId'].includes(queryName) ? content : getRegExpMatcher(content)];
|
||||
|
||||
if (name) {
|
||||
queryOptions.name = getRegExpMatcher(name);
|
||||
}
|
||||
|
||||
if (queryName === 'Role' && (0, _roleHelpers.isInaccessible)(element)) {
|
||||
queryOptions.hidden = true;
|
||||
warning = `Element is inaccessible. This means that the element and all its children are invisible to screen readers.
|
||||
If you are using the aria-hidden prop, make sure this is the right choice for your case.
|
||||
`;
|
||||
}
|
||||
|
||||
if (Object.keys(queryOptions).length > 0) {
|
||||
queryArgs.push(queryOptions);
|
||||
}
|
||||
|
||||
const queryMethod = `${variant}By${queryName}`;
|
||||
return {
|
||||
queryName,
|
||||
queryMethod,
|
||||
queryArgs,
|
||||
variant,
|
||||
warning,
|
||||
|
||||
toString() {
|
||||
if (warning) {
|
||||
console.warn(warning);
|
||||
}
|
||||
|
||||
let [text, options] = queryArgs;
|
||||
text = typeof text === 'string' ? `'${text}'` : text;
|
||||
options = options ? `, { ${Object.entries(options).map(([k, v]) => `${k}: ${v}`).join(', ')} }` : '';
|
||||
return `${queryMethod}(${text}${options})`;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
function canSuggest(currentMethod, requestedMethod, data) {
|
||||
return data && (!requestedMethod || requestedMethod.toLowerCase() === currentMethod.toLowerCase());
|
||||
}
|
||||
|
||||
function getSuggestedQuery(element, variant = 'get', method) {
|
||||
var _element$getAttribute, _getImplicitAriaRoles;
|
||||
|
||||
// don't create suggestions for script and style elements
|
||||
if (element.matches(_shared.DEFAULT_IGNORE_TAGS)) {
|
||||
return undefined;
|
||||
} //We prefer to suggest something else if the role is generic
|
||||
|
||||
|
||||
const role = (_element$getAttribute = element.getAttribute('role')) != null ? _element$getAttribute : (_getImplicitAriaRoles = (0, _roleHelpers.getImplicitAriaRoles)(element)) == null ? void 0 : _getImplicitAriaRoles[0];
|
||||
|
||||
if (role !== 'generic' && canSuggest('Role', method, role)) {
|
||||
return makeSuggestion('Role', element, role, {
|
||||
variant,
|
||||
name: (0, _domAccessibilityApi.computeAccessibleName)(element, {
|
||||
computedStyleSupportsPseudoElements: (0, _config.getConfig)().computedStyleSupportsPseudoElements
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
const labelText = (0, _labelHelpers.getLabels)(document, element).map(label => label.content).join(' ');
|
||||
|
||||
if (canSuggest('LabelText', method, labelText)) {
|
||||
return makeSuggestion('LabelText', element, labelText, {
|
||||
variant
|
||||
});
|
||||
}
|
||||
|
||||
const placeholderText = element.getAttribute('placeholder');
|
||||
|
||||
if (canSuggest('PlaceholderText', method, placeholderText)) {
|
||||
return makeSuggestion('PlaceholderText', element, placeholderText, {
|
||||
variant
|
||||
});
|
||||
}
|
||||
|
||||
const textContent = normalize((0, _getNodeText.getNodeText)(element));
|
||||
|
||||
if (canSuggest('Text', method, textContent)) {
|
||||
return makeSuggestion('Text', element, textContent, {
|
||||
variant
|
||||
});
|
||||
}
|
||||
|
||||
if (canSuggest('DisplayValue', method, element.value)) {
|
||||
return makeSuggestion('DisplayValue', element, normalize(element.value), {
|
||||
variant
|
||||
});
|
||||
}
|
||||
|
||||
const alt = element.getAttribute('alt');
|
||||
|
||||
if (canSuggest('AltText', method, alt)) {
|
||||
return makeSuggestion('AltText', element, alt, {
|
||||
variant
|
||||
});
|
||||
}
|
||||
|
||||
const title = element.getAttribute('title');
|
||||
|
||||
if (canSuggest('Title', method, title)) {
|
||||
return makeSuggestion('Title', element, title, {
|
||||
variant
|
||||
});
|
||||
}
|
||||
|
||||
const testId = element.getAttribute((0, _config.getConfig)().testIdAttribute);
|
||||
|
||||
if (canSuggest('TestId', method, testId)) {
|
||||
return makeSuggestion('TestId', element, testId, {
|
||||
variant
|
||||
});
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
63
web/node_modules/@testing-library/dom/dist/wait-for-element-to-be-removed.js
generated
vendored
Normal file
63
web/node_modules/@testing-library/dom/dist/wait-for-element-to-be-removed.js
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.waitForElementToBeRemoved = waitForElementToBeRemoved;
|
||||
|
||||
var _waitFor = require("./wait-for");
|
||||
|
||||
const isRemoved = result => !result || Array.isArray(result) && !result.length; // Check if the element is not present.
|
||||
// As the name implies, waitForElementToBeRemoved should check `present` --> `removed`
|
||||
|
||||
|
||||
function initialCheck(elements) {
|
||||
if (isRemoved(elements)) {
|
||||
throw new 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, options) {
|
||||
// created here so we get a nice stacktrace
|
||||
const timeoutError = new Error('Timed out in waitForElementToBeRemoved.');
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
initialCheck(callback);
|
||||
const elements = Array.isArray(callback) ? callback : [callback];
|
||||
const getRemainingElements = elements.map(element => {
|
||||
let parent = element.parentElement;
|
||||
if (parent === null) return () => null;
|
||||
|
||||
while (parent.parentElement) parent = parent.parentElement;
|
||||
|
||||
return () => parent.contains(element) ? element : null;
|
||||
});
|
||||
|
||||
callback = () => getRemainingElements.map(c => c()).filter(Boolean);
|
||||
}
|
||||
|
||||
initialCheck(callback());
|
||||
return (0, _waitFor.waitFor)(() => {
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = callback();
|
||||
} catch (error) {
|
||||
if (error.name === 'TestingLibraryElementError') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!isRemoved(result)) {
|
||||
throw timeoutError;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}, options);
|
||||
}
|
||||
/*
|
||||
eslint
|
||||
require-await: "off"
|
||||
*/
|
184
web/node_modules/@testing-library/dom/dist/wait-for.js
generated
vendored
Normal file
184
web/node_modules/@testing-library/dom/dist/wait-for.js
generated
vendored
Normal file
|
@ -0,0 +1,184 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.waitFor = waitForWrapper;
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
var _config = require("./config");
|
||||
|
||||
// This is so the stack trace the developer sees is one that's
|
||||
// closer to their code (because async stack traces are hard to follow).
|
||||
function copyStackTrace(target, source) {
|
||||
target.stack = source.stack.replace(source.message, target.message);
|
||||
}
|
||||
|
||||
function waitFor(callback, {
|
||||
container = (0, _helpers.getDocument)(),
|
||||
timeout = (0, _config.getConfig)().asyncUtilTimeout,
|
||||
showOriginalStackTrace = (0, _config.getConfig)().showOriginalStackTrace,
|
||||
stackTraceError,
|
||||
interval = 50,
|
||||
onTimeout = error => {
|
||||
error.message = (0, _config.getConfig)().getElementError(error.message, container).message;
|
||||
return error;
|
||||
},
|
||||
mutationObserverOptions = {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
attributes: true,
|
||||
characterData: true
|
||||
}
|
||||
}) {
|
||||
if (typeof callback !== 'function') {
|
||||
throw new TypeError('Received `callback` arg must be a function');
|
||||
}
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let lastError, intervalId, observer;
|
||||
let finished = false;
|
||||
let promiseStatus = 'idle';
|
||||
const overallTimeoutTimer = setTimeout(handleTimeout, timeout);
|
||||
const usingJestFakeTimers = (0, _helpers.jestFakeTimersAreEnabled)();
|
||||
|
||||
if (usingJestFakeTimers) {
|
||||
checkCallback(); // this is a dangerous rule to disable because it could lead to an
|
||||
// infinite loop. However, eslint isn't smart enough to know that we're
|
||||
// setting finished inside `onDone` which will be called when we're done
|
||||
// waiting or when we've timed out.
|
||||
// eslint-disable-next-line no-unmodified-loop-condition
|
||||
|
||||
while (!finished) {
|
||||
if (!(0, _helpers.jestFakeTimersAreEnabled)()) {
|
||||
const error = new 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`);
|
||||
if (!showOriginalStackTrace) copyStackTrace(error, stackTraceError);
|
||||
reject(error);
|
||||
return;
|
||||
} // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's
|
||||
// possible that could make this loop go on forever if someone is using
|
||||
// third party code that's setting up recursive timers so rapidly that
|
||||
// the user's timer's don't get a chance to resolve. So we'll advance
|
||||
// by an interval instead. (We have a test for this case).
|
||||
|
||||
|
||||
jest.advanceTimersByTime(interval); // It's really important that checkCallback is run *before* we flush
|
||||
// in-flight promises. To be honest, I'm not sure why, and I can't quite
|
||||
// think of a way to reproduce the problem in a test, but I spent
|
||||
// an entire day banging my head against a wall on this.
|
||||
|
||||
checkCallback(); // In this rare case, we *need* to wait for in-flight promises
|
||||
// to resolve before continuing. We don't need to take advantage
|
||||
// of parallelization so we're fine.
|
||||
// https://stackoverflow.com/a/59243586/971592
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
|
||||
await new Promise(r => {
|
||||
setTimeout(r, 0);
|
||||
jest.advanceTimersByTime(0);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
(0, _helpers.checkContainerType)(container);
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
return;
|
||||
}
|
||||
|
||||
intervalId = setInterval(checkRealTimersCallback, interval);
|
||||
const {
|
||||
MutationObserver
|
||||
} = (0, _helpers.getWindowFromNode)(container);
|
||||
observer = new MutationObserver(checkRealTimersCallback);
|
||||
observer.observe(container, mutationObserverOptions);
|
||||
checkCallback();
|
||||
}
|
||||
|
||||
function onDone(error, result) {
|
||||
finished = true;
|
||||
clearTimeout(overallTimeoutTimer);
|
||||
|
||||
if (!usingJestFakeTimers) {
|
||||
clearInterval(intervalId);
|
||||
observer.disconnect();
|
||||
}
|
||||
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
|
||||
function checkRealTimersCallback() {
|
||||
if ((0, _helpers.jestFakeTimersAreEnabled)()) {
|
||||
const error = new 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`);
|
||||
if (!showOriginalStackTrace) copyStackTrace(error, stackTraceError);
|
||||
return reject(error);
|
||||
} else {
|
||||
return checkCallback();
|
||||
}
|
||||
}
|
||||
|
||||
function checkCallback() {
|
||||
if (promiseStatus === 'pending') return;
|
||||
|
||||
try {
|
||||
const result = (0, _config.runWithExpensiveErrorDiagnosticsDisabled)(callback);
|
||||
|
||||
if (typeof (result == null ? void 0 : result.then) === 'function') {
|
||||
promiseStatus = 'pending';
|
||||
result.then(resolvedValue => {
|
||||
promiseStatus = 'resolved';
|
||||
onDone(null, resolvedValue);
|
||||
}, rejectedValue => {
|
||||
promiseStatus = 'rejected';
|
||||
lastError = rejectedValue;
|
||||
});
|
||||
} else {
|
||||
onDone(null, result);
|
||||
} // If `callback` throws, wait for the next mutation, interval, or timeout.
|
||||
|
||||
} catch (error) {
|
||||
// Save the most recent callback error to reject the promise with it in the event of a timeout
|
||||
lastError = error;
|
||||
}
|
||||
}
|
||||
|
||||
function handleTimeout() {
|
||||
let error;
|
||||
|
||||
if (lastError) {
|
||||
error = lastError;
|
||||
|
||||
if (!showOriginalStackTrace && error.name === 'TestingLibraryElementError') {
|
||||
copyStackTrace(error, stackTraceError);
|
||||
}
|
||||
} else {
|
||||
error = new Error('Timed out in waitFor.');
|
||||
|
||||
if (!showOriginalStackTrace) {
|
||||
copyStackTrace(error, stackTraceError);
|
||||
}
|
||||
}
|
||||
|
||||
onDone(onTimeout(error), null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function waitForWrapper(callback, options) {
|
||||
// create the error here so its stack trace is as close to the
|
||||
// calling code as possible
|
||||
const stackTraceError = new Error('STACK_TRACE_MESSAGE');
|
||||
return (0, _config.getConfig)().asyncWrapper(() => waitFor(callback, {
|
||||
stackTraceError,
|
||||
...options
|
||||
}));
|
||||
}
|
||||
/*
|
||||
eslint
|
||||
max-lines-per-function: ["error", {"max": 200}],
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue