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

[RFR] Initial commit for issues functionality #736

Merged
merged 7 commits into from
Oct 16, 2023
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
62 changes: 62 additions & 0 deletions cypress/e2e/models/migration/dynamicreports/issue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {
click,
clickByText,
clickWithinByText,
getUrl,
inputText,
selectFilter,
selectItemsPerPage,
selectUserPerspective,
} from "../../../../utils/utils";
import { button, filterIssue, migration, SEC } from "../../../types/constants";
import { navMenu } from "../../../views/menu.view";
import { searchButton, span } from "../../../views/common.view";
import {
appFilterName,
bsFilterName,
categoryFilterName,
sourceFilterName,
tagFilterName,
targetFilterName,
} from "../../../views/issue.view";

export class Issue {
/** Contains URL of issues web page */
static fullUrl = Cypress.env("tackleUrl") + "/issues";
abrugaro marked this conversation as resolved.
Show resolved Hide resolved

public static openList(itemsPerPage = 100, forceReload = false): void {
if (forceReload) {
abrugaro marked this conversation as resolved.
Show resolved Hide resolved
cy.visit(Issue.fullUrl);
}
if (!getUrl().includes(Issue.fullUrl)) {
selectUserPerspective(migration);
}
clickByText(navMenu, "Issues");
cy.wait(2 * SEC);
selectItemsPerPage(itemsPerPage);
abrugaro marked this conversation as resolved.
Show resolved Hide resolved
}

public static filterBy(item: string, itemName: string | string[]): void {
//TODO: Refactor this after bug https://issues.redhat.com/browse/MTA-1465 will be fixed
const selectorMap: Record<string, string> = {
[filterIssue.appName]: appFilterName,
[filterIssue.category]: categoryFilterName,
[filterIssue.source]: sourceFilterName,
[filterIssue.target]: targetFilterName,
};

selectFilter(item);
if (selectorMap[item]) {
inputText(selectorMap[item], itemName);
click(searchButton);
} else if (item == filterIssue.bs && !Array.isArray(itemName)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can make dynamic Id's but okay for this PR.

click(bsFilterName);
clickWithinByText(bsFilterName, button, itemName);
} else if (item == filterIssue.tags && Array.isArray(itemName)) {
click(tagFilterName);
itemName.forEach((name) => {
clickWithinByText(tagFilterName, span, name);
});
}
}
abrugaro marked this conversation as resolved.
Show resolved Hide resolved
}
9 changes: 9 additions & 0 deletions cypress/e2e/types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,12 @@ export enum SortType {
ascending = "ascending",
descending = "descending",
}

export enum filterIssue {
appName = "Application name",
bs = "Business service",
tags = "Tags",
category = "Category",
source = "Source",
target = "Target",
}
3 changes: 2 additions & 1 deletion cypress/e2e/views/common.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const expandableRow = ".pf-c-expandable-row";
export const nameHelper = "span.pf-v5-c-helper-text__item-text";
export const filterToggleButton = "div.pf-c-dropdown > button.pf-c-dropdown__toggle";
export const filterInput = "input[type='search']";
export const searchButton = "button[aria-label='search button for search input']";
export const searchButton = "#search-button";
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

export const nextPageButton = "button[aria-label='Go to next page']";
export const prevPageButton = "button[aria-label='Go to previous page']";
export const lastPageButton = "button[aria-label='Go to last page']";
Expand All @@ -60,3 +60,4 @@ export const dropdownClearSelection = "pf-v5-c-select__toggle-clear";
export const footer = "footer";
export const manageImportsActionsButton = 'button[aria-label="Actions"]';
export const nextButton = "button[cy-data='next']";
export const span = "span";
6 changes: 6 additions & 0 deletions cypress/e2e/views/issue.view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const appFilterName = "#application.name-input";
export const bsFilterName = "#businessService.name-filter-value-select";
export const tagFilterName = "#tag.id-filter-value-select";
export const categoryFilterName = "#category-input";
export const sourceFilterName = "#source-input";
export const targetFilterName = "#target-input";
4 changes: 4 additions & 0 deletions cypress/fixtures/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@
"sourceRepo": "https://github.com/konveyor/example-applications",
"branch": "main",
"rootPath": "example-1"
},
"day-trader-app": {
"repoType": "Git",
"sourceRepo": "https://github.com/WASdev/sample.daytrader7"
}
}
6 changes: 2 additions & 4 deletions cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,8 @@ export function selectFilter(filterName: string, identifiedRisk?: boolean, value
cy.get(commonView.selectFilter)
.eq(value)
.within(() => {
cy.get("#filtered-by").click();
cy.get("div.pf-v5-c-menu__content").within(() => {
clickByText("span", filterName);
});
click("#filtered-by");
clickWithinByText('div[aria-labelledby="filtered-by"]', "a", filterName);
});
}

Expand Down