Skip to content

Commit

Permalink
[ADF-5463] Rework Protractor tests - changes related to element/eleme…
Browse files Browse the repository at this point in the history
…nt… (#7284)

* ADF-5463 Rework Protractor tests - changes related to element/elements and duplication of locators

* Fix one which I missed

* Remove console.logs

* Remove console.logs

* Reverse the timeouts

* Fixed things TSLint

* Remove unused import

* Fixed broken tests

* Last test fixed
  • Loading branch information
MichalFidor committed Oct 8, 2021
1 parent db6a638 commit 1e62b46
Show file tree
Hide file tree
Showing 156 changed files with 1,672 additions and 1,666 deletions.
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { by, element } from 'protractor';
import { $ } from 'protractor';
import { createApiService,
BreadcrumbPage,
BreadcrumbDropdownPage,
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('Document List Component - Actions', () => {
const usersActions = new UsersActions(apiService);

const uploadActions = new UploadActions(apiService);
const infinitePaginationPage = new InfinitePaginationPage(element(by.css('adf-content-node-selector')));
const infinitePaginationPage = new InfinitePaginationPage($('adf-content-node-selector'));

describe('Folder Actions - Copy and Move', () => {
const folderModel1 = new FolderModel({ name: StringUtil.generateRandomString() });
Expand Down
4 changes: 2 additions & 2 deletions e2e/content-services/pages/permissions.page.ts
Expand Up @@ -22,7 +22,7 @@ import {
DropdownPage,
TestElement
} from '@alfresco/adf-testing';
import { browser, by } from 'protractor';
import { browser } from 'protractor';

export class PermissionsPage {

Expand Down Expand Up @@ -55,7 +55,7 @@ export class PermissionsPage {
async clickRoleDropdownByUserOrGroupName(name: string): Promise<void> {
const row = this.dataTableComponentPage.getRow('Users and Groups', name);
await row.click();
await BrowserActions.click(row.element(by.css('[id="adf-select-role-permission"] .mat-select-trigger')));
await BrowserActions.click(row.$('[id="adf-select-role-permission"] .mat-select-trigger'));
await TestElement.byCss('.mat-select-panel').waitVisible();
}

Expand Down
4 changes: 2 additions & 2 deletions e2e/content-services/pages/social.page.ts
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

import { by, element } from 'protractor';
import { $ } from 'protractor';
import { BrowserActions } from '@alfresco/adf-testing';

export class SocialPage {

nodeIdField = element(by.css(`input[id="nodeId"]`));
nodeIdField = $(`input[id="nodeId"]`);

async getNodeIdFieldValue(): Promise<string> {
return BrowserActions.getInputValue(this.nodeIdField);
Expand Down
6 changes: 3 additions & 3 deletions e2e/content-services/pages/tag.page.ts
Expand Up @@ -15,13 +15,13 @@
* limitations under the License.
*/

import { element, by, protractor, browser } from 'protractor';
import { by, protractor, browser, $, $$ } from 'protractor';
import { BrowserActions, TestElement } from '@alfresco/adf-testing';

export class TagPage {

addTagButton = TestElement.byCss('#add-tag');
insertNodeIdElement = element(by.css('input[id="nodeId"]'));
insertNodeIdElement = $('input[id="nodeId"]');
newTagInput = TestElement.byCss('input[id="new-tag-text"]');
tagListRow = TestElement.byCss('adf-tag-node-actions-list mat-list-item');
tagListByNodeIdRow = TestElement.byCss('adf-tag-node-list mat-chip');
Expand All @@ -30,7 +30,7 @@ export class TagPage {
showDeleteButton = TestElement.byCss('#adf-remove-button-tag');
showMoreButton = TestElement.byCss('button[data-automation-id="show-more-tags"]');
showLessButton = TestElement.byCss('button[data-automation-id="show-fewer-tags"]');
tagsOnPage = element.all(by.css('div[class*="adf-list-tag"]'));
tagsOnPage = $$('div[class*="adf-list-tag"]');
confirmTag = TestElement.byCss('#adf-tag-node-send');

getNodeId(): Promise<string> {
Expand Down
16 changes: 8 additions & 8 deletions e2e/content-services/pages/tree-view.page.ts
Expand Up @@ -15,15 +15,15 @@
* limitations under the License.
*/

import { element, by, protractor } from 'protractor';
import { element, by, protractor, $, $$ } from 'protractor';
import { BrowserVisibility, BrowserActions } from '@alfresco/adf-testing';

export class TreeViewPage {

treeViewTitle = element(by.cssContainingText('app-tree-view div', 'TREE VIEW TEST'));
nodeIdInput = element(by.css('input[data-placeholder="Node Id"]'));
noNodeMessage = element(by.id('adf-tree-view-missing-node'));
nodesOnPage = element.all(by.css('mat-tree-node'));
nodeIdInput = $('input[data-placeholder="Node Id"]');
noNodeMessage = $('#adf-tree-view-missing-node');
nodesOnPage = $$('mat-tree-node');

async checkTreeViewTitleIsDisplayed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.treeViewTitle);
Expand All @@ -34,17 +34,17 @@ export class TreeViewPage {
}

async clickNode(nodeName: string): Promise<void> {
const node = element(by.css('mat-tree-node[id="' + nodeName + '-tree-child-node"] button'));
const node = $('mat-tree-node[id="' + nodeName + '-tree-child-node"] button');
await BrowserActions.click(node);
}

async checkNodeIsDisplayedAsClosed(nodeName: string): Promise<void> {
const node = element(by.css('mat-tree-node[id="' + nodeName + '-tree-child-node"][aria-expanded="false"]'));
const node = $('mat-tree-node[id="' + nodeName + '-tree-child-node"][aria-expanded="false"]');
await BrowserVisibility.waitUntilElementIsVisible(node);
}

async checkNodeIsDisplayedAsOpen(nodeName: string): Promise<void> {
const node = element(by.css('mat-tree-node[id="' + nodeName + '-tree-child-node"][aria-expanded="true"]'));
const node = $('mat-tree-node[id="' + nodeName + '-tree-child-node"][aria-expanded="true"]');
await BrowserVisibility.waitUntilElementIsVisible(node);
}

Expand All @@ -54,7 +54,7 @@ export class TreeViewPage {
}

async checkNodeIsNotDisplayed(nodeName: string): Promise<void> {
const node = element(by.id('' + nodeName + '-tree-child-node'));
const node = $('#' + nodeName + '-tree-child-node');
await BrowserVisibility.waitUntilElementIsNotVisible(node);
}

Expand Down
58 changes: 29 additions & 29 deletions e2e/core/pages/card-view-component.page.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { by, element } from 'protractor';
import { $, by, element } from 'protractor';
import {
BrowserVisibility,
BrowserActions,
Expand All @@ -29,19 +29,19 @@ export class CardViewComponentPage {
addButton = element(by.className('adf-card-view__key-value-pairs__add-btn'));
nameCardTextItem = new CardTextItemPage('name');
booleanCardBooleanItem = new CardBooleanItemPage('boolean');
intField = element(by.css(`input[data-automation-id='card-textitem-editinput-int']`));
floatField = element(by.css(`input[data-automation-id='card-textitem-editinput-float']`));
intField = $(`input[data-automation-id='card-textitem-editinput-int']`);
floatField = $(`input[data-automation-id='card-textitem-editinput-float']`);
valueInputField = element(by.xpath(`//*[contains(@id,'input') and @placeholder='Value']`));
nameInputField = element(by.xpath(`//*[contains(@id,'input') and @placeholder='Name']`));
consoleLog = element(by.className('app-console'));
deleteButton = element.all(by.className('adf-card-view__key-value-pairs__remove-btn')).first();
resetButton = element(by.css(`#adf-reset-card-log`));
editableSwitch = element(by.id('app-toggle-editable'));
clearDateSwitch = element(by.id('app-toggle-clear-date'));
noneOptionSwitch = element(by.id('app-toggle-none-option'));
clickableField = element(by.css(`[data-automation-id="card-textitem-toggle-click"]`));
resetButton = $(`#adf-reset-card-log`);
editableSwitch = $('#app-toggle-editable');
clearDateSwitch = $('#app-toggle-clear-date');
noneOptionSwitch = $('#app-toggle-none-option');
clickableField = $(`[data-automation-id="card-textitem-toggle-click"]`);

selectDropdown = new DropdownPage(element(by.css('mat-select[data-automation-class="select-box"]')));
selectDropdown = new DropdownPage($('mat-select[data-automation-class="select-box"]'));

async clickOnAddButton(): Promise<void> {
await BrowserActions.click(this.addButton);
Expand Down Expand Up @@ -72,18 +72,18 @@ export class CardViewComponentPage {
}

async clickOnIntField(): Promise<void> {
const toggleText = element(by.css('div[data-automation-id="card-textitem-toggle-int"]'));
const toggleText = $('div[data-automation-id="card-textitem-toggle-int"]');
await BrowserActions.click(toggleText);
await BrowserVisibility.waitUntilElementIsVisible(this.intField);
}

async clickOnIntClearIcon(): Promise<void> {
const clearIcon = element(by.css('button[data-automation-id="card-textitem-reset-int"]'));
const clearIcon = $('button[data-automation-id="card-textitem-reset-int"]');
await BrowserActions.click(clearIcon);
}

async clickOnIntSaveIcon(): Promise<void> {
const saveIcon = element(by.css('button[data-automation-id="card-textitem-update-int"]'));
const saveIcon = $('button[data-automation-id="card-textitem-update-int"]');
await BrowserActions.click(saveIcon);
}

Expand All @@ -92,28 +92,28 @@ export class CardViewComponentPage {
}

getIntFieldText(): Promise<string> {
const textField = element(by.css('span[data-automation-id="card-textitem-value-int"]'));
const textField = $('span[data-automation-id="card-textitem-value-int"]');
return BrowserActions.getText(textField);
}

getErrorInt(): Promise<string> {
const errorElement = element(by.css('mat-error[data-automation-id="card-textitem-error-int"]'));
const errorElement = $('mat-error[data-automation-id="card-textitem-error-int"]');
return BrowserActions.getText(errorElement);
}

async clickOnFloatField(): Promise<void> {
const toggleText = element(by.css('div[data-automation-id="card-textitem-toggle-float"]'));
const toggleText = $('div[data-automation-id="card-textitem-toggle-float"]');
await BrowserActions.click(toggleText);
await BrowserVisibility.waitUntilElementIsVisible(this.floatField);
}

async clickOnFloatClearIcon(): Promise<void> {
const clearIcon = element(by.css(`button[data-automation-id="card-textitem-reset-float"]`));
const clearIcon = $(`button[data-automation-id="card-textitem-reset-float"]`);
await BrowserActions.click(clearIcon);
}

async clickOnFloatSaveIcon(): Promise<void> {
const saveIcon = element(by.css(`button[data-automation-id="card-textitem-update-float"]`));
const saveIcon = $(`button[data-automation-id="card-textitem-update-float"]`);
await BrowserActions.click(saveIcon);
}

Expand All @@ -122,12 +122,12 @@ export class CardViewComponentPage {
}

getFloatFieldText(): Promise<string> {
const textField = element(by.css('span[data-automation-id="card-textitem-value-float"]'));
const textField = $('span[data-automation-id="card-textitem-value-float"]');
return BrowserActions.getText(textField);
}

getErrorFloat(): Promise<string> {
const errorElement = element(by.css('mat-error[data-automation-id="card-textitem-error-float"]'));
const errorElement = $('mat-error[data-automation-id="card-textitem-error-float"]');
return BrowserActions.getText(errorElement);
}

Expand All @@ -144,7 +144,7 @@ export class CardViewComponentPage {
}

getOutputText(index: number): Promise<string> {
return BrowserActions.getText(this.consoleLog.all(by.css('p')).get(index));
return BrowserActions.getText(this.consoleLog.$$('p').get(index));
}

async deletePairsValues(): Promise<void> {
Expand Down Expand Up @@ -177,30 +177,30 @@ export class CardViewComponentPage {
}

async getDateValue(): Promise<string> {
const dateValue = element(by.css('span[data-automation-id="card-date-value-date"]'));
const dateValue = $('span[data-automation-id="card-date-value-date"]');
return dateValue.getText();
}

async getDateTimeValue(): Promise<string> {
const dateTimeValue = element(by.css('span[data-automation-id="card-datetime-value-datetime"]'));
const dateTimeValue = $('span[data-automation-id="card-datetime-value-datetime"]');
return dateTimeValue.getText();
}

async clearDateField(): Promise<void> {
const clearDateButton = element(by.css('mat-icon[data-automation-id="datepicker-date-clear-date"]'));
const clearDateButton = $('mat-icon[data-automation-id="datepicker-date-clear-date"]');
await BrowserActions.click(clearDateButton);
}

async clearDateTimeField(): Promise<void> {
const clearDateButton = element(by.css('mat-icon[data-automation-id="datepicker-date-clear-datetime"]'));
const clearDateButton = $('mat-icon[data-automation-id="datepicker-date-clear-datetime"]');
await BrowserActions.click(clearDateButton);
}

async enableClearDate(): Promise<void> {
const switchClass = await BrowserActions.getAttribute(this.editableSwitch, 'class');
if (switchClass.indexOf('mat-checked') === -1) {
await this.clearDateSwitch.click();
const clearDateChecked = element(by.css('mat-slide-toggle[id="app-toggle-clear-date"][class*="mat-checked"]'));
const clearDateChecked = $('mat-slide-toggle[id="app-toggle-clear-date"][class*="mat-checked"]');
await BrowserVisibility.waitUntilElementIsVisible(clearDateChecked);
}
}
Expand All @@ -209,13 +209,13 @@ export class CardViewComponentPage {
const switchClass = await BrowserActions.getAttribute(this.noneOptionSwitch, 'class');
if (switchClass.indexOf('mat-checked') === -1) {
await this.noneOptionSwitch.click();
const noneOptionChecked = element(by.css('mat-slide-toggle[id="app-toggle-none-option"][class*="mat-checked"]'));
const noneOptionChecked = $('mat-slide-toggle[id="app-toggle-none-option"][class*="mat-checked"]');
await BrowserVisibility.waitUntilElementIsVisible(noneOptionChecked);
}
}

async isErrorNotDisplayed(): Promise<boolean> {
const errorElement = element(by.css('mat-error[data-automation-id="card-textitem-error-int"]'));
const errorElement = $('mat-error[data-automation-id="card-textitem-error-int"]');
try {
await BrowserVisibility.waitUntilElementIsNotVisible(errorElement);
return true;
Expand All @@ -231,10 +231,10 @@ export class CardViewComponentPage {
async updateClickableField(text: string): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.clickableField);
await BrowserActions.click(this.clickableField);
const inputField = element(by.css('input[data-automation-id="card-textitem-editinput-click"]'));
const inputField = $('input[data-automation-id="card-textitem-editinput-click"]');
await BrowserVisibility.waitUntilElementIsPresent(inputField);
await BrowserActions.clearSendKeys(inputField, text);
const save = element(by.css('[data-automation-id="card-textitem-update-click"]'));
const save = $('[data-automation-id="card-textitem-update-click"]');
await BrowserVisibility.waitUntilElementIsVisible(save);
await BrowserActions.click(save);
}
Expand Down
16 changes: 8 additions & 8 deletions e2e/core/pages/comments.page.ts
Expand Up @@ -16,18 +16,18 @@
*/

import { BrowserActions, BrowserVisibility, TabsPage } from '@alfresco/adf-testing';
import { by, element } from 'protractor';
import { $, $$ } from 'protractor';

export class CommentsPage {

tabsPage = new TabsPage();
numberOfComments = element(by.id('comment-header'));
commentUserIcon = element.all(by.id('comment-user-icon'));
commentUserName = element.all(by.id('comment-user'));
commentMessage = element.all(by.id('comment-message'));
commentTime = element.all(by.id('comment-time'));
commentInput = element(by.id('comment-input'));
addCommentButton = element(by.css("[data-automation-id='comments-input-add']"));
numberOfComments = $('#comment-header');
commentUserIcon = $$('#comment-user-icon');
commentUserName = $$('#comment-user');
commentMessage = $$('#comment-message');
commentTime = $$('#comment-time');
commentInput = $('#comment-input');
addCommentButton = $("[data-automation-id='comments-input-add']");

async getTotalNumberOfComments(text: string): Promise<void> {
await BrowserVisibility.waitUntilElementHasText(this.numberOfComments, text);
Expand Down

0 comments on commit 1e62b46

Please sign in to comment.