Skip to content

Commit

Permalink
Fixed assessment/crud test
Browse files Browse the repository at this point in the history
Solved by making `click()` function to select first element instead of searching all.
Added parameter to specify which element number user wants to click instead of first one.

Signed-off-by: Igor Braginsky <[email protected]>
  • Loading branch information
ibragins committed Sep 3, 2023
1 parent c963936 commit 5f9ba12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ export class Application {
): void {
cy.wait(2000);
performRowActionByIcon(this.name, editButton);
// cy.contains(this.name, { timeout: 120 * SEC })
// .closest(trTag)
// .within(() => {
// click(editButton);
// });

if (cancel) {
cancelForm();
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/views/applicationinventory.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export const cyclicDependenciesErrorMsg = "cyclic dependencies are not allowed";
export const northdependenciesDropdownBtn = "button[aria-label='northbound-dependencies-toggle']";
export const southdependenciesDropdownBtn = "button[aria-label='southbound-dependencies-toggle']";
export const date = "Date";
export const editButton =
"td[class='pf-v5-c-table__td pf-v5-c-table__inline-edit-action'] > button";
export const editButton = "td[class='pf-v5-c-table__td pf-v5-c-table__action'] > button";
export const importStatus = "Status";
export const northboundHelper = "div[id=northbound-dependencies-helper]";
export const southboundHelper = "div[id=southbound-dependencies-helper]";
Expand Down
20 changes: 12 additions & 8 deletions cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,34 @@ export function clickByText(
cy.wait(SEC, { log });
}

export function click(fieldId: string, isForced = true, log = false): void {
export function click(fieldId: string, isForced = true, log = false, number = 0): void {
if (!log) {
cy.log(`Click ${fieldId}`);
}
cy.get(fieldId, { log, timeout: 30 * SEC }).click({ log, force: isForced });
cy.get(fieldId, { log, timeout: 30 * SEC })
.eq(number)
.click({ log, force: isForced });
}

export function clickWithFocus(fieldId: string, isForced = true, log = false): void {
export function clickWithFocus(fieldId: string, isForced = true, log = false, number = 0): void {
if (!log) {
cy.log(`Click ${fieldId}`);
}
cy.get(fieldId, { log, timeout: 30 * SEC })
.eq(number)
.focus()
.click({ log, force: isForced });
}

export function clickJs(fieldId: string, isForced = true, log = false): void {
export function clickJs(fieldId: string, isForced = true, log = false, number = 0): void {
if (!log) {
cy.log(`Click ${fieldId}`);
}
cy.get(fieldId, { log, timeout: 30 * SEC }).then(($obj) => {
$obj[0].click();
});
cy.get(fieldId, { log, timeout: 30 * SEC })
.eq(number)
.then(($obj) => {
$obj[0].click();
});
}

export function submitForm(): void {
Expand Down Expand Up @@ -913,7 +918,6 @@ export function performRowAction(itemName: string, action: string): void {
export function performRowActionByIcon(itemName: string, action: string): void {
// itemName is the text to be searched on the screen (For eg: application name, etc)
// Action is the name of the action to be applied (For eg: edit or click kebab menu)
selectItemsPerPage(100);
cy.contains(itemName, { timeout: 120 * SEC })
.closest(trTag)
.within(() => {
Expand Down

0 comments on commit 5f9ba12

Please sign in to comment.