[ACS-5866] authentication playwright tests (#3391)

* viewer action files e2e migration

* viewer action files e2e remove comment

* review code fix

* [ci:force]

* [ACS-5650]viewer test with new user

* remove commented code

* login and logout playwright test

* Update error message login.spec.ts
This commit is contained in:
Akash Rathod
2023-08-18 18:49:46 +02:00
committed by GitHub
parent 9f1b8a0ac6
commit f8a30f3706
14 changed files with 325 additions and 238 deletions

View File

@@ -163,4 +163,15 @@ export class ApiClientFactory {
return null;
}
}
async changePassword(username: string, newPassword: string): Promise<PersonEntry> {
const peopleApi = new PeopleApi(this.alfrescoApi);
try {
return peopleApi.updatePerson(username, { password: newPassword });
} catch (error) {
logger.error('[API Client Factory] changePassword failed : ', error);
return null;
}
}
}

View File

@@ -35,7 +35,8 @@ import {
FavoritesPage,
FavoritesPageApi,
TrashPage,
UserActions
UserActions,
LoginPage
} from '../';
interface Pages {
@@ -47,6 +48,7 @@ interface Pages {
searchPage: SearchPage;
favoritePage: FavoritesPage;
trashPage: TrashPage;
loginPage: LoginPage;
}
interface Api {
@@ -78,6 +80,9 @@ export const test = base.extend<Pages & Api>({
trashPage: async ({ page }, use) => {
await use(new TrashPage(page));
},
loginPage: async ({ page }, use) => {
await use(new LoginPage(page));
},
// eslint-disable-next-line no-empty-pattern
fileAction: async ({}, use) => {
await use(await FileActionsApi.initialize('hruser'));

View File

@@ -31,15 +31,18 @@ interface LoginOptions {
withNavigation?: boolean;
}
export class LoginPage extends BasePage {
private static pageUrl = 'login';
constructor(page: Page) {
super(page, '');
super(page, LoginPage.pageUrl);
}
private username = this.page.locator('#username');
private password = this.page.locator('#password');
private submitButton = this.page.locator('#login-button');
private userProfileButton = this.page.locator('aca-user-menu button');
private userLogOutButton = this.page.locator('aca-logout button');
public username = this.page.locator('#username');
public password = this.page.locator('#password');
public submitButton = this.page.locator('#login-button');
public userProfileButton = this.page.locator('aca-user-menu button');
public userLogOutButton = this.page.locator('aca-logout button');
public passwordVisibility = this.page.locator('.adf-login-password-icon');
async loginUser(userData: { username: string; password: string } | UserModel, options?: LoginOptions): Promise<void> {
if (options?.withNavigation) {
@@ -58,4 +61,12 @@ export class LoginPage extends BasePage {
await this.userProfileButton.click();
await this.userLogOutButton.click();
}
async isPasswordDisplayed(): Promise<boolean> {
const type = await this.password.getAttribute('type');
if (type === 'text') {
return true;
}
return false;
}
}