mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5650] viewer user actions test (#3373)
* 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
This commit is contained in:
@@ -38,11 +38,13 @@ import {
|
||||
UploadApi,
|
||||
SharedlinksApi,
|
||||
FavoritesApi,
|
||||
TrashcanApi
|
||||
TrashcanApi,
|
||||
PersonEntry
|
||||
} from '@alfresco/js-api';
|
||||
import { logger } from '@alfresco/adf-cli/scripts/logger';
|
||||
import { ActionTypes, Rule } from './rules-api';
|
||||
import { users } from '../base-config';
|
||||
import { Person, PersonModel } from './people-api-models';
|
||||
|
||||
export interface AcaBackend {
|
||||
sites: SitesApi;
|
||||
@@ -149,4 +151,16 @@ export class ApiClientFactory {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async createUser(user: PersonModel): Promise<PersonEntry> {
|
||||
const person = new Person(user);
|
||||
const peopleApi = new PeopleApi(this.alfrescoApi);
|
||||
|
||||
try {
|
||||
return peopleApi.createPerson(person);
|
||||
} catch (error) {
|
||||
logger.error('[API Client Factory] createUser failed : ', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,3 +27,5 @@ export * from './api-client-factory';
|
||||
export * from './file-actions';
|
||||
export * from './shared-links-api';
|
||||
export * from './favorites-api';
|
||||
export * from './user-actions';
|
||||
export * from './people-api-models';
|
||||
|
52
projects/aca-playwright-shared/src/api/people-api-models.ts
Executable file
52
projects/aca-playwright-shared/src/api/people-api-models.ts
Executable file
@@ -0,0 +1,52 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export interface PersonModel {
|
||||
username?: string;
|
||||
password?: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
email?: string;
|
||||
enabled?: boolean;
|
||||
properties?: any;
|
||||
}
|
||||
|
||||
export class Person {
|
||||
id: string;
|
||||
password: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
email: string;
|
||||
enabled: boolean;
|
||||
properties: any;
|
||||
|
||||
constructor(user: PersonModel) {
|
||||
this.id = user.username;
|
||||
this.password = user.password || user.username;
|
||||
this.firstName = user.firstName || user.username;
|
||||
this.lastName = user.lastName || user.username;
|
||||
this.email = user.email || `${user.username}@alfresco.com`;
|
||||
this.enabled = user.enabled || true;
|
||||
}
|
||||
}
|
134
projects/aca-playwright-shared/src/api/user-actions.ts
Normal file
134
projects/aca-playwright-shared/src/api/user-actions.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { AlfrescoApi, CommentsApi, NodesApi, TrashcanApi, SitesApi, SharedlinksApi, UploadApi } from '@alfresco/js-api';
|
||||
|
||||
const { BASE_URL } = process.env;
|
||||
|
||||
const config = {
|
||||
authType: 'BASIC',
|
||||
hostBpm: BASE_URL,
|
||||
hostEcm: BASE_URL,
|
||||
provider: 'ECM',
|
||||
contextRoot: 'alfresco'
|
||||
};
|
||||
|
||||
export class UserActions {
|
||||
public alfrescoApi: AlfrescoApi;
|
||||
|
||||
public commentsApi: CommentsApi;
|
||||
public nodesApi: NodesApi;
|
||||
public trashCanApi: TrashcanApi;
|
||||
public sitesApi: SitesApi;
|
||||
public sharedLinksApi: SharedlinksApi;
|
||||
public uploadApi: UploadApi;
|
||||
|
||||
protected username: string;
|
||||
protected password: string;
|
||||
|
||||
constructor() {
|
||||
this.alfrescoApi = new AlfrescoApi(config);
|
||||
}
|
||||
|
||||
public async setUpUserAcaBackend(username: string, password: string): Promise<void> {
|
||||
await this.loginUser(username, password );
|
||||
|
||||
this.commentsApi = new CommentsApi(this.alfrescoApi);
|
||||
this.nodesApi = new NodesApi(this.alfrescoApi);
|
||||
this.trashCanApi = new TrashcanApi(this.alfrescoApi);
|
||||
this.sitesApi = new SitesApi(this.alfrescoApi);
|
||||
this.sharedLinksApi = new SharedlinksApi(this.alfrescoApi);
|
||||
this.uploadApi = new UploadApi(this.alfrescoApi);
|
||||
}
|
||||
|
||||
public async loginUser(username: string, password: string): Promise<any> {
|
||||
this.username = username || this.username;
|
||||
this.password = password || this.password;
|
||||
|
||||
try {
|
||||
return this.alfrescoApi.login(this.username, this.password);
|
||||
} catch (error) {
|
||||
Logger.error(`\n [User Actions] - login failed ${error} error :`);
|
||||
}
|
||||
}
|
||||
|
||||
async lockNodes(nodeIds: string[], lockType: string = 'ALLOW_OWNER_CHANGES') {
|
||||
try {
|
||||
for (const nodeId of nodeIds) {
|
||||
await this.nodesApi.lockNode(nodeId, { type: lockType });
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(`\n [User Actions] - lockNodes failed ${error} error :`);
|
||||
}
|
||||
}
|
||||
|
||||
async uploadFile(fileLocation: string, fileName: string, parentFolderId: string): Promise<any> {
|
||||
const file = fs.createReadStream(fileLocation);
|
||||
return this.uploadApi.uploadFile(
|
||||
file,
|
||||
'',
|
||||
parentFolderId,
|
||||
null,
|
||||
{
|
||||
name: fileName,
|
||||
nodeType: 'cm:content',
|
||||
renditions: 'doclib'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete multiple sites/libraries.
|
||||
* @param siteIds The list of the site/library IDs to delete.
|
||||
* @param permanent Delete permanently, without moving to the trashcan? (default: true)
|
||||
*/
|
||||
async deleteSites(siteIds: string[], permanent: boolean = true) {
|
||||
try {
|
||||
if (siteIds && siteIds.length > 0) {
|
||||
for (const siteId of siteIds) {
|
||||
await this.sitesApi.deleteSite(siteId, { permanent });
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(`\n [User Actions] - deleteSites failed error : ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete multiple nodes.
|
||||
* @param nodeIds The list of node IDs to delete.
|
||||
* @param permanent Delete permanently, without moving to the trashcan? (default: true)
|
||||
*/
|
||||
async deleteNodes(nodeIds: string[], permanent: boolean = true): Promise<any> {
|
||||
try {
|
||||
for (const nodeId of nodeIds) {
|
||||
await this.nodesApi.deleteNode(nodeId, { permanent });
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(`\n [User Actions] - deleteNodes failed error : ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
@@ -34,7 +34,8 @@ import {
|
||||
SearchPage,
|
||||
FavoritesPage,
|
||||
FavoritesPageApi,
|
||||
TrashPage
|
||||
TrashPage,
|
||||
UserActions
|
||||
} from '../';
|
||||
|
||||
interface Pages {
|
||||
@@ -52,6 +53,7 @@ interface Api {
|
||||
fileAction: FileActionsApi;
|
||||
shareAction: SharedLinksApi;
|
||||
favoritesPageAction: FavoritesPageApi;
|
||||
userActions: UserActions;
|
||||
}
|
||||
|
||||
export const test = base.extend<Pages & Api>({
|
||||
@@ -88,6 +90,10 @@ export const test = base.extend<Pages & Api>({
|
||||
favoritesPageAction: async ({}, use) => {
|
||||
await use(await FavoritesPageApi.initialize('hruser'));
|
||||
},
|
||||
// eslint-disable-next-line no-empty-pattern
|
||||
userActions: async ({}, use) => {
|
||||
await use(new UserActions());
|
||||
},
|
||||
myLibrariesPage: async ({ page }, use) => {
|
||||
await use(new MyLibrariesPage(page));
|
||||
}
|
||||
|
@@ -0,0 +1,55 @@
|
||||
/*!
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
import { BaseComponent } from '../base.component';
|
||||
|
||||
export class ContentNodeSelectorDialog extends BaseComponent {
|
||||
private static rootElement = 'adf-content-node-selector';
|
||||
|
||||
public cancelButton = this.getChild('[data-automation-id="content-node-selector-actions-cancel"]');
|
||||
public actionButton = this.getChild('[data-automation-id="content-node-selector-actions-choose"]');
|
||||
public locationDropDown = this.getChild('[id="site-dropdown-container"]');
|
||||
private selectedRow = this.getChild('.adf-is-selected');
|
||||
private getOptionLocator = (optionName: string): Locator => this.page.locator('.mat-select-panel .mat-option-text', { hasText: optionName });
|
||||
private getRowByName = (name: string | number): Locator => this.getChild(`adf-datatable-row`, { hasText: name.toString() });
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page, ContentNodeSelectorDialog.rootElement);
|
||||
}
|
||||
|
||||
async selectLocation(location: string): Promise<void> {
|
||||
await this.locationDropDown.click();
|
||||
const optionLocator = this.getOptionLocator(location);
|
||||
await optionLocator.click();
|
||||
await optionLocator.waitFor({ state: 'detached' });
|
||||
}
|
||||
|
||||
async selectDestination(folderName: string): Promise<void> {
|
||||
const row = this.getRowByName(folderName);
|
||||
await row.click();
|
||||
await this.selectedRow.waitFor({ state: 'attached' });
|
||||
await this.selectedRow.isVisible();
|
||||
}
|
||||
}
|
@@ -26,3 +26,4 @@ export * from './adf-folder-dialog.component';
|
||||
export * from './adf-library-dialog.component';
|
||||
export * from './password-overlay-dialog.component';
|
||||
export * from './viewer-overlay-dialog.component';
|
||||
export * from './content-node-selector-dialog';
|
||||
|
@@ -38,6 +38,8 @@ export class LoginPage extends BasePage {
|
||||
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');
|
||||
|
||||
async loginUser(userData: { username: string; password: string } | UserModel, options?: LoginOptions): Promise<void> {
|
||||
if (options?.withNavigation) {
|
||||
@@ -51,4 +53,9 @@ export class LoginPage extends BasePage {
|
||||
await Promise.all([this.page.waitForLoadState('domcontentloaded'), this.spinner.waitForReload()]);
|
||||
}
|
||||
}
|
||||
|
||||
async logoutUser(): Promise<void> {
|
||||
await this.userProfileButton.click();
|
||||
await this.userLogOutButton.click();
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,15 @@
|
||||
import { Page } from '@playwright/test';
|
||||
import { BasePage } from './base.page';
|
||||
import { AcaHeader } from '../components/aca-header.component';
|
||||
import { AdfInfoDrawerComponent, AdfLibraryDialogComponent, DataTableComponent, MatMenuComponent } from '../components';
|
||||
import {
|
||||
AdfInfoDrawerComponent,
|
||||
AdfLibraryDialogComponent,
|
||||
DataTableComponent,
|
||||
MatMenuComponent,
|
||||
ViewerComponent,
|
||||
ViewerOverlayDialogComponent,
|
||||
ContentNodeSelectorDialog
|
||||
} from '../components';
|
||||
|
||||
export class MyLibrariesPage extends BasePage {
|
||||
private static pageUrl = 'libraries';
|
||||
@@ -38,6 +46,9 @@ export class MyLibrariesPage extends BasePage {
|
||||
public libraryDialog = new AdfLibraryDialogComponent(this.page);
|
||||
public dataTable = new DataTableComponent(this.page);
|
||||
public libraryDetails = new AdfInfoDrawerComponent(this.page);
|
||||
public viewer = new ViewerComponent(this.page);
|
||||
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
|
||||
public copyMoveDialog = new ContentNodeSelectorDialog(this.page);
|
||||
|
||||
async selectCreateLibrary(): Promise<void> {
|
||||
await this.acaHeader.createButton.click();
|
||||
|
@@ -0,0 +1,198 @@
|
||||
%PDF-1.3
|
||||
%<25><><EFBFBD><EFBFBD>
|
||||
|
||||
1 0 obj
|
||||
<<
|
||||
/Type /Catalog
|
||||
/Outlines 2 0 R
|
||||
/Pages 3 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
2 0 obj
|
||||
<<
|
||||
/Type /Outlines
|
||||
/Count 0
|
||||
>>
|
||||
endobj
|
||||
|
||||
3 0 obj
|
||||
<<
|
||||
/Type /Pages
|
||||
/Count 2
|
||||
/Kids [ 4 0 R 6 0 R ]
|
||||
>>
|
||||
endobj
|
||||
|
||||
4 0 obj
|
||||
<<
|
||||
/Type /Page
|
||||
/Parent 3 0 R
|
||||
/Resources <<
|
||||
/Font <<
|
||||
/F1 9 0 R
|
||||
>>
|
||||
/ProcSet 8 0 R
|
||||
>>
|
||||
/MediaBox [0 0 612.0000 792.0000]
|
||||
/Contents 5 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
5 0 obj
|
||||
<< /Length 1074 >>
|
||||
stream
|
||||
2 J
|
||||
BT
|
||||
0 0 0 rg
|
||||
/F1 0027 Tf
|
||||
57.3750 722.2800 Td
|
||||
( A Simple PDF File ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 688.6080 Td
|
||||
( This is a small demonstration .pdf file - ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 664.7040 Td
|
||||
( just for use in the Virtual Mechanics tutorials. More text. And more ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 652.7520 Td
|
||||
( text. And more text. And more text. And more text. ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 628.8480 Td
|
||||
( And more text. And more text. And more text. And more text. And more ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 616.8960 Td
|
||||
( text. And more text. Boring, zzzzz. And more text. And more text. And ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 604.9440 Td
|
||||
( more text. And more text. And more text. And more text. And more text. ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 592.9920 Td
|
||||
( And more text. And more text. ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 569.0880 Td
|
||||
( And more text. And more text. And more text. And more text. And more ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 557.1360 Td
|
||||
( text. And more text. And more text. Even more. Continued on page 2 ...) Tj
|
||||
ET
|
||||
endstream
|
||||
endobj
|
||||
|
||||
6 0 obj
|
||||
<<
|
||||
/Type /Page
|
||||
/Parent 3 0 R
|
||||
/Resources <<
|
||||
/Font <<
|
||||
/F1 9 0 R
|
||||
>>
|
||||
/ProcSet 8 0 R
|
||||
>>
|
||||
/MediaBox [0 0 612.0000 792.0000]
|
||||
/Contents 7 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
7 0 obj
|
||||
<< /Length 676 >>
|
||||
stream
|
||||
2 J
|
||||
BT
|
||||
0 0 0 rg
|
||||
/F1 0027 Tf
|
||||
57.3750 722.2800 Td
|
||||
( Simple PDF File 2 ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 688.6080 Td
|
||||
( ...continued from page 1. Yet more text. And more text. And more text. ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 676.6560 Td
|
||||
( And more text. And more text. And more text. And more text. And more ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 664.7040 Td
|
||||
( text. Oh, how boring typing this stuff. But not as boring as watching ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 652.7520 Td
|
||||
( paint dry. And more text. And more text. And more text. And more text. ) Tj
|
||||
ET
|
||||
BT
|
||||
/F1 0010 Tf
|
||||
69.2500 640.8000 Td
|
||||
( Boring. More, a little more text. The end, and just as well. ) Tj
|
||||
ET
|
||||
endstream
|
||||
endobj
|
||||
|
||||
8 0 obj
|
||||
[/PDF /Text]
|
||||
endobj
|
||||
|
||||
9 0 obj
|
||||
<<
|
||||
/Type /Font
|
||||
/Subtype /Type1
|
||||
/Name /F1
|
||||
/BaseFont /Helvetica
|
||||
/Encoding /WinAnsiEncoding
|
||||
>>
|
||||
endobj
|
||||
|
||||
10 0 obj
|
||||
<<
|
||||
/Creator (Rave \(http://www.nevrona.com/rave\))
|
||||
/Producer (Nevrona Designs)
|
||||
/CreationDate (D:20060301072826)
|
||||
>>
|
||||
endobj
|
||||
|
||||
xref
|
||||
0 11
|
||||
0000000000 65535 f
|
||||
0000000019 00000 n
|
||||
0000000093 00000 n
|
||||
0000000147 00000 n
|
||||
0000000222 00000 n
|
||||
0000000390 00000 n
|
||||
0000001522 00000 n
|
||||
0000001690 00000 n
|
||||
0000002423 00000 n
|
||||
0000002456 00000 n
|
||||
0000002574 00000 n
|
||||
|
||||
trailer
|
||||
<<
|
||||
/Size 11
|
||||
/Root 1 0 R
|
||||
/Info 10 0 R
|
||||
>>
|
||||
|
||||
startxref
|
||||
2714
|
||||
%%EOF
|
Binary file not shown.
@@ -35,10 +35,15 @@ export const TEST_FILES = {
|
||||
name: 'file-pdf',
|
||||
data: 'Lorem ipsum dolor sit amet'
|
||||
},
|
||||
DOCX_PROTECTED: {
|
||||
PDF_PROTECTED: {
|
||||
path: resolve(__dirname, 'file-pdf-protected.pdf'),
|
||||
name: 'file-pdf-protected',
|
||||
data: 'Lorem ipsum dolor sit amet',
|
||||
password: '0000'
|
||||
},
|
||||
XLSX: {
|
||||
path: resolve(__dirname, 'file-xlsx.xlsx'),
|
||||
name: 'file-xlsx',
|
||||
data: 'Lorem ipsum dolor sit amet'
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user