Website : rimsha.abasa.com
backdoor
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
canvas
/
node_modules
/
@instructure
/
ui-test-locator
/
lib
/
utils
/
Filename :
locator.js
back
Copy
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.locator = locator; var _uiTestQueries = require("@instructure/ui-test-queries"); /* * The MIT License (MIT) * * Copyright (c) 2015 - present Instructure, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ function locator(containerSelector, customMethods = {}) { const queryAll = (element, selector, options) => { return (0, _uiTestQueries.querySelectorAllWithin)(containerSelector, element, selector, options); }; queryAll.displayName = containerSelector; const query = (...args) => { // @ts-expect-error ...args should be refactored for better typing return (0, _uiTestQueries.firstOrNull)(queryAll(...args)); }; const findAll = (...args) => { const _parseQueryArguments = (0, _uiTestQueries.parseQueryArguments)(...args), element = _parseQueryArguments.element, selector = _parseQueryArguments.selector, options = _parseQueryArguments.options; // this could be typed better. findAllByQuery should be generic, accepting // customMethods as a generic param. return (0, _uiTestQueries.findAllByQuery)(queryAll, element, selector, { ...options, customMethods: { ...customMethods, ...options.customMethods } // Adding here the generic T argument makes TS able to autocomplete custom // methods (if they are a compile time constant) // Typing this properly would require to make QueryArguments generic, // which would introduce a tons of complexity, so a refactor of this // library would be preferred. }); }; const find = async (...args) => { return (0, _uiTestQueries.firstOrNull)(await findAll(...args)); }; const findWithText = (...args) => { const _parseQueryArguments2 = (0, _uiTestQueries.parseQueryArguments)(...args), element = _parseQueryArguments2.element, selector = _parseQueryArguments2.selector, options = _parseQueryArguments2.options; return find(element, `:withText("${selector}")`, options); }; const findWithLabel = (...args) => { const _parseQueryArguments3 = (0, _uiTestQueries.parseQueryArguments)(...args), element = _parseQueryArguments3.element, selector = _parseQueryArguments3.selector, options = _parseQueryArguments3.options; return find(element, `:withLabel("${selector}")`, options); }; const methods = {}; Object.keys(customMethods).forEach(methodKey => { methods[methodKey] = async (...args) => { const _parseQueryArguments4 = (0, _uiTestQueries.parseQueryArguments)(...args), element = _parseQueryArguments4.element, selector = _parseQueryArguments4.selector, options = _parseQueryArguments4.options; const container = await find(element); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return container ? container[methodKey](selector, options) : null; }; }); return { customMethods, selector: containerSelector, query, queryAll, findAll, find, findWithText, findWithLabel, ...methods }; }