[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

@@ -100,7 +100,7 @@ test.describe('Search Results - General', () => {
expect(await searchPage.dataTable.isItemPresent(folder)).toBeFalsy(); expect(await searchPage.dataTable.isItemPresent(folder)).toBeFalsy();
await searchPage.searchInput.searchButton.click(); await searchPage.searchInput.searchButton.click();
await searchPage.searchInput.searchFor(folder); await searchPage.searchOverlay.searchFor(folder);
await searchPage.dataTable.progressBarWaitForReload(); await searchPage.dataTable.progressBarWaitForReload();
expect(await searchPage.dataTable.isItemPresent(file)).toBeFalsy(); expect(await searchPage.dataTable.isItemPresent(file)).toBeFalsy();

View File

@@ -85,7 +85,7 @@ test.describe('Search Results - General', () => {
}); });
test.afterAll(async () => { test.afterAll(async () => {
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed', sitesApi, [ await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed', sitesAdminApi, [
site1.id, site1.id,
site2.id, site2.id,
site3.id, site3.id,

View File

@@ -30,12 +30,6 @@ export class SearchInputComponent extends BaseComponent {
private static rootElement = 'aca-page-layout'; private static rootElement = 'aca-page-layout';
public searchInput = this.page.locator('#app-control-input'); public searchInput = this.page.locator('#app-control-input');
public searchButton = this.page.locator('.app-search-button'); 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 }); 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.getCellLinkByName(name).dblclick();
await this.spinnerWaitForReload(); 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 searchFilesOption = this.getChild('label[for="content-input"]');
public searchFoldersOption = this.getChild('label[for="folder-input"]'); public searchFoldersOption = this.getChild('label[for="folder-input"]');
public searchLibrariesOption = this.getChild('label[for="libraries-input"]'); public searchLibrariesOption = this.getChild('label[for="libraries-input"]');
public searchInput = this.getChild('input[id="app-control-input"]'); public searchInput = this.page.locator('#app-control-input');
public searchButton = this.getChild('.app-search-button'); public searchButton = this.page.locator('#app-search-button');
public searchInputControl = this.page.locator('.app-search-control'); public searchInputControl = this.page.locator('.app-search-control');
public searchOptions = this.page.locator('#search-options'); public searchOptions = this.page.locator('#search-options');
@@ -40,7 +40,50 @@ export class SearchOverlayComponent extends BaseComponent {
super(page, rootElement); 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> { async checkFilesAndFolders(): Promise<void> {
await this.clearOptions();
await this.searchFilesOption.click(); await this.searchFilesOption.click();
await this.searchFoldersOption.click(); await this.searchFoldersOption.click();
} }

View File

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