mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-7333] [E2E] search filters - properties tests migrated to Playwright (#3756)
* [ACS-7333] [E2E] search filters - properties tests migrated to Playwright * [ACS-7333] review fix 1 * [ACS-7333] review fix 2 * [ACS-7333] review fix 3 * [ACS-7333] [E2E] search filters - properties tests migrated to Playwright
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"C290019": "https://alfresco.atlassian.net/browse/ACS-6928",
|
"C290019": "https://alfresco.atlassian.net/browse/ACS-6928",
|
||||||
"C290018": "https://alfresco.atlassian.net/browse/ACS-6928"
|
"C290018": "https://alfresco.atlassian.net/browse/ACS-6928",
|
||||||
|
"C699046-3": "https://hyland.atlassian.net/browse/ACS-7464"
|
||||||
}
|
}
|
@@ -0,0 +1,95 @@
|
|||||||
|
/*!
|
||||||
|
* Copyright © 2005-2024 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 { expect } from '@playwright/test';
|
||||||
|
import { ApiClientFactory, Utils, test, NodesApi, TrashcanApi, FileActionsApi, TEST_FILES } from '@alfresco/playwright-shared';
|
||||||
|
|
||||||
|
test.describe('Search - Filters - Properties', () => {
|
||||||
|
let nodesApi: NodesApi;
|
||||||
|
let trashcanApi: TrashcanApi;
|
||||||
|
|
||||||
|
const randomId = Utils.random();
|
||||||
|
const username = `user-${randomId}`;
|
||||||
|
const fileNamePdfKb = `${randomId}-fileNameKb.pdf`;
|
||||||
|
const fileNameJpgMb = `${randomId}-fileNameMb.jpg`;
|
||||||
|
|
||||||
|
test.beforeEach(async ({ loginPage }) => {
|
||||||
|
await Utils.tryLoginUser(loginPage, username, username, 'beforeEach failed');
|
||||||
|
});
|
||||||
|
|
||||||
|
test.beforeAll(async () => {
|
||||||
|
try {
|
||||||
|
const apiClientFactory = new ApiClientFactory();
|
||||||
|
await apiClientFactory.setUpAcaBackend('admin');
|
||||||
|
await apiClientFactory.createUser({ username });
|
||||||
|
nodesApi = await NodesApi.initialize(username, username);
|
||||||
|
trashcanApi = await TrashcanApi.initialize(username, username);
|
||||||
|
const fileActionsApi = await FileActionsApi.initialize(username, username);
|
||||||
|
await fileActionsApi.uploadFileWithRename(TEST_FILES.PDF.path, fileNamePdfKb, '-my-');
|
||||||
|
await fileActionsApi.uploadFileWithRename(TEST_FILES.JPG_FILE_1MB.path, fileNameJpgMb, '-my-');
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`beforeAll failed: ${error}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterAll(async () => {
|
||||||
|
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[C699046-1] Filter by size - At least 1000KB', async ({ searchPage }) => {
|
||||||
|
await searchPage.searchWithin(randomId, 'files');
|
||||||
|
await searchPage.searchFiltersProperties.setPropertiesParameters(searchPage, undefined, undefined, '1000');
|
||||||
|
|
||||||
|
await expect(searchPage.searchFilters.propertiesFilter).toContainText('Properties: At Least 1000 KB');
|
||||||
|
await expect(searchPage.dataTable.getRowByName(fileNamePdfKb)).toBeHidden();
|
||||||
|
await expect(searchPage.dataTable.getRowByName(fileNameJpgMb)).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[C699046-2] Filter by size - At most 1MB', async ({ searchPage }) => {
|
||||||
|
await searchPage.searchWithin(randomId, 'files');
|
||||||
|
await searchPage.searchFiltersProperties.setPropertiesParameters(searchPage, 'At Most', 'MB', '1');
|
||||||
|
|
||||||
|
await expect(searchPage.searchFilters.propertiesFilter).toContainText('Properties: At Most 1 MB');
|
||||||
|
await expect(searchPage.dataTable.getRowByName(fileNamePdfKb)).toBeVisible();
|
||||||
|
await expect(searchPage.dataTable.getRowByName(fileNameJpgMb)).toBeHidden();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[C699046-3] Filter by size - Exactly', async ({ searchPage }) => {
|
||||||
|
await searchPage.searchWithin(randomId, 'files');
|
||||||
|
await searchPage.searchFiltersProperties.setPropertiesParameters(searchPage, 'Exactly', undefined, '2.96');
|
||||||
|
|
||||||
|
await expect(searchPage.searchFilters.propertiesFilter).toContainText('Properties: Exactly 2.96 KB');
|
||||||
|
await expect(searchPage.dataTable.getRowByName(fileNamePdfKb)).toBeVisible();
|
||||||
|
await expect(searchPage.dataTable.getRowByName(fileNameJpgMb)).toBeHidden();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[C699047] Filter by type', async ({ searchPage }) => {
|
||||||
|
await searchPage.searchWithin(randomId, 'files');
|
||||||
|
await searchPage.searchFiltersProperties.setPropertiesParameters(searchPage, undefined, undefined, undefined, 'pdf');
|
||||||
|
|
||||||
|
await expect(searchPage.searchFilters.propertiesFilter).toContainText('Properties: pdf');
|
||||||
|
await expect(searchPage.dataTable.getRowByName(fileNamePdfKb)).toBeVisible();
|
||||||
|
await expect(searchPage.dataTable.getRowByName(fileNameJpgMb)).toBeHidden();
|
||||||
|
});
|
||||||
|
});
|
@@ -39,9 +39,9 @@ export class SearchFilters extends BaseComponent {
|
|||||||
public locationFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Location' });
|
public locationFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Location' });
|
||||||
public tagsFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Tags' });
|
public tagsFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Tags' });
|
||||||
public categoriesFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Categories' });
|
public categoriesFilter = this.page.locator('adf-search-widget-chip', { hasText: 'Categories' });
|
||||||
public resetButton = this.getChild('button' , { hasText: 'Reset' });
|
public resetButton = this.page.locator('button' , { hasText: 'Reset' });
|
||||||
public menuCardTitle = this.getChild('.adf-search-filter-title');
|
public menuCardTitle = this.page.locator('.adf-search-filter-title');
|
||||||
public menuCardClose = this.getChild('.adf-search-filter-title-action');
|
public menuCardClose = this.page.locator('.adf-search-filter-title-action');
|
||||||
public menuCardClear = this.getChild('#cancel-filter-button');
|
public menuCardClear = this.page.locator('#cancel-filter-button');
|
||||||
public menuCardApply = this.getChild('#apply-filter-button');
|
public menuCardApply = this.page.locator('#apply-filter-button');
|
||||||
}
|
}
|
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
import { BaseComponent } from '../../base.component';
|
import { BaseComponent } from '../../base.component';
|
||||||
import { Page } from '@playwright/test';
|
import { Page } from '@playwright/test';
|
||||||
|
import { SearchPage } from '@alfresco/playwright-shared';
|
||||||
|
|
||||||
export class SearchFiltersProperties extends BaseComponent {
|
export class SearchFiltersProperties extends BaseComponent {
|
||||||
private static rootElement = '.adf-search-filter-menu-card';
|
private static rootElement = '.adf-search-filter-menu-card';
|
||||||
@@ -33,7 +34,66 @@ export class SearchFiltersProperties extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public operatorButton = this.getChild(`.adf-search-properties-file-size-operator`);
|
public operatorButton = this.getChild(`.adf-search-properties-file-size-operator`);
|
||||||
public fileSizeInput = this.getChild(`[placeholder$='Results will match all words entered here']`);
|
public fileSizeInput = this.getChild(`[placeholder$='Enter file size']`);
|
||||||
public unitButton = this.getChild(`.adf-search-properties-file-size-unit`);
|
public unitButton = this.getChild(`.adf-search-properties-file-size-unit`);
|
||||||
public fileTypeInput = this.getChild(`[placeholder$='Results will exclude matches with these words']`);
|
public fileTypeInput = this.getChild(`[placeholder$='File Type']`);
|
||||||
|
public atLeastOption = this.page.locator(`.mat-option`, { hasText: 'At Least' });
|
||||||
|
public atMostOption = this.page.locator(`.mat-option`, { hasText: 'At Most' });
|
||||||
|
public exactlyOption = this.page.locator(`.mat-option`, { hasText: 'Exactly' });
|
||||||
|
public kbUnit = this.page.locator(`.mat-option`, { hasText: 'KB' });
|
||||||
|
public mbUnit = this.page.locator(`.mat-option`, { hasText: 'MB' });
|
||||||
|
public gbUnit = this.page.locator(`.mat-option`, { hasText: 'GB' });
|
||||||
|
public dropdownOptions = this.page.locator(`.mat-option`);
|
||||||
|
|
||||||
|
async setPropertiesParameters(
|
||||||
|
page: SearchPage,
|
||||||
|
operator?: 'At Least' | 'At Most' | 'Exactly',
|
||||||
|
unit?: 'KB' | 'MB' | 'GB',
|
||||||
|
fileSizeInputText?: string,
|
||||||
|
fileTypeInputText?: string
|
||||||
|
): Promise<void> {
|
||||||
|
await page.searchFilters.propertiesFilter.click();
|
||||||
|
|
||||||
|
if (operator) {
|
||||||
|
await this.operatorButton?.click();
|
||||||
|
switch (operator) {
|
||||||
|
case 'At Least':
|
||||||
|
await this.atLeastOption?.click();
|
||||||
|
break;
|
||||||
|
case 'At Most':
|
||||||
|
await this.atMostOption?.click();
|
||||||
|
break;
|
||||||
|
case 'Exactly':
|
||||||
|
await this.exactlyOption?.click();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unit) {
|
||||||
|
await this.unitButton?.click();
|
||||||
|
switch (unit) {
|
||||||
|
case 'KB':
|
||||||
|
await this.kbUnit?.click();
|
||||||
|
break;
|
||||||
|
case 'MB':
|
||||||
|
await this.mbUnit?.click();
|
||||||
|
break;
|
||||||
|
case 'GB':
|
||||||
|
await this.gbUnit?.click();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileSizeInputText) {
|
||||||
|
await this.fileSizeInput?.fill(fileSizeInputText);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileTypeInputText) {
|
||||||
|
await this.fileTypeInput?.fill(fileTypeInputText);
|
||||||
|
await this.dropdownOptions.first().click();
|
||||||
|
}
|
||||||
|
|
||||||
|
await page.searchFilters.menuCardApply.click();
|
||||||
|
await page.dataTable.progressBarWaitForReload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
@@ -65,6 +65,10 @@ export const TEST_FILES = {
|
|||||||
path: resolve(__dirname, 'file-jpg.jpg'),
|
path: resolve(__dirname, 'file-jpg.jpg'),
|
||||||
name: 'file-jpg'
|
name: 'file-jpg'
|
||||||
},
|
},
|
||||||
|
JPG_FILE_1MB: {
|
||||||
|
path: resolve(__dirname, 'file-jpg-1mb.jpg'),
|
||||||
|
name: 'file-jpg-1mb'
|
||||||
|
},
|
||||||
PDF_PROTECTED2: {
|
PDF_PROTECTED2: {
|
||||||
path: resolve(__dirname, 'protected.pdf'),
|
path: resolve(__dirname, 'protected.pdf'),
|
||||||
name: 'file-protected',
|
name: 'file-protected',
|
||||||
|
Reference in New Issue
Block a user