[ACS-8561] [E2E] Merge-selectItem-and-selectMultiItem-into-one-method (#4011)

* [ACS-8561] [E2E] Merge-selectItem-and-selectMultiItem-into-one-method

* [ACS-8561] method fixes 1

* [ACS-8561] review fixes 1
This commit is contained in:
Adam Świderski
2024-08-08 10:06:43 +02:00
committed by GitHub
parent 3075135fbc
commit 2bc4e158f2
19 changed files with 77 additions and 84 deletions

View File

@@ -56,6 +56,8 @@ export class DataTableComponent extends BaseComponent {
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');
uncheckedChecbox = this.page.locator('.mat-mdc-checkbox');
checkedChecbox = this.page.locator('.mat-mdc-checkbox-checked');
/** Locator for row (or rows) */
getRowLocator = this.page.getByRole('rowgroup').nth(1).locator('adf-datatable-row');
@@ -238,29 +240,21 @@ export class DataTableComponent extends BaseComponent {
}
}
async selectItem(name: string): Promise<void> {
const isSelected = await this.isRowSelected(name);
if (!isSelected) {
let row = this.getRowByName(name);
await row.hover();
await row.locator('.mat-mdc-checkbox').click();
await row.locator('.mat-mdc-checkbox-checked').waitFor({ state: 'attached' });
}
}
async selectMultiItem(...names: string[]): Promise<void> {
async selectItems(...names: string[]): Promise<void> {
for (const name of names) {
let row = this.getRowByName(name);
await row.hover();
await row.locator('.mat-mdc-checkbox').click();
await row.locator('.mat-mdc-checkbox-checked').waitFor({ state: 'attached' });
await this.page.waitForTimeout(1000);
const isSelected = await this.isRowSelected(name);
if (!isSelected) {
let row = this.getRowByName(name);
await row.hover();
await row.locator(this.uncheckedChecbox).click();
await row.locator(this.checkedChecbox).waitFor({ state: 'attached' });
}
}
}
async isRowSelected(itemName: string): Promise<boolean> {
const row = this.getRowByName(itemName);
return await row.locator('.adf-datatable-checkbox .mat-mdc-checkbox-checked').isVisible();
return await row.locator(this.checkedChecbox).isVisible();
}
async getColumnHeaders(): Promise<Array<string>> {

View File

@@ -98,7 +98,7 @@ export class PersonalFilesPage extends BasePage {
async copyOrMoveContentInDatatable(sourceFileList: string[], destinationName: string, operation = 'Copy'): Promise<void> {
await this.page.keyboard.down('Control');
for (const sourceName of sourceFileList) {
await this.dataTable.selectItem(sourceName);
await this.dataTable.selectItems(sourceName);
}
await this.page.keyboard.up('Control');
await this.clickMoreActionsButton(operation);
@@ -108,7 +108,7 @@ export class PersonalFilesPage extends BasePage {
async selectItemsAndToggleFavorite(item: string[], action: 'Favorite' | 'Remove Favorite') {
for (const itemToSelect of item) {
await this.dataTable.selectItem(itemToSelect);
await this.dataTable.selectItems(itemToSelect);
}
await this.acaHeader.clickMoreActions();
await this.matMenu.clickMenuItem(action);