[ACS-6437] viewer e2e test migrate to playwright (#3704)

* rebase

* [ACS-6437] view protractor migrate to playwright

* [ACS-6437] review changes

* [ACS-6437] review changes
This commit is contained in:
Akash Rathod
2024-03-15 14:17:20 +01:00
committed by GitHub
parent f2d78f165c
commit 227f3fb996
10 changed files with 141 additions and 293 deletions

View File

@@ -23,11 +23,11 @@
*/
const crypto = require('crypto');
import { LoginPage } from '../';
import * as path from 'path';
import { LoginPage, PersonalFilesPage } from '../';
import { NodesApi, TrashcanApi, SitesApi } from '@alfresco/playwright-shared';
export class Utils {
static string257Long = 'x'.repeat(257);
static string513Long = 'x'.repeat(513);
@@ -49,15 +49,15 @@ export class Utils {
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 });
@@ -66,17 +66,23 @@ export class Utils {
}
}
/**
/**
* 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> {
*
*/
static async deleteNodesSitesEmptyTrashcan(
nodesApi?: NodesApi,
trashcanApi?: TrashcanApi,
errorMessage = 'Error ',
sitesApi?: SitesApi,
sitesToDelete?: string[]
): Promise<void> {
try {
await nodesApi?.deleteCurrentUserNodes();
await trashcanApi?.emptyTrashcan();
@@ -87,4 +93,9 @@ export class Utils {
console.error(`${errorMessage}: ${error}`);
}
}
static async uploadFileNewVersion(personalFilesPage: PersonalFilesPage, fileFromOS: string): Promise<void> {
const fileInput = await personalFilesPage.page.$('#app-upload-file-version');
await fileInput.setInputFiles(path.join(__dirname, `../resources/test-files/${fileFromOS}.docx`));
}
}