@nova-ui/bits
Version:
SolarWinds Nova Framework
120 lines • 5.81 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.PanelAtom = void 0;
const tslib_1 = require("tslib");
const protractor_1 = require("protractor");
const atom_1 = require("../../atom");
const icon_atom_1 = require("../icon/icon.atom");
class PanelAtom extends atom_1.Atom {
constructor() {
super(...arguments);
this.toggleElement = this.getElement().element(protractor_1.by.className(PanelAtom.HEADER_BUTTON_TOGGLE));
this.getToggleIcon = () => atom_1.Atom.findIn(icon_atom_1.IconAtom, this.toggleElement);
this.isToggleIconPresent = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return yield this.toggleElement.isPresent(); });
this.toggleExpanded = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
const expanded = yield this.isExpanded();
yield this.toggleElement.click();
// Wait for animation to finish
return protractor_1.browser.wait(() => tslib_1.__awaiter(this, void 0, void 0, function* () { return (yield this.isExpanded()) === !expanded; }), 1000, "Animation timed out");
});
this.closeSidePane = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
return yield this.getElement()
.element(protractor_1.by.className(PanelAtom.HEADER_BUTTON_CLOSE))
.click();
});
this.hoverOnSidePane = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
yield protractor_1.browser
.actions()
.mouseMove(this.getElement().element(protractor_1.by.css(`${atom_1.Atom.getSelector(PanelAtom)} .${PanelAtom.SIDE_PANE_CSS}`)))
.perform();
});
this.isHeaderDisplayed = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getHeaderContent().isDisplayed(); });
this.isFooterDisplayed = () => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.getFooterContent().isDisplayed(); });
}
getCenterPaneElementSize() {
const _super = Object.create(null, {
getElement: { get: () => super.getElement }
});
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return _super.getElement.call(this)
.element(protractor_1.by.className(PanelAtom.CENTER_PANE_CSS))
.getSize();
});
}
getSidePaneElementSize() {
const _super = Object.create(null, {
getElement: { get: () => super.getElement }
});
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return _super.getElement.call(this)
.element(protractor_1.by.className(PanelAtom.SIDE_PANE_CSS))
.getSize();
});
}
isPaneDisplayed(orientation) {
const _super = Object.create(null, {
getElement: { get: () => super.getElement }
});
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return _super.getElement.call(this)
.element(protractor_1.by.css(`.${PanelAtom.CSS_CLASS}--${orientation} .${PanelAtom.SIDE_PANE_CSS}`))
.isDisplayed();
});
}
isCollapsed() {
const _super = Object.create(null, {
hasClass: { get: () => super.hasClass }
});
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return _super.hasClass.call(this, PanelAtom.COLLAPSED_CSS);
});
}
isExpanded() {
const _super = Object.create(null, {
hasClass: { get: () => super.hasClass }
});
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return _super.hasClass.call(this, PanelAtom.COLLAPSED_CSS)
.then((value) => !value);
});
}
getHeaderContent() {
return super
.getElement()
.element(protractor_1.by.className(PanelAtom.HEADER_CONTENT_CSS));
}
getFooterContent() {
return super
.getElement()
.element(protractor_1.by.className(PanelAtom.FOOTER_CONTENT_CSS));
}
}
exports.PanelAtom = PanelAtom;
PanelAtom.CSS_CLASS = "nui-panel";
PanelAtom.COLLAPSED_CSS = "nui-panel--is-collapsed";
PanelAtom.HEADER_BUTTON_TOGGLE = "nui-panel__header-btn";
PanelAtom.HEADER_BUTTON_CLOSE = "nui-panel__header-btn--close";
PanelAtom.HEADER_CONTENT_CSS = "nui-panel__header";
PanelAtom.SIDE_PANE_CSS = "nui-panel__side-pane";
PanelAtom.CENTER_PANE_CSS = "nui-panel__center-pane";
PanelAtom.FOOTER_CONTENT_CSS = "nui-panel__footer";
//# sourceMappingURL=panel.atom.js.map