[ACS-6954] Refactor Search Playwright tests - move search actions to searchOverlay component (#3703)

* Refactored search playwright tests moved search actions to search overlay component
This commit is contained in:
Katarzyna Kita
2024-03-12 12:55:02 +01:00
committed by GitHub
parent f63d5073f4
commit c572dde261
5 changed files with 52 additions and 82 deletions

View File

@@ -30,12 +30,6 @@ export class SearchInputComponent extends BaseComponent {
private static rootElement = 'aca-page-layout';
public searchInput = this.page.locator('#app-control-input');
public searchButton = this.page.locator('.app-search-button');
public searchButtonWindow = this.page.locator('#app-search-button');
public searchOptions = this.page.locator('#search-options');
public searchFilesOption = this.page.locator('#content')
public searchLibrariesOption = this.page.locator('#libraries')
public searchFoldersOption = this.page.locator('#folder')
getIconByName = (name: string): Locator => this.getChild('.mat-icon', { hasText: name });
@@ -56,71 +50,4 @@ export class SearchInputComponent extends BaseComponent {
await this.getCellLinkByName(name).dblclick();
await this.spinnerWaitForReload();
}
async clickLibrariesOption() {
await this.searchLibrariesOption.click();
}
async clickFilesOption() {
await this.searchFilesOption.click();
}
async clickFoldersOption() {
await this.searchFoldersOption.click();
}
async isFoldersOptionChecked() {
const optClass = await this.searchFoldersOption.getAttribute('class');
return optClass.includes('mat-checkbox-checked');
}
async isFilesOptionChecked() {
const optClass = await this.searchFilesOption.getAttribute('class');
return optClass.includes('mat-checkbox-checked');
}
async isLibrariesOptionChecked() {
const optClass = await this.searchLibrariesOption.getAttribute('class');
return optClass.includes('mat-checkbox-checked');
}
async clearOptions() {
if (await this.isFilesOptionChecked()) {
await this.clickFilesOption();
}
if (await this.isFoldersOptionChecked()) {
await this.clickFoldersOption();
}
if (await this.isLibrariesOptionChecked()) {
await this.clickLibrariesOption();
}
}
async checkOnlyFolders() {
await this.clearOptions();
await this.clickFoldersOption();
}
async checkOnlyFiles() {
await this.clearOptions();
await this.clickFilesOption();
}
async checkLibraries() {
await this.clearOptions();
await this.clickLibrariesOption();
}
async checkFilesAndFolders() {
await this.clearOptions();
await this.clickFilesOption();
await this.clickFoldersOption();
}
async searchFor(text: string) {
await this.searchInput.click({force: true});
await this.searchInput.clear({force: true});
await this.searchInput.fill(text, {force: true});
await this.searchButtonWindow.click();
}
}

View File

@@ -31,8 +31,8 @@ export class SearchOverlayComponent extends BaseComponent {
public searchFilesOption = this.getChild('label[for="content-input"]');
public searchFoldersOption = this.getChild('label[for="folder-input"]');
public searchLibrariesOption = this.getChild('label[for="libraries-input"]');
public searchInput = this.getChild('input[id="app-control-input"]');
public searchButton = this.getChild('.app-search-button');
public searchInput = this.page.locator('#app-control-input');
public searchButton = this.page.locator('#app-search-button');
public searchInputControl = this.page.locator('.app-search-control');
public searchOptions = this.page.locator('#search-options');
@@ -40,7 +40,50 @@ export class SearchOverlayComponent extends BaseComponent {
super(page, rootElement);
}
async isFoldersOptionChecked() {
const optClass = await this.searchFoldersOption.getAttribute('class');
return optClass.includes('mat-checkbox-checked');
}
async isFilesOptionChecked() {
const optClass = await this.searchFilesOption.getAttribute('class');
return optClass.includes('mat-checkbox-checked');
}
async isLibrariesOptionChecked() {
const optClass = await this.searchLibrariesOption.getAttribute('class');
return optClass.includes('mat-checkbox-checked');
}
async clearOptions() {
if (await this.isFilesOptionChecked()) {
await this.searchFilesOption.click();
}
if (await this.isFoldersOptionChecked()) {
await this.searchFoldersOption.click();
}
if (await this.isLibrariesOptionChecked()) {
await this.searchLibrariesOption.click();
}
}
async checkOnlyFolders(): Promise<void> {
await this.clearOptions();
await this.searchFoldersOption.click();
}
async checkOnlyFiles(): Promise<void> {
await this.clearOptions();
await this.searchFilesOption.click();
}
async checkLibraries(): Promise<void> {
await this.clearOptions();
await this.searchLibrariesOption.click();
}
async checkFilesAndFolders(): Promise<void> {
await this.clearOptions();
await this.searchFilesOption.click();
await this.searchFoldersOption.click();
}

View File

@@ -52,21 +52,21 @@ export class SearchPage extends BasePage {
await this.searchInput.searchButton.click();
switch (searchType) {
case 'files':
await this.searchInput.checkOnlyFiles();
await this.searchOverlay.checkOnlyFiles();
break;
case 'folders':
await this.searchInput.checkOnlyFolders();
await this.searchOverlay.checkOnlyFolders();
break;
case 'filesAndFolders':
await this.searchInput.checkFilesAndFolders();
await this.searchOverlay.checkFilesAndFolders();
break;
case 'libraries':
await this.searchInput.checkLibraries();
await this.searchOverlay.checkLibraries();
break;
default:
break;
}
await this.searchInput.searchFor(searchText);
await this.searchOverlay.searchFor(searchText);
await this.dataTable.progressBarWaitForReload();
}
}