Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/13069 fss UI only display filters where there is more than 1 attribute value #126

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 87 additions & 84 deletions Tests/FunctionalTests/fss-simplified-search-results.spec.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
const { autoTestConfig } = require('./appSetting');
const { pageObjectsConfig, pageTimeOut } = require('./pageObjects');
import {AcceptCookies, InsertSearchText,
import {
AcceptCookies, InsertSearchText,
ExpectAllResultsHaveBatchUserAttValue,
ExpectAllResultsContainAnyBatchUserAttValue,
GetTotalResultCount,GetSpecificAttributeCount,filterCheckBox,ExpectAllResultsContainBatchUserAttValue,ExpectSpecificColumnValueDisplayed} from './helpermethod';
import {attributeProductType, searchNonExistBatchAttribute,batchAttributeKeys,attributeMediaType,attributeMultipleMediaType} from './helperconstant';
GetTotalResultCount, GetSpecificAttributeCount, filterCheckBox, ExpectAllResultsContainBatchUserAttValue, ExpectSpecificColumnValueDisplayed
} from './helpermethod';
import { attributeProductType, searchNonExistBatchAttribute, batchAttributeKeys, attributeMediaType, attributeMultipleMediaTypes, attributeMultipleMediaType } from './helperconstant';

describe('Test Search Result Scenario On Simplified Search Page', () => {
jest.setTimeout(pageTimeOut.timeOutInMilliSeconds);

beforeEach(async () => {
beforeEach(async () => {
await page.goto(autoTestConfig.url)
await AcceptCookies(page);

await page.waitForSelector(pageObjectsConfig.searchPageContainerHeaderSelector);
expect(await page.innerHTML(pageObjectsConfig.searchPageContainerHeaderSelector)).toEqual(pageObjectsConfig.searchPageContainerHeaderText);

})

it('Verify No results for non existing batch attribute value search', async () => {
//Enter non existing value in search box
await InsertSearchText(page, searchNonExistBatchAttribute);
try{
await page.waitForSelector(pageObjectsConfig.dialogInfoSelector);

}catch{
await page.click(pageObjectsConfig.simplifiedSearchButtonSelector);
await page.waitForSelector(pageObjectsConfig.dialogInfoSelector);
}
const infoText=await page.innerText(pageObjectsConfig.dialogInfoSelector);
expect(infoText).toEqual(pageObjectsConfig.dialogInfoText);
await InsertSearchText(page, searchNonExistBatchAttribute);
try {
await page.waitForSelector(pageObjectsConfig.dialogInfoSelector);

} catch {
await page.click(pageObjectsConfig.simplifiedSearchButtonSelector);
await page.waitForSelector(pageObjectsConfig.dialogInfoSelector);
}

const infoText = await page.innerText(pageObjectsConfig.dialogInfoSelector);

expect(infoText).toEqual(pageObjectsConfig.dialogInfoText);

})

it('Verify search results for single batch attribute search', async () => {
await InsertSearchText(page, attributeProductType.value);

Expand All @@ -44,124 +46,125 @@ describe('Test Search Result Scenario On Simplified Search Page', () => {
// verify paginator links are available on the page
expect(await page.isVisible(pageObjectsConfig.paginatorLinkPrevious)).toBeTruthy();
expect(await page.isVisible(pageObjectsConfig.paginatorLinkNext)).toBeTruthy();

})

it('Verify paginator text showing correct values for search results on first page', async () => {
await InsertSearchText(page, attributeProductType.value);
await InsertSearchText(page, attributeProductType.value);

await page.waitForSelector(pageObjectsConfig.searchResultTableSelector);
const recordCount = await GetTotalResultCount(page);
const paginatorText = await page.innerText(pageObjectsConfig.paginatorTextSelector);

if (recordCount<=10)
{
expect(paginatorText).toEqual(`Showing 1-${recordCount} of ${recordCount}`);
if (recordCount <= 10) {
expect(paginatorText).toEqual(`Showing 1-${recordCount} of ${recordCount}`);
}
else
{
expect(paginatorText).toEqual(`Showing 1-10 of ${recordCount}`);
}

else {
expect(paginatorText).toEqual(`Showing 1-10 of ${recordCount}`);
}

})

it('Verify search results for multiple batch attributes search', async () => {
const searchText = `L1K2 ${attributeProductType.value}`;
await InsertSearchText(page, searchText);

await page.waitForSelector(pageObjectsConfig.searchResultTableSelector);
const batchAttributesValue = searchText.split(' ');
await ExpectAllResultsContainAnyBatchUserAttValue(page, batchAttributesValue);
})

it('Verify file downloaded status changed after click on download button', async () => {
await InsertSearchText(page, attributeProductType.value);
await InsertSearchText(page, attributeProductType.value);

await page.waitForSelector(pageObjectsConfig.searchResultTableSelector);

//verify Choose files to download and Download buttons are available on the page
expect(await page.isVisible(pageObjectsConfig.chooseFileDownloadSelector)).toBeTruthy();
//Click on expand button
await page.click(pageObjectsConfig.chooseFileDownloadSelector);
//Click on download button
await page.click(pageObjectsConfig.fileDownloadButton, {force: true});
//Get the file downloaded status
const fileDownloadStatus=await page.getAttribute(pageObjectsConfig.fileDownloadButtonStatus,"class");
expect(fileDownloadStatus).toContain("check");

//Click on expand button
await page.click(pageObjectsConfig.chooseFileDownloadSelector);

//Click on download button
await page.click(pageObjectsConfig.fileDownloadButton, { force: true });

//Get the file downloaded status
const fileDownloadStatus = await page.getAttribute(pageObjectsConfig.fileDownloadButtonStatus, "class");
expect(fileDownloadStatus).toContain("check");
})

it('Verify search results specific batch attributes on filter panel', async () => {
it('Verify search results specific batch attributes Not displayed on filter panel', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this test to Verify batch attributes with single value are not displayed on filter panel

Suggested change
it('Verify search results specific batch attributes Not displayed on filter panel', async () => {
it('Verify batch attributes with single value are not displayed on filter panel', async () => {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved. Thanks

await InsertSearchText(page, attributeProductType.value);

await page.waitForSelector(pageObjectsConfig.searchResultTableSelector);
await ExpectAllResultsHaveBatchUserAttValue(page, attributeProductType.value);

const filterSpeficAttributeCount=await GetSpecificAttributeCount(page, attributeProductType.key, attributeProductType.value );
expect(filterSpeficAttributeCount).toEqual(1);
const filterSpeficAttributeCount = await GetSpecificAttributeCount(page, attributeProductType.key, attributeProductType.value);

expect(filterSpeficAttributeCount).toEqual(0);

})

it('Verify configured batch attributes will be displayed on the filter panel', async () => {
await InsertSearchText(page, attributeProductType.value);
it('Verify batch attributes with multiple values are displayed on filter panel', async () => {
await InsertSearchText(page, attributeMultipleMediaTypes.value);

await page.waitForSelector(pageObjectsConfig.searchResultTableSelector);
await ExpectAllResultsHaveBatchUserAttValue(page, attributeProductType.value);
await ExpectAllResultsContainAnyBatchUserAttValue(page, attributeMultipleMediaTypes.value.split(' '));

const configuredBatchAttibutes = await page.$$eval(pageObjectsConfig.filterBatchAttributes, elements => { return elements.map(element => element.textContent) });
const filterCount = configuredBatchAttibutes.length;
expect(filterCount).toBeGreaterThan(0);

for (let i = 0; i < filterCount; i++) {
expect(batchAttributeKeys.includes(configuredBatchAttibutes[i])).toBeTruthy();
//filter values count should be more than one
const batchAttibutesValues = await page.$$eval(`[aria-label='${configuredBatchAttibutes[i]}'] label`, elements => { return elements.map(element => element.textContent) });
expect(batchAttibutesValues.length).toBeGreaterThan(1);
}

const configuredBatchAttibutes=await page.$$eval(pageObjectsConfig.filterBatchAttributes ,elements => { return elements.map(element => element.textContent) });

var match = (batchAttributeKeys.length == configuredBatchAttibutes.length) && batchAttributeKeys.every(function(element, index) {
return element === configuredBatchAttibutes[index];
});

expect(match).toBeTruthy();

})

it('Verify batch attributes filter can select or deselect', async () => {
await InsertSearchText(page, attributeProductType.value);
await InsertSearchText(page, attributeMultipleMediaTypes.value);

await page.waitForSelector(pageObjectsConfig.searchResultTableSelector);
await ExpectAllResultsHaveBatchUserAttValue(page, attributeProductType.value);
await ExpectAllResultsContainAnyBatchUserAttValue(page, attributeMultipleMediaTypes.value.split(' '));

const [attrCD, attrDVD] = attributeMultipleMediaTypes.value.split(' ');
//select filter check box
await page.check(await filterCheckBox(attributeProductType.key, attributeProductType.value));
await page.check(await filterCheckBox(attributeMediaType.key, attributeMediaType.value));
await page.check(await filterCheckBox(attributeMultipleMediaTypes.key, attrCD));
await page.check(await filterCheckBox(attributeMultipleMediaTypes.key, attrDVD));

// Assert the filter checked state
expect(await page.isChecked(await filterCheckBox(attributeProductType.key, attributeProductType.value))).toBeTruthy()
expect(await page.isChecked(await filterCheckBox(attributeMediaType.key, attributeMediaType.value))).toBeTruthy()
//clicks on clear filter buttton
expect(await page.isChecked(await filterCheckBox(attributeMultipleMediaTypes.key, attrCD))).toBeTruthy()
expect(await page.isChecked(await filterCheckBox(attributeMultipleMediaTypes.key, attrDVD))).toBeTruthy()

//clicks on clear filter buttton
await page.click(pageObjectsConfig.clearFilterButton);

// Assert the filter checked state
expect(await page.isChecked(await filterCheckBox(attributeProductType.key, attributeProductType.value))).toBeFalsy()
expect(await page.isChecked(await filterCheckBox(attributeMediaType.key, attributeMediaType.value))).toBeFalsy()
expect(await page.isChecked(await filterCheckBox(attributeMultipleMediaTypes.key, attrCD))).toBeFalsy()
expect(await page.isChecked(await filterCheckBox(attributeMultipleMediaTypes.key, attrDVD))).toBeFalsy()

})

it('Select batch attributes filter and clicks on Apply filters button and refine the search', async () => {
await InsertSearchText(page, attributeProductType.value);
await InsertSearchText(page, attributeMultipleMediaTypes.value);

await page.waitForSelector(pageObjectsConfig.searchResultTableSelector);
await ExpectAllResultsHaveBatchUserAttValue(page, attributeProductType.value);
await ExpectAllResultsContainAnyBatchUserAttValue(page, attributeMultipleMediaTypes.value.split(' '));
//select batch attributes filter
await page.check(await filterCheckBox(attributeProductType.key, attributeProductType.value));
await page.check(await filterCheckBox(attributeMediaType.key, attributeMediaType.value));

await page.check(await filterCheckBox(attributeMultipleMediaTypes.key, attributeMultipleMediaTypes.value.split(' ')[0]));

// Assert the filter checked state
expect(await page.isChecked(await filterCheckBox(attributeProductType.key, attributeProductType.value))).toBeTruthy()
expect(await page.isChecked(await filterCheckBox(attributeMediaType.key, attributeMediaType.value))).toBeTruthy()

//clicks on clear filter buttton
expect(await page.isChecked(await filterCheckBox(attributeMultipleMediaTypes.key, attributeMultipleMediaTypes.value.split(' ')[0]))).toBeTruthy()

//clicks on clear filter buttton
await page.click(pageObjectsConfig.applyFilterButton);

await page.waitForSelector(pageObjectsConfig.searchResultTableSelector);
await ExpectAllResultsContainBatchUserAttValue(page,attributeProductType.value);
await ExpectAllResultsContainBatchUserAttValue(page,attributeMediaType.value);
await ExpectAllResultsContainBatchUserAttValue(page, attributeMultipleMediaTypes.value.split(' ')[0]);

})

it('Search multiple batch attributes and select filter and Apply filters button returned refined search', async () => {
Expand Down
1 change: 1 addition & 0 deletions Tests/FunctionalTests/helperconstant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const attributeProductType: BatchAttribute = { key: 'Product Type', value
export const attributeFileSize: BatchAttribute = {key: 'FileSize', value: '1000'};
export const attributeMimeType: BatchAttribute = {key: 'MimeType', value: 'text/plain'};
export const attributeMediaType: BatchAttribute = {key: 'Media Type', value: 'DVD'};
export const attributeMultipleMediaTypes: BatchAttribute = {key: 'Media Type', value: 'CD DVD'};
export const attributeMultipleMediaType: BatchAttribute = {key: 'Media Type', value: 'CD DVD'};

export const searchNonExistBatchAttribute = 'pqtestresult';
Expand Down
32 changes: 16 additions & 16 deletions Tests/UnitTests/fss-search.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ describe('FssSearchComponent', () => {
"batchAttributes": [
{
"attributeSortType":"alphabetical",
"attribute":"product",
"attribute":"Media Type",
"sortOrder":"ascending"
},
{
"attributeSortType":"alphabetical",
"attribute":"cellname",
"sortOrder":"ascending"
"attribute":"Year / Week",
"sortOrder":"descending"
},
{
"attributeSortType":"numeric",
"attribute":"Year / Week",
"attribute":"Year",
"sortOrder":"descending"
}
]
Expand All @@ -80,7 +80,7 @@ describe('FssSearchComponent', () => {

it('should have filterGroups ordered to match the configuration after transformSearchAttributesToFilter is called', () => {
const batchAttributesFromConfig = AppConfigService.settings["fssConfig"].batchAttributes;
//as we defined 3 attributes in test configuration, i.e. "batchAttributes": ["product","cellname","Year / Week"]
//as we defined 3 attributes in test configuration, i.e. "batchAttributes": ["Media Type","Year","Year / Week"]
const expectedFilterGroupLengthFromConfig = 3;
component.transformSearchAttributesToFilter(inputSearchResultMockData);
expect(component.filterGroups.length).toEqual(expectedFilterGroupLengthFromConfig);
Expand All @@ -93,27 +93,27 @@ describe('FssSearchComponent', () => {
export const inputSearchResultMockData: any =
[
{
"key": "product",
"key": "Media Type",
"values": [
"avcs"
"CD",
"DVD",
"ZIP"
]
},
{
"key": "product-name",
"key": "Year",
"values": [
"AVCS"
"2022",
"2021",
"2020"
]
},
{
"key": "YEAR / week",
"values": [
"2022 / 10"
]
},
{
"key": "cellname",
"values": [
"AVCS"
"2022 / 10",
"2022 / 11",
"2021 / 10"
]
}
]
Expand Down
14 changes: 8 additions & 6 deletions src/app/features/fss-search/fss-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,16 @@ export class FssSearchComponent implements OnInit {
configAttributes = AppConfigService.settings["fssConfig"].batchAttributes;

if (configAttributes.length > 0 && attributeSearchResults.length > 0) {
for(let element of configAttributes){
for(let element of configAttributes) {
const attribute = attributeSearchResults.find((searchResult: { key: any; }) => searchResult.key.toLowerCase() === element.attribute.toLowerCase());
if (attribute) {
this.filterGroups.push({
title: element.attribute,
items: this.getAttributesValues(attribute["values"], element.attributeSortType, element.sortOrder),
expanded: true
});
if(attribute["values"].length > 1) {
this.filterGroups.push({
title: element.attribute,
items: this.getAttributesValues(attribute["values"], element.attributeSortType, element.sortOrder),
expanded: true
});
}
}
}
}
Expand Down