[ACS-6798] protractor to playwright e2e test suites search results libraries (#3690)

* [ACS-6798] seach results libraries migrated

* [ACS-6798] added infoDrawer and search to PW tests in PRs

* [ACS-6798] excluded tests + sonar fix

* [ACS-6798] sonar fix 2

* [ACS-6798] sonar fix 3

* [ACS-6798] sonar fix 3

* [ACS-6798] login and delete methods added to Utils for sonar cloud duplication code

* [ACS-6798] review fixes

* Revert "[ci:force][auto-commit] Update dependencies ADF:6.8.0-8186121470  JS:7.7.0-8186121470 (#3693)"

This reverts commit 29b1bf99d4ff8734342b94907d6bb2676a407e2e.

* Revert "Release 4.4.1 (#3688)"

This reverts commit 6dd3ad66d0d96054beb4f70fee5b2b550cc23efc.

* [ACS-6798] review fixes pt2

* [ACS-6798] review fixes pt 3

* [ACS-6798] review fixes pt4

* [ACS-6798] review fixes pt4.1
This commit is contained in:
Adam Świderski
2024-03-08 10:58:19 +01:00
committed by GitHub
parent 00feb07d7d
commit 93cf1b9198
12 changed files with 370 additions and 92 deletions

View File

@@ -52,6 +52,9 @@ export class DataTableComponent extends BaseComponent {
emptyListTest = this.getChild('adf-custom-empty-content-template');
paginationButton = this.page.locator('.adf-pagination__block button').nth(0);
paginationOptions = this.page.locator('#cdk-overlay-0 button');
sitesVisibility = this.page.locator('.adf-datatable-body [data-automation-id*="datatable-row"] [aria-label="Visibility"]');
sitesName = this.page.locator('.adf-datatable-body [data-automation-id*="datatable-row"] [aria-label="Name"]');
sitesRole = this.page.locator('.adf-datatable-body [data-automation-id*="datatable-row"] [aria-label="My Role"]');
/** Locator for row (or rows) */
getRowLocator = this.getChild(`adf-datatable-row`);
@@ -327,4 +330,47 @@ export class DataTableComponent extends BaseComponent {
await this.paginationButton.click();
await this.paginationOptions.getByText("50").click();
}
/**
* Method used to create objects from names and visibility of sites from datatable
*
* @returns an object with sites' names and their corresponding visibility values
*/
async getSitesNameAndVisibility(): Promise<{ [siteName: string]: string }> {
const rowsCount = await this.sitesName.count();
let sitesInfo: { [siteName: string]: string } = {};
for (let i = 0; i < rowsCount; i++) {
let siteVisibilityText = await this.sitesVisibility.nth(i).textContent();
let siteNameText = await this.sitesName.nth(i).textContent();
siteVisibilityText = siteVisibilityText.trim().toUpperCase();
siteNameText = siteNameText.trim();
sitesInfo[siteNameText] = siteVisibilityText;
}
return sitesInfo;
}
/**
* Method used to create objects from names and roles of sites from datatable
*
* @returns an object with sites' names and their corresponding role values
*/
async getSitesNameAndRole(): Promise<{ [siteName: string]: string }> {
const rowsCount = await this.sitesName.count();
let sitesInfo: { [siteName: string]: string } = {};
for (let i = 0; i < rowsCount; i++) {
let siteNameText = await this.sitesName.nth(i).textContent();
let siteRoleText = await this.sitesRole.nth(i).textContent();
siteNameText = siteNameText.trim();
siteRoleText = siteRoleText.trim();
sitesInfo[siteNameText] = siteRoleText;
}
return sitesInfo;
}
/**
* Method used to wait for values to be loaded in the table
*/
async waitForTable(): Promise<void> {
await this.getRowLocator.nth(0).waitFor({timeout:5000});
}
}

View File

@@ -23,6 +23,8 @@
*/
const crypto = require('crypto');
import { LoginPage } from '../';
import { NodesApi, TrashcanApi, SitesApi } from '@alfresco/playwright-shared';
export class Utils {
@@ -46,4 +48,43 @@ export class Utils {
static formatDate(date: string): string {
return new Date(date).toLocaleDateString('en-US');
}
/**
* Method used to login user with navigation. Also waits for the page to load after login
*
* @param loginPage page context passed from the test
* @param username username string
* @param password password string
* @param errorMessage error message string if the login fails
*
*/
static async tryLoginUser(loginPage: LoginPage, username: string, password: string, errorMessage = 'Error '): Promise<void> {
try {
await loginPage.loginUser({ username, password }, { withNavigation: true, waitForLoading: true });
} catch (error) {
console.error(`${errorMessage}: ${error}`);
}
}
/**
* Method used to delete nodes and sites from user's account
*
* @param nodesApi nodesApi initialized with user credentials passed from the test
* @param trashcanApi trashcanApi initialized with user credentials passed from the test
* @param errorMessage error message string if the deleting sites/nodes fails
* @param sitesApi sitesApi initialized with user credentials passed from the test
* @param sitesToDelete array of sites' ids
*
*/
static async deleteNodesSitesEmptyTrashcan(nodesApi?: NodesApi, trashcanApi?: TrashcanApi, errorMessage = 'Error ', sitesApi?: SitesApi, sitesToDelete?: string[]): Promise<void> {
try {
await nodesApi?.deleteCurrentUserNodes();
await trashcanApi?.emptyTrashcan();
if (sitesToDelete?.length > 0) {
await sitesApi?.deleteSites(sitesToDelete);
}
} catch (error) {
console.error(`${errorMessage}: ${error}`);
}
}
}