[ACS-12629] Automate XAT-19936 + lots of viewer refactoring (#5372)

* [ACS-12629] Automated xat-19936 - pt1

* [ACS-12629] viewer refactoring

* [ACS-12629] infodrawer changes

* [ACS-12629] sonar fix 1
This commit is contained in:
Adam Świderski
2026-09-04 14:11:11 +02:00
committed by GitHub
parent 8134f59d80
commit ec82e76753
22 changed files with 148 additions and 87 deletions
@@ -28,17 +28,13 @@ import { BaseComponent } from './base.component';
export class AcaHeader extends BaseComponent {
private static readonly rootElement = 'aca-toolbar';
private readonly moreActionsButton = this.getChild('button[id="app.viewer.toolbar.more"]');
private readonly toolbarMoreActions = this.getChild('button[id="app.toolbar.more"]');
public createButton = this.getChild('[id="app.toolbar.create"]');
public viewDetails = this.getChild('[title="View Details"]');
public viewButton = this.getChild('button[title="View"]');
public searchButton = this.getChild('button[id="app.toolbar.search"]');
public fullScreenButton = this.getChild('button[id="app.viewer.fullscreen"]');
public shareButton = this.getChild('button[id="share-action-button"]');
public downloadButtonViewer = this.getChild('button[id="app.viewer.download"]');
public downloadButton = this.getChild('button[id="app.toolbar.download"]');
public sharedDownloadButton = this.getChild('button[id="app.viewer.shared.download"]');
public uploadButton = this.getChild('button[id="app.toolbar.upload"]');
public uploadFileButton = this.page.locator('button[id="app.create.uploadFile"]');
public uploadNewVersionButton = this.page.locator('#app-upload-file-version');
@@ -50,11 +46,6 @@ export class AcaHeader extends BaseComponent {
}
public matMenu = new MatMenuComponent(this.page);
async clickViewerMoreActions(): Promise<void> {
await this.moreActionsButton.waitFor({ state: 'attached' });
await this.moreActionsButton.click();
}
async clickMoreActions(): Promise<void> {
await this.toolbarMoreActions.waitFor({ state: 'attached' });
await this.toolbarMoreActions.click();
@@ -30,7 +30,7 @@ export * from './base.component';
export * from './actions-dropdown.component';
export * from './conditions.component';
export * from './pagination.component';
export * from './adf-info-drawer.component';
export * from './info-drawer.component';
export * from './viewer.component';
export * from './search';
export * from './breadcrumb/breadcrumb.component';
@@ -39,3 +39,4 @@ export * from './aca-header.component';
export * from './error.component';
export * from './datetime-picker/datetime-picker.component';
export * from './edit-mode.component';
export * from './viewer-toolbar.component';
@@ -25,11 +25,18 @@
import { BaseComponent } from './base.component';
import { Locator, Page } from '@playwright/test';
export class AdfInfoDrawerComponent extends BaseComponent {
export class InfoDrawerComponent extends BaseComponent {
private static readonly rootElement = 'adf-info-drawer';
constructor(page: Page) {
super(page, AdfInfoDrawerComponent.rootElement);
private viewerScoped?: InfoDrawerComponent;
constructor(page: Page, rootElement: string = InfoDrawerComponent.rootElement) {
super(page, rootElement);
}
get viewer(): InfoDrawerComponent {
this.viewerScoped ??= new InfoDrawerComponent(this.page, `adf-viewer ${InfoDrawerComponent.rootElement}`);
return this.viewerScoped;
}
private readonly categoriesManagement = this.getChild('adf-categories-management');
@@ -51,7 +58,7 @@ export class AdfInfoDrawerComponent extends BaseComponent {
public commentUsername = this.getChild('.adf-comment-user-name');
public commentTextContent = this.getChild('.adf-comment-message');
public commentTimestamp = this.getChild('.adf-comment-message-time');
public infoDrawerPanel = this.page.locator(AdfInfoDrawerComponent.rootElement);
public infoDrawerPanel = this.page.locator(InfoDrawerComponent.rootElement);
public headerTitle = this.getChild('.adf-info-drawer-layout-header-title').getByRole('heading');
public editButton = this.page.getByRole('button', { name: 'Edit' });
public cancelButton = this.page.getByRole('button', { name: 'Cancel' });
@@ -0,0 +1,46 @@
/*!
* Copyright © 2005-2026 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
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { Page } from '@playwright/test';
import { BaseComponent } from './base.component';
export class ViewerToolbarComponent extends BaseComponent {
private static readonly rootElement = 'adf-viewer';
private readonly moreActionsButton = this.getChild('button[id="app.viewer.toolbar.more"]');
public viewDetailsButton = this.getChild('[title="View Details"]');
public fullScreenButton = this.getChild('button[id="app.viewer.fullscreen"]');
public shareButton = this.getChild('button[id="share-action-button"]');
public downloadButton = this.getChild('button[id="app.viewer.download"]');
public sharedDownloadButton = this.getChild('button[id="app.viewer.shared.download"]');
constructor(page: Page) {
super(page, ViewerToolbarComponent.rootElement);
}
async clickMoreActions(): Promise<void> {
await this.moreActionsButton.waitFor({ state: 'attached' });
await this.moreActionsButton.click();
}
}
@@ -24,21 +24,19 @@
import { Page, expect } from '@playwright/test';
import { BaseComponent } from './base.component';
import { AcaHeader } from './aca-header.component';
import { ViewerToolbarComponent } from './viewer-toolbar.component';
import { timeouts } from '../../utils';
export class ViewerComponent extends BaseComponent {
private static readonly rootElement = 'adf-viewer';
public viewerLocator = this.getChild('adf-viewer-render');
public closeButtonLocator = this.getChild('.adf-viewer-close-button');
public fileTitleButtonLocator = this.getChild('#adf-viewer-display-name');
public viewerRender = this.getChild('adf-viewer-render');
public closeButton = this.getChild('.adf-viewer-close-button');
public fileTitleButton = this.getChild('#adf-viewer-display-name');
public pdfViewerContentPages = this.getChild('.adf-pdf-viewer__content .page');
public shareButton = this.getChild('button[id="share-action-button"]');
public downloadButton = this.getChild('button[id="app.viewer.download"]');
public unknownFormat = this.getChild(`adf-viewer-unknown-format .adf-viewer__unknown-format-view`);
public viewerImage = this.viewerLocator.locator('#viewer-image');
public viewerDocument = this.viewerLocator.locator('.adf-pdf-viewer__content [role="document"]');
public viewerImage = this.viewerRender.locator('#viewer-image');
public viewerDocument = this.viewerRender.locator('.adf-pdf-viewer__content [role="document"]');
public documentThumbnailButton = this.getChild('[data-automation-id="adf-thumbnails-button"]');
public thumbnailsPages = this.getChild('[data-automation-id="adf-thumbnails-content"] adf-pdf-thumb');
public thumbnailsCloseButton = this.getChild('[data-automation-id="adf-thumbnails-close"]');
@@ -54,7 +52,7 @@ export class ViewerComponent extends BaseComponent {
public previousFileButton = this.getChild('[data-automation-id="adf-toolbar-pref-file"]');
public noPermissionsView = this.getChild('aca-generic-error');
toolbar = new AcaHeader(this.page);
public toolbar = new ViewerToolbarComponent(this.page);
constructor(page: Page) {
super(page, ViewerComponent.rootElement);
@@ -67,12 +65,12 @@ export class ViewerComponent extends BaseComponent {
async isViewerOpened(): Promise<boolean> {
await this.waitForViewerToOpen();
return this.viewerLocator.isVisible();
return this.viewerRender.isVisible();
}
async waitForViewerToOpen(): Promise<void> {
await this.waitForViewerLoaderToFinish();
await this.viewerLocator.waitFor({ state: 'visible', timeout: timeouts.large });
await this.viewerRender.waitFor({ state: 'visible', timeout: timeouts.large });
}
async waitForViewerLoaderToFinish(): Promise<void> {
@@ -101,13 +99,13 @@ export class ViewerComponent extends BaseComponent {
}
async isCloseButtonDisplayed(): Promise<boolean> {
await this.closeButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
return this.closeButtonLocator.isEnabled({ timeout: timeouts.normal });
await this.closeButton.waitFor({ state: 'visible', timeout: timeouts.normal });
return this.closeButton.isEnabled({ timeout: timeouts.normal });
}
async isFileTitleDisplayed(): Promise<boolean> {
await this.fileTitleButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
return this.fileTitleButtonLocator.isVisible();
await this.fileTitleButton.waitFor({ state: 'visible', timeout: timeouts.normal });
return this.fileTitleButton.isVisible();
}
async waitForZoomPercentageToDisplay(): Promise<void> {
@@ -129,8 +127,8 @@ export class ViewerComponent extends BaseComponent {
}
async getFileTitle(): Promise<string> {
await this.fileTitleButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
const title = await this.fileTitleButtonLocator.textContent();
await this.fileTitleButton.waitFor({ state: 'visible', timeout: timeouts.normal });
const title = await this.fileTitleButton.textContent();
if (!title) {
const errorMessage = 'File title is not displayed in the viewer';
this.logger.error(errorMessage);
@@ -140,8 +138,8 @@ export class ViewerComponent extends BaseComponent {
}
async getCloseButtonTooltip(): Promise<string> {
await this.closeButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
const tooltip = await this.closeButtonLocator.getAttribute('title');
await this.closeButton.waitFor({ state: 'visible', timeout: timeouts.normal });
const tooltip = await this.closeButton.getAttribute('title');
if (!tooltip) {
const errorMessage = 'Close button tooltip is not available';
this.logger.error(errorMessage);
@@ -31,7 +31,7 @@ import {
SidenavComponent,
PaginationComponent,
Breadcrumb,
AdfInfoDrawerComponent
InfoDrawerComponent
} from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent, ViewerOverlayDialogComponent, ManageVersionsDialog } from '../components/dialogs';
@@ -52,7 +52,7 @@ export class FavoritesPage extends BasePage {
public sidenav = new SidenavComponent(this.page);
public pagination = new PaginationComponent(this.page);
public breadcrumb = new Breadcrumb(this.page);
public infoDrawer = new AdfInfoDrawerComponent(this.page);
public infoDrawer = new InfoDrawerComponent(this.page);
public manageVersionsDialog = new ManageVersionsDialog(this.page);
async waitForPageLoad() {
@@ -26,7 +26,7 @@ import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import {
AcaHeader,
AdfInfoDrawerComponent,
InfoDrawerComponent,
AdfLibraryDialogComponent,
DataTableComponent,
MatMenuComponent,
@@ -50,8 +50,8 @@ export class MyLibrariesPage extends BasePage {
public matMenu = new MatMenuComponent(this.page);
public libraryDialog = new AdfLibraryDialogComponent(this.page);
public dataTable = new DataTableComponent(this.page);
public libraryDetails = new AdfInfoDrawerComponent(this.page);
public infoDrawer = new AdfInfoDrawerComponent(this.page);
public libraryDetails = new InfoDrawerComponent(this.page);
public infoDrawer = new InfoDrawerComponent(this.page);
public viewer = new ViewerComponent(this.page);
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
public copyMoveDialog = new ContentNodeSelectorDialog(this.page);
@@ -40,7 +40,7 @@ import {
ErrorComponent,
ShareDialogComponent,
AdfConfirmDialogComponent,
AdfInfoDrawerComponent,
InfoDrawerComponent,
UploadNewVersionDialog,
ManageVersionsDialog,
UploadDialog,
@@ -63,6 +63,7 @@ export class PersonalFilesPage extends BasePage {
public contentNodeSelector = new ContentNodeSelectorDialog(this.page);
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
public passwordDialog = new PasswordOverlayDialogComponent(this.page);
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
public breadcrumb = new Breadcrumb(this.page);
@@ -72,7 +73,7 @@ export class PersonalFilesPage extends BasePage {
public errorDialog = new ErrorComponent(this.page);
public shareDialog = new ShareDialogComponent(this.page);
public confirmDialog = new AdfConfirmDialogComponent(this.page);
public infoDrawer = new AdfInfoDrawerComponent(this.page);
public infoDrawer = new InfoDrawerComponent(this.page);
public nodeInfoEditMode = new EditModeComponent(this.page);
public uploadNewVersionDialog = new UploadNewVersionDialog(this.page);
public manageVersionsDialog = new ManageVersionsDialog(this.page);
@@ -24,7 +24,7 @@
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent, Breadcrumb, AdfInfoDrawerComponent } from '../components';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent, Breadcrumb, InfoDrawerComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent, ContentNodeSelectorDialog, ManageVersionsDialog } from '../components/dialogs';
@@ -42,7 +42,7 @@ export class RecentFilesPage extends BasePage {
public viewer = new ViewerComponent(this.page);
public sidenav = new SidenavComponent(this.page);
public breadcrumb = new Breadcrumb(this.page);
public infoDrawer = new AdfInfoDrawerComponent(this.page);
public infoDrawer = new InfoDrawerComponent(this.page);
public contentNodeSelector = new ContentNodeSelectorDialog(this.page);
public manageVersionsDialog = new ManageVersionsDialog(this.page);
}
@@ -24,7 +24,7 @@
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent, Breadcrumb, AdfInfoDrawerComponent } from '../components';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent, Breadcrumb, InfoDrawerComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent, ViewerOverlayDialogComponent, ManageVersionsDialog } from '../components/dialogs';
@@ -43,6 +43,6 @@ export class SharedPage extends BasePage {
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
public sidenav = new SidenavComponent(this.page);
public breadcrumb = new Breadcrumb(this.page);
public infoDrawer = new AdfInfoDrawerComponent(this.page);
public infoDrawer = new InfoDrawerComponent(this.page);
public manageVersionsDialog = new ManageVersionsDialog(this.page);
}