UNPKG

moh-common-lib

Version:

A library of Angular components, services, and styles for B.C. Government Ministry of Health (MoH).

413 lines (408 loc) 15.1 kB
import { __awaiter, __generator } from 'tslib'; import { browser, by, element, $$, protractor } from 'protractor'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * AbstractTestPage provides common functionality for e2e tests that make use of * the MoH Common Lib. For example, `getNameComponent()` and * `getNameComponentVal()` both correspond to the NameComponent. * @abstract */ var /** * AbstractTestPage provides common functionality for e2e tests that make use of * the MoH Common Lib. For example, `getNameComponent()` and * `getNameComponentVal()` both correspond to the NameComponent. * @abstract */ AbstractTestPage = /** @class */ (function () { function AbstractTestPage() { /** * Clicking this button should complete the page, navigate to the next one. * We default it to `.form-bar .submit` but you may overwrite as necessary. */ this.continueButton = element(by.css('.form-bar .submit')); /** * This is the 'Skip To Content' button for Screen Readers that appears when * tabbed to. May be overwritten as necessary. */ this.skipToContentButton = element(by.css('.skip-to-content')); } /** * @return {?} */ AbstractTestPage.prototype.continue = /** * @return {?} */ function () { this.continueButton.click(); }; /** * @return {?} */ AbstractTestPage.prototype.getContinueButton = /** * @return {?} */ function () { return this.continueButton; }; /** Scrolls down to the bottom of the page */ /** * Scrolls down to the bottom of the page * @return {?} */ AbstractTestPage.prototype.scrollDown = /** * Scrolls down to the bottom of the page * @return {?} */ function () { browser.executeScript('window.scrollTo(0, document.body.scrollHeight)'); }; /** * @return {?} */ AbstractTestPage.prototype.clickSkipToContent = /** * @return {?} */ function () { this.skipToContentButton.click(); }; /** * **NameComponent** - Returns the NameComponent for an associated human * readable label. If the label is a duplicate it will grab the first one * only. * * TODO: Update to "common-name" component when it's imported from PRIME * * @param labelName Human redable label name. */ /** * **NameComponent** - Returns the NameComponent for an associated human * readable label. If the label is a duplicate it will grab the first one * only. * * TODO: Update to "common-name" component when it's imported from PRIME * * @param {?} labelName Human redable label name. * @return {?} */ AbstractTestPage.prototype.getNameComponent = /** * **NameComponent** - Returns the NameComponent for an associated human * readable label. If the label is a duplicate it will grab the first one * only. * * TODO: Update to "common-name" component when it's imported from PRIME * * @param {?} labelName Human redable label name. * @return {?} */ function (labelName) { return __awaiter(this, void 0, void 0, function () { var label, _a, _b, _c; return __generator(this, function (_d) { switch (_d.label) { case 0: label = element.all(by.cssContainingText('lib-prime-name label', labelName)).first(); _a = element; _c = (_b = by).id; return [4 /*yield*/, label.getAttribute('for')]; case 1: return [2 /*return*/, _a.apply(void 0, [_c.apply(_b, [_d.sent()])])]; } }); }); }; /** * **NameComponent** - Returns the value within a given NameComponent * * TODO: Update to "common-name" component when it's imported from PRIME * * @param labelName Human readable label name */ /** * **NameComponent** - Returns the value within a given NameComponent * * TODO: Update to "common-name" component when it's imported from PRIME * * @param {?} labelName Human readable label name * @return {?} */ AbstractTestPage.prototype.getNameComponentVal = /** * **NameComponent** - Returns the value within a given NameComponent * * TODO: Update to "common-name" component when it's imported from PRIME * * @param {?} labelName Human readable label name * @return {?} */ function (labelName) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getNameComponent(labelName)]; case 1: return [2 /*return*/, (_a.sent()).getAttribute('value')]; } }); }); }; /** * @return {?} */ AbstractTestPage.prototype.formErrors = /** * @return {?} */ function () { return $$('[role=alert] .text-danger'); }; /** * Selects from an ng-select component. This includes DropdownComponent * others, like country, province, etc. * * TODO - Need to test this works! Right now just copied from GitHub with * minor tweaks. IDEA - Mirror getNameComponent, where we lookup via the label * text and use the 'for' attribute. * * @param labelId corresponds to labelForId on the <ng-select> * @param optionText the option we want to select */ /** * Selects from an ng-select component. This includes DropdownComponent * others, like country, province, etc. * * TODO - Need to test this works! Right now just copied from GitHub with * minor tweaks. IDEA - Mirror getNameComponent, where we lookup via the label * text and use the 'for' attribute. * * @param {?} labelId corresponds to labelForId on the <ng-select> * @param {?} optionText the option we want to select * @return {?} */ AbstractTestPage.prototype.selectOption = /** * Selects from an ng-select component. This includes DropdownComponent * others, like country, province, etc. * * TODO - Need to test this works! Right now just copied from GitHub with * minor tweaks. IDEA - Mirror getNameComponent, where we lookup via the label * text and use the 'for' attribute. * * @param {?} labelId corresponds to labelForId on the <ng-select> * @param {?} optionText the option we want to select * @return {?} */ function (labelId, optionText) { element(by.css("ng-select[id=\"" + labelId + "\"]")).click(); // opens dropdown element(by.cssContainingText('span.ng-option-label', optionText)).click(); // selects option by provided text }; /** * Works on same NgSelect components but it sends custom text instead of * selecting a given choice. * @param labelId corresponds to labelForId on the <ng-select> * @param data the text we want to type */ /** * Works on same NgSelect components but it sends custom text instead of * selecting a given choice. * @param {?} labelId corresponds to labelForId on the <ng-select> * @param {?} data the text we want to type * @return {?} */ AbstractTestPage.prototype.typeOption = /** * Works on same NgSelect components but it sends custom text instead of * selecting a given choice. * @param {?} labelId corresponds to labelForId on the <ng-select> * @param {?} data the text we want to type * @return {?} */ function (labelId, data) { element(by.css("ng-select[id=\"" + labelId + "\"]")).click(); // opens dropdown element(by.css("input[role=\"combobox\"]")).sendKeys(data); // type option browser.actions().sendKeys(protractor.Key.ENTER).perform(); // hit enter key }; /** * Enter text into an input via ng-reflect-name component * @param refNameVal Value of ng-reflect-name component * @param text Text to enter into the input */ /** * Enter text into an input via ng-reflect-name component * @param {?} refNameVal Value of ng-reflect-name component * @param {?} text Text to enter into the input * @return {?} */ AbstractTestPage.prototype.typeText = /** * Enter text into an input via ng-reflect-name component * @param {?} refNameVal Value of ng-reflect-name component * @param {?} text Text to enter into the input * @return {?} */ function (refNameVal, text) { element(by.css("input[ng-reflect-name^=\"" + refNameVal + "\"]")).sendKeys(text); }; /** * Clicks the button based on the text specified * @param classVal Human readable class value for a button * @param text Text inside the button */ /** * Clicks the button based on the text specified * @param {?} classVal Human readable class value for a button * @param {?} text Text inside the button * @return {?} */ AbstractTestPage.prototype.clickButton = /** * Clicks the button based on the text specified * @param {?} classVal Human readable class value for a button * @param {?} text Text inside the button * @return {?} */ function (classVal, text) { element(by.cssContainingText("button[class*=\"" + classVal + "\"]", text)).click(); }; /** * Clicks the check box based on the ng-reflect-name component * @param refNameVal Value of ng-reflect-name component */ /** * Clicks the check box based on the ng-reflect-name component * @param {?} refNameVal Value of ng-reflect-name component * @return {?} */ AbstractTestPage.prototype.clickCheckBox = /** * Clicks the check box based on the ng-reflect-name component * @param {?} refNameVal Value of ng-reflect-name component * @return {?} */ function (refNameVal) { element(by.css("input[ng-reflect-name=\"" + refNameVal + "\"]")).click(); }; /** * Clicks the checkbox which means the user agrees with the info collection notice. * InfoColectionNoticeComponent <common-collection-modal> */ /** * Clicks the checkbox which means the user agrees with the info collection notice. * InfoColectionNoticeComponent <common-collection-modal> * @return {?} */ AbstractTestPage.prototype.agreeConsentModal = /** * Clicks the checkbox which means the user agrees with the info collection notice. * InfoColectionNoticeComponent <common-collection-modal> * @return {?} */ function () { element(by.css('label[for="agree"]')).element(by.css('strong')).click(); }; /** * Clicks continue inside the modal * InfoColectionNoticeComponent <common-collection-modal> */ /** * Clicks continue inside the modal * InfoColectionNoticeComponent <common-collection-modal> * @return {?} */ AbstractTestPage.prototype.clickConsentModalContinue = /** * Clicks continue inside the modal * InfoColectionNoticeComponent <common-collection-modal> * @return {?} */ function () { element(by.css('div[class="modal-footer"]')).element(by.css('button[type="submit"]')).click(); }; /** * Checks if the consent modal is currently displayed or not */ /** * Checks if the consent modal is currently displayed or not * @return {?} */ AbstractTestPage.prototype.checkConsentModal = /** * Checks if the consent modal is currently displayed or not * @return {?} */ function () { return element(by.css('common-consent-modal')).element(by.css('div[aria-labelledby="myLargeModalLabel"]')).isDisplayed(); }; /** * Scrolls up to the top of the page */ /** * Scrolls up to the top of the page * @return {?} */ AbstractTestPage.prototype.scrollUp = /** * Scrolls up to the top of the page * @return {?} */ function () { browser.executeScript('window.scrollTo(0,0)'); }; /** * Types the text inside the first ocurrence of input field * @param refNameVal Value of ng-reflect-name component * @param text Text to enter into the input */ /** * Types the text inside the first ocurrence of input field * @param {?} refNameVal Value of ng-reflect-name component * @param {?} text Text to enter into the input * @return {?} */ AbstractTestPage.prototype.typeTextFirstOccurrence = /** * Types the text inside the first ocurrence of input field * @param {?} refNameVal Value of ng-reflect-name component * @param {?} text Text to enter into the input * @return {?} */ function (refNameVal, text) { element.all(by.css("input[ng-reflect-name^=\"" + refNameVal + "\"]")).first().sendKeys(text); }; /** * Clicks the link based from the label and text provided * @param label * @param text */ /** * Clicks the link based from the label and text provided * @param {?} label * @param {?} text * @return {?} */ AbstractTestPage.prototype.clickLink = /** * Clicks the link based from the label and text provided * @param {?} label * @param {?} text * @return {?} */ function (label, text) { element(by.cssContainingText(label, text)).click(); }; /** * Counts the number of options inside a dropdown box * @param refNameVal */ /** * Counts the number of options inside a dropdown box * @param {?} refNameVal * @return {?} */ AbstractTestPage.prototype.countLength = /** * Counts the number of options inside a dropdown box * @param {?} refNameVal * @return {?} */ function (refNameVal) { return $$("select[ng-reflect-name^=\"" + refNameVal + "\"] option"); }; return AbstractTestPage; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { AbstractTestPage }; //# sourceMappingURL=moh-common-lib-e2e.js.map