[ACS-11051] getChild usage refactored (#5056)

* [ACS-11051] getChild usage refactored

* [ACS-11051] sonar fix 1

* [ACS-11051] test fixes 1

* [ACS-11051] test fixes 2

* [ACS-11051] review fixes 1

* [ACS-11051] review fixes 2
This commit is contained in:
Adam Świderski
2026-02-20 15:06:37 +01:00
committed by GitHub
parent 6c1f3b3188
commit 1218c0fb64
30 changed files with 198 additions and 111 deletions
@@ -44,15 +44,15 @@ export class AdfInfoDrawerComponent extends BaseComponent {
public propertiesTab = this.page.getByRole('tab', { name: 'Properties' });
public commentsTab = this.page.getByRole('tab', { name: 'Comments' });
public infoDrawerTabs = this.getChild('.adf-info-drawer-tab');
public commentInputField = this.page.locator('#comment-input');
public commentInputField = this.getChild('#comment-input');
public commentsHeader = this.getChild('#comment-header');
public addCommentButton = this.getChild('[data-automation-id="comments-input-add"]');
public commentsList = this.getChild('.adf-comment-list-item');
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('.adf-info-drawer');
public headerTitle = this.page.locator('.adf-info-drawer-layout-header-title').getByRole('heading');
public infoDrawerPanel = this.page.locator(AdfInfoDrawerComponent.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' });
public updateButton = this.page.getByRole('button', { name: 'Update' });
@@ -62,9 +62,9 @@ export class AdfInfoDrawerComponent extends BaseComponent {
public expandDetailsButton = this.getChild(`button[title='Expand panel']`);
public expandedDetailsTabs = this.page.locator('.aca-details-container [role="tab"]');
public expandedDetailsPermissionsTab = this.expandedDetailsTabs.getByText('Permissions');
public nameField = this.page.locator('input[placeholder=Name]');
public idField = this.page.locator(`input[placeholder='Library ID']`);
public descriptionField = this.page.locator('textarea[placeholder=Description]');
public nameField = this.getChild('input[placeholder=Name]');
public idField = this.getChild(`input[placeholder='Library ID']`);
public descriptionField = this.getChild('textarea[placeholder=Description]');
public visibilityField = this.infoDrawerPanel.getByRole('combobox');
public selectVisibility = (visibilityOption: string) => this.page.getByRole('listbox').getByRole('option', { name: visibilityOption }).click();
public tagsAccordion = this.getChild('[data-automation-id="adf-content-metadata-tags-panel"]');
@@ -50,12 +50,10 @@ export class DataTableComponent extends BaseComponent {
emptyListSubtitle = this.getChild('.adf-empty-content__subtitle');
emptySearchText = this.getChild('.empty-search__text');
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"]');
lockOwner = this.page.locator('.aca-locked-by--name');
sitesVisibility = this.getChild('.adf-datatable-body [data-automation-id*="datatable-row"] [aria-label="Visibility"]');
sitesName = this.getChild('.adf-datatable-body [data-automation-id*="datatable-row"] [aria-label="Name"]');
sitesRole = this.getChild('.adf-datatable-body [data-automation-id*="datatable-row"] [aria-label="My Role"]');
lockOwner = '.aca-locked-by--name';
highlightedText = '.aca-highlight';
searchFileName = '.search-file-name';
searchFileDescription = '[data-automation-id="search-results-entry-description"]';
@@ -310,11 +308,6 @@ export class DataTableComponent extends BaseComponent {
await this.getCellByColumnNameAndRowItem(itemName, 'Name').click({ button: 'right' });
}
async setPaginationTo50(): Promise<void> {
await this.paginationButton.click();
await this.paginationOptions.getByText('50').click();
}
/**
* Method used to create objects from names and visibility of sites from datatable
*
@@ -24,4 +24,3 @@
export * from './data-table.component';
export * from './mat-menu.component';
export * from './toolbar.component';
@@ -35,7 +35,7 @@ export class DateTimePicker extends BaseComponent {
}
async isCalendarOpen(): Promise<boolean> {
const element = this.getChild('');
const element = this.page.locator(DateTimePicker.rootElement);
return element.isVisible();
}
@@ -35,8 +35,8 @@ export class CreateFromTemplateDialogComponent extends BaseComponent {
cancelButton = this.getChild('[data-automation-id="create-from-template-dialog-cancel-button"]');
createButton = this.getChild('[data-automation-id="create-from-template-dialog-create-button"]');
getDialogTitle = (text: string) => this.getChild('[data-automation-id="create-from-template-title"]', { hasText: text });
getDialogLabel = (text: string) => this.getChild('label', { hasText: text });
getDialogTitle = (text: string): Locator => this.getChild('[data-automation-id="create-from-template-title"]', { hasText: text });
getDialogLabel = (text: string): Locator => this.getChild('label', { hasText: text });
getErrorByText = (text: string): Locator => this.page.locator('[data-automation-id="create-from-template-field-error"]', { hasText: text });
async isErrorMessageDisplayed(errorText: string): Promise<boolean> {
@@ -28,7 +28,7 @@ import { BaseComponent } from '../base.component';
export class EditDialog extends BaseComponent {
private static rootElement = 'adf-folder-dialog';
public editDialog = this.getChild('');
public editDialog = this.page.locator(EditDialog.rootElement);
public titleInput = this.getChild('[data-automation-id="adf-folder-dialog-title"]');
public cancelButton = this.getChild('#adf-folder-cancel-button');
public updateButton = this.getChild('#adf-folder-create-button');
@@ -29,7 +29,7 @@ export class ManageVersionsDialog extends BaseComponent {
private static rootElement = '.adf-new-version-uploader-dialog';
async viewFileVersion(version: string): Promise<void> {
const versionActionsButton = this.page.locator(`[id="adf-version-list-action-menu-button-${version}"]`);
const versionActionsButton = this.getChild(`[id="adf-version-list-action-menu-button-${version}"]`);
await versionActionsButton.click();
}
@@ -26,12 +26,12 @@ import { Page } from '@playwright/test';
import { BaseComponent } from '../base.component';
export class UploadDialog extends BaseComponent {
private static rootElement = '.adf-upload-dialog';
private static rootElement = 'aca-upload-files-dialog';
public uploadDialog = this.page.locator('.adf-upload-dialog');
public uploadDialogContent = this.getChild('.adf-upload-dialog__content');
public closeButton = this.getChild('#adf-upload-dialog-close');
public minimizeButton = this.page.locator('[data-automation-id="adf-upload-dialog__toggle-minimize"]');
public uploadDialogMinimized = this.page.locator('.adf-upload-dialog--minimized');
public minimizeButton = this.getChild('[data-automation-id="adf-upload-dialog__toggle-minimize"]');
public uploadDialogMinimized = this.getChild('.adf-upload-dialog--minimized');
constructor(page: Page) {
super(page, UploadDialog.rootElement);
@@ -33,16 +33,7 @@ export * from './conditions.component';
export * from './pagination.component';
export * from './adf-info-drawer.component';
export * from './viewer.component';
export * from './search/search-input.component';
export * from './search/search-overlay.components';
export * from './search/search-sorting-picker.components';
export * from './search/search-filters.component';
export * from './search/search-filters/search-filters-categories.component';
export * from './search/search-filters/search-filters-date.component';
export * from './search/search-filters/search-filters-location.component';
export * from './search/search-filters/search-filters-logic.component';
export * from './search/search-filters/search-filters-properties.component';
export * from './search/search-filters/search-filters-tags.component';
export * from './search';
export * from './breadcrumb/breadcrumb.component';
export * from './sidenav.component';
export * from './aca-header.component';
@@ -24,3 +24,4 @@
export * from './manage-rules-dialog.component';
export * from './manage-rules.component';
export * from './manage-rules-toolbar.component';
@@ -25,20 +25,20 @@
import { BaseComponent } from '../base.component';
import { Page } from '@playwright/test';
export class ToolbarComponent extends BaseComponent {
private static rootElement = 'adf-toolbar';
export class RulesToolbarComponent extends BaseComponent {
private static readonly rootElement = '.aca-manage-rules__actions-bar';
constructor(page: Page) {
super(page, ToolbarComponent.rootElement);
super(page, RulesToolbarComponent.rootElement);
}
async clickCreateRuleButton(): Promise<void> {
const button = this.page.locator('[data-automation-id="manage-rules-create-button"]');
const button = this.getChild('[data-automation-id="manage-rules-create-button"]');
await button.click();
}
async clickLinkRulesButton(): Promise<void> {
const button = this.page.locator('[data-automation-id="manage-rules-link-button"]');
const button = this.getChild('[data-automation-id="manage-rules-link-button"]');
await button.click();
}
}
@@ -0,0 +1,30 @@
/*!
* Copyright © 2005-2025 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/>.
*/
export * from './search-filters';
export * from './search-filters.component';
export * from './search-input.component';
export * from './search-menu-card.component';
export * from './search-overlay.components';
export * from './search-sorting-picker.components';
@@ -32,17 +32,17 @@ export class SearchFilters extends BaseComponent {
super(page, SearchFilters.rootElement);
}
public filtersButtons = this.page.locator('adf-search-widget-chip');
public logicFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Logic' });
public propertiesFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Properties' });
public dateFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Date' });
public locationFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Location' });
public tagsFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Tags' });
public categoriesFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Categories' });
public resetButton = this.page.locator('button', { hasText: 'Reset' });
public menuCardTitle = this.page.locator('.adf-search-filter-title');
public menuCardClose = this.page.locator('.adf-search-filter-title-action');
public menuCardClear = this.page.locator('#cancel-filter-button');
public menuCardApply = this.page.locator('#apply-filter-button');
public filtersButtons = this.getChild('adf-search-widget-chip');
public logicFilter = this.getChild('adf-search-widget-chip', { hasText: 'Logic' });
public propertiesFilter = this.getChild('adf-search-widget-chip', { hasText: 'Properties' });
public dateFilter = this.getChild('adf-search-widget-chip', { hasText: 'Date' });
public locationFilter = this.getChild('adf-search-widget-chip', { hasText: 'Location' });
public tagsFilter = this.getChild('adf-search-widget-chip', { hasText: 'Tags' });
public categoriesFilter = this.getChild('adf-search-widget-chip', { hasText: 'Categories' });
public resetButton = this.getChild('button', { hasText: 'Reset' });
public menuCardTitle = this.getChild('.adf-search-filter-title');
public menuCardClose = this.getChild('.adf-search-filter-title-action');
public menuCardClear = this.getChild('#cancel-filter-button');
public menuCardApply = this.getChild('#apply-filter-button');
public dropdownOptions = this.page.locator(`[role="option"]`);
}
@@ -0,0 +1,30 @@
/*!
* Copyright © 2005-2025 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/>.
*/
export * from './search-filters-categories.component';
export * from './search-filters-date.component';
export * from './search-filters-location.component';
export * from './search-filters-logic.component';
export * from './search-filters-properties.component';
export * from './search-filters-tags.component';
@@ -43,7 +43,7 @@ export class SearchFiltersLocation extends BaseComponent {
await page.searchFilters.locationFilter.click();
await page.searchFiltersLocation.addOptionInput.fill(location);
await page.searchFiltersLocation.searchOption(location).click();
await page.searchFilters.menuCardApply.click();
await page.searchMenuCard.menuCardApply.click();
await page.dataTable.progressBarWaitForReload();
}
}
@@ -94,7 +94,7 @@ export class SearchFiltersProperties extends BaseComponent {
await this.dropdownOptions.getByText(fileTypeInputText).click();
}
await page.searchFilters.menuCardApply.click();
await page.searchMenuCard.menuCardApply.click();
await page.dataTable.progressBarWaitForReload();
}
}
@@ -43,13 +43,13 @@ export class SearchFiltersTags extends BaseComponent {
await page.searchFilters.tagsFilter.click();
await page.searchFiltersTags.addOptionInput.fill(tag);
await this.searchOption(tag).click();
await page.searchFilters.menuCardApply.click();
await page.searchMenuCard.menuCardApply.click();
await page.dataTable.progressBarWaitForReload();
}
async clearTagFilter(page: SearchPage): Promise<void> {
await page.searchFilters.tagsFilter.click();
await page.searchFilters.menuCardClear.click();
await page.searchMenuCard.menuCardClear.click();
await page.dataTable.progressBarWaitForReload();
}
}
@@ -0,0 +1,41 @@
/*!
* Copyright © 2005-2025 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 { BaseComponent } from '../base.component';
import { Page } from '@playwright/test';
export class SearchMenuCard extends BaseComponent {
private static readonly rootElement = '.adf-search-filter-menu-card';
public resetButton = this.getChild('button', { hasText: 'Reset' });
public menuCardTitle = this.getChild('.adf-search-filter-title');
public menuCardClose = this.getChild('.adf-search-filter-title-action');
public menuCardClear = this.getChild('#cancel-filter-button');
public menuCardApply = this.getChild('#apply-filter-button');
public dropdownOptions = this.page.locator(`[role="option"]`);
constructor(page: Page) {
super(page, SearchMenuCard.rootElement);
}
}
@@ -27,7 +27,7 @@ import { BaseComponent } from './base.component';
import { Locator, Page } from '@playwright/test';
export class SidenavComponent extends BaseComponent {
private static rootElement = 'app-sidenav';
private static rootElement = '.adf-layout-container-sidenav';
private personalFiles = this.getChild(`[data-automation-id='app.navbar.personalFiles']`);
private myLibraries = this.getChild(`[data-automation-id='app.navbar.libraries.files']`);
@@ -37,8 +37,8 @@ export class SidenavComponent extends BaseComponent {
private favorites = this.getChild(`[data-automation-id='app.navbar.favorites']`);
private trash = this.getChild(`[data-automation-id='app.navbar.trashcan']`);
private sidenavToggle = this.getChild(`.aca-sidenav-header-title-logo`);
private sidenavExpand = this.page.getByTitle('Expand navigation menu');
public expandedSidenav = this.page.locator(`[data-automation-id='expanded']`);
private sidenavExpand = this.page.locator(`[title='Expand navigation menu']`);
public expandedSidenav = this.getChild(`[data-automation-id='expanded']`);
constructor(page: Page) {
super(page, SidenavComponent.rootElement);
@@ -74,7 +74,7 @@ export class SidenavComponent extends BaseComponent {
}
}
async isSidenavExpanded(): Promise<boolean> {
private async isSidenavExpanded(): Promise<boolean> {
await this.page.waitForTimeout(timeouts.tiny);
return this.expandedSidenav.isVisible();
}
@@ -27,7 +27,7 @@ import {
ConditionComponent,
ManageRules,
ManageRulesDialogComponent,
ToolbarComponent,
RulesToolbarComponent,
ActionsDropdownComponent,
ContentNodeSelectorDialog,
LinkRulesDialog
@@ -41,7 +41,7 @@ export class NodesPage extends BasePage {
super(page, NodesPage.pageUrl);
}
public toolbar = new ToolbarComponent(this.page);
public rulesToolbar = new RulesToolbarComponent(this.page);
public manageRulesDialog = new ManageRulesDialogComponent(this.page);
public actionsDropdown = new ActionsDropdownComponent(this.page);
public conditionsDropdown = new ConditionComponent(this.page);
@@ -39,7 +39,8 @@ import {
SearchFiltersLocation,
SearchFiltersLogic,
SearchFiltersProperties,
FolderInformationDialogComponent
FolderInformationDialogComponent,
SearchMenuCard
} from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfConfirmDialogComponent, AdfFolderDialogComponent, UploadNewVersionDialog, ManageVersionsDialog } from '../components/dialogs';
@@ -73,6 +74,7 @@ export class SearchPage extends BasePage {
public uploadNewVersionDialog = new UploadNewVersionDialog(this.page);
public manageVersionsDialog = new ManageVersionsDialog(this.page);
public folderInformationDialog = new FolderInformationDialogComponent(this.page);
public searchMenuCard = new SearchMenuCard(this.page);
async searchWithin(searchText: string, searchType?: SearchType): Promise<void> {
await this.acaHeader.searchButton.click();