UNPKG

@nova-ui/bits

Version:

SolarWinds Nova Framework

100 lines 4.83 kB
"use strict"; // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // 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. Object.defineProperty(exports, "__esModule", { value: true }); exports.ComboboxV2Atom = void 0; const tslib_1 = require("tslib"); const isNil_1 = tslib_1.__importDefault(require("lodash/isNil")); const protractor_1 = require("protractor"); const atom_1 = require("../../atom"); const icon_atom_1 = require("../icon/icon.atom"); const overlay_atom_1 = require("../overlay/overlay.atom"); const base_select_v2_atom_1 = require("../select-v2/base-select-v2.atom"); class ComboboxV2Atom extends base_select_v2_atom_1.BaseSelectV2Atom { constructor() { super(...arguments); this.popup = atom_1.Atom.findIn(overlay_atom_1.OverlayAtom, (0, protractor_1.element)(protractor_1.by.className("combobox-v2-test-pane"))); this.removeAllButton = this.getElement().element(protractor_1.by.className("nui-combobox-v2__remove-value")); this.createOption = this.getPopupElement().element(protractor_1.by.className("nui-combobox-v2__create-option")); this.toggleButton = this.getElement().element(protractor_1.by.className("nui-combobox-v2__toggle")); this.chips = this.getElement().all(protractor_1.by.css("nui-chip")); this.activeChip = this.getElement().element(protractor_1.by.css("nui-chip.active")); this.activeOption = this.getPopupElement().element(protractor_1.by.css("nui-select-v2-option.active")); } static type(text) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return protractor_1.browser.actions().sendKeys(text).perform(); }); } removeAll() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.removeAllButton.click(); }); } removeChips(amount) { return tslib_1.__awaiter(this, void 0, void 0, function* () { this.chips.each((chip, i) => tslib_1.__awaiter(this, void 0, void 0, function* () { if (!chip || (0, isNil_1.default)(i)) { throw new Error("chip is not defined"); } if (amount > i) { yield atom_1.Atom.findIn(icon_atom_1.IconAtom, chip).getElement().click(); } })); }); } selectAll() { return tslib_1.__awaiter(this, void 0, void 0, function* () { yield this.selectFirst(yield this.countOptions()); }); } selectFirst(numberOfItems) { return tslib_1.__awaiter(this, void 0, void 0, function* () { let index = numberOfItems || 1; while (index > 0) { index--; yield (yield this.getOption(index)).click(); } }); } getInputValue() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.input.getAttribute("value"); }); } getSelectionStart() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield protractor_1.browser.executeScript("return arguments[0].selectionStart", yield this.input.getWebElement()); }); } getSelectionEnd() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield protractor_1.browser.executeScript("return arguments[0].selectionEnd", yield this.input.getWebElement()); }); } getSelectionRange() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return ((yield this.getSelectionEnd()) - (yield this.getSelectionStart())); }); } } exports.ComboboxV2Atom = ComboboxV2Atom; ComboboxV2Atom.CSS_CLASS = "nui-combobox-v2"; //# sourceMappingURL=combobox-v2.atom.js.map