@nova-ui/bits
Version:
SolarWinds Nova Framework
91 lines • 4.91 kB
JavaScript
"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.WizardAtom = void 0;
const tslib_1 = require("tslib");
const protractor_1 = require("protractor");
const atom_1 = require("../../atom");
const button_atom_1 = require("../button/button.atom");
const wizard_step_atom_1 = require("../wizard/wizard-step.atom");
class WizardAtom extends atom_1.Atom {
constructor() {
super(...arguments);
this.root = this.getElement();
this.backButton = new button_atom_1.ButtonAtom(this.root.element(protractor_1.by.className("nui-wizard__back-button")));
this.nextButton = new button_atom_1.ButtonAtom(this.root.element(protractor_1.by.className("nui-wizard__next-button")));
this.finishButton = new button_atom_1.ButtonAtom(this.root.element(protractor_1.by.className("nui-wizard__finish-button")));
this.cancelButton = new button_atom_1.ButtonAtom(this.root.element(protractor_1.by.className("nui-wizard__cancel-button")));
this.back = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.backButton.click(); });
this.cancel = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.cancelButton.click(); });
this.finish = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.finishButton.click(); });
this.getHeader = () => this.root.element(protractor_1.by.css(".nui-wizard__header"));
this.getActiveStep = () => this.root.element(protractor_1.by.css(".nui-wizard__header-step--active"));
this.next = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.nextButton.click(); });
}
getHeaderSteps() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const stepsEl = this.root.element(protractor_1.by.className("nui-wizard__header-steps"));
return stepsEl
.all(protractor_1.by.className("nui-wizard__header-step"))
.map((el) => tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!el) {
throw new Error("elementFinder is not defined");
}
return el
.all(protractor_1.by.className("nui-wizard__header-step-title"))
.first()
.getText();
}));
});
}
getSteps() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const stepsEl = this.root.element(protractor_1.by.className("nui-wizard__header"));
// this should really be a map operation. However, map has a bug- if you put an element finder
// in it, it will try to resolve EVERYTHING, and causes node to go into an infinite loop
return stepsEl
.all(protractor_1.by.className("nui-wizard__header-step-container"))
.reduce((accumulator, el) => {
accumulator.push(new wizard_step_atom_1.WizardStepAtom(el));
return accumulator;
}, []);
});
}
getContainerHeight() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.root
.element(protractor_1.by.className("nui-wizard__container"))
.getSize()
.then((elemSize) => elemSize.height);
});
}
goToStep(index) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.root
.all(protractor_1.by.className("nui-wizard__header-step"))
.get(index)
.click();
});
}
}
exports.WizardAtom = WizardAtom;
WizardAtom.CSS_CLASS = "nui-wizard";
//# sourceMappingURL=wizard.atom.js.map