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

[Draft] ✨ Adding tests for checking filter&sort abilities in application table #1238

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
SEC,
tags,
archetypes,
analysis,
} from "../../../../types/constants";

import * as data from "../../../../../utils/data_utils";
Expand Down Expand Up @@ -140,6 +141,16 @@ describe(["@tier3"], "Application inventory filter validations", function () {
clickByText(button, clearAllFilters);
});

it("Analysis filter validations",function(){
Copy link

Choose a reason for hiding this comment

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

nitpick: Analysis status filter validations

Application.open();
getFirstAnalysisColumnValue().then((firstValue) => {
cy.log("First Analysis column value: ", firstValue);
Copy link

Choose a reason for hiding this comment

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

nitpick: This line can be removed

applySearchFilter(analysis,firstValue);
Copy link

Choose a reason for hiding this comment

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

This test suite creates 2 applications at the beginning and does not analyze it so we can be sure that at least there is going to be one application with the "Not started" status.

In fact, there is a high probability only apps with "Not started" status exist when this test is executed, so maybe it would be a good idea to create an app then start and cancel an analysis on it so we have, at least, 2 statuses to correctly test the feature.

cy.wait(2000);
Copy link

Choose a reason for hiding this comment

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

I think we can remove this line and it should work anyway

exists(firstValue)
});
} );

it("Tag filter validations", function () {
Application.open();

Expand Down Expand Up @@ -368,3 +379,17 @@ const filterApplicationsBySubstring = (): void => {

clickByText(button, clearAllFilters);
};

// this function finds the analysis status of the first application
const getFirstAnalysisColumnValue = (): Cypress.Chainable<string> => {
return cy.get('table').then(($table) => {
const analysisColumnIndex = $table.find('th').toArray().findIndex(th => th.innerText.trim() === "Analysis");
if (analysisColumnIndex >= 0) {
return cy.get(`tbody tr td:nth-child(${analysisColumnIndex + 1})`).first().invoke('text').then((text) => {
return text.trim();
});
} else {
return cy.wrap("").then(() => "");
}
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
clickOnSortButton,
deleteByList,
} from "../../../../../utils/utils";
import { name, tags, SortType, businessService, SEC } from "../../../../types/constants";
import { name, tags, SortType, businessService, SEC, analysis } from "../../../../types/constants";
import * as data from "../../../../../utils/data_utils";
import { BusinessServices } from "../../../../models/migration/controls/businessservices";
import { Application } from "../../../../models/migration/applicationinventory/application";
Expand Down Expand Up @@ -74,6 +74,24 @@ describe(["@tier3"], "Application inventory sort validations", function () {
verifySortDesc(afterDescSortList, unsortedList);
});

it("Analysis status sort validations", function () {
Application.open();
// get unsorted list when page loads
const unsortedList = getTableColumnData(analysis);
// Sort the application inventory by Tag count in ascending order
clickOnSortButton(analysis, SortType.ascending);
cy.wait(2 * SEC);
// Verify that the application inventory table rows are displayed in ascending order
const afterAscSortList = getTableColumnData(analysis);
verifySortAsc(afterAscSortList, unsortedList);
// Sort the application inventory by analysis in descending order
clickOnSortButton(analysis, SortType.descending);
cy.wait(2000);
// Verify that the application inventory table rows are displayed in descending order
Copy link

Choose a reason for hiding this comment

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

The code is explanatory enough so we can remove the comments.

I think the cy.wait lineas can be removed as well

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are methods like verifySortAsc and verifySortDesc in utils which can be used directly .Please check.

Copy link
Author

Choose a reason for hiding this comment

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

used these methods here a well,
the verifySortDesc is only a verification function that checks that the filter works right,
after the application filters the apps by pressing on the filter button

const afterDescSortList = getTableColumnData(analysis);
verifySortDesc(afterDescSortList, unsortedList);
});

it("Business service sort validations", function () {
Application.open();

Expand Down
Loading