Skip to content

Commit

Permalink
[RFR] Refactor all pagination (#855)
Browse files Browse the repository at this point in the history
* Refactor Pagination test

Signed-off-by: Shveta Sachdeva <[email protected]>

* Refactor Pagination test

Signed-off-by: Shveta Sachdeva <[email protected]>

* Refactor Pagination test

Signed-off-by: Shveta Sachdeva <[email protected]>

* Refactor Pagination test

Signed-off-by: Shveta Sachdeva <[email protected]>

---------

Signed-off-by: Shveta Sachdeva <[email protected]>
Co-authored-by: Shveta Sachdeva <[email protected]>
  • Loading branch information
sshveta and Shveta Sachdeva authored Dec 1, 2023
1 parent 33a27a4 commit bcf9af5
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 593 deletions.
196 changes: 0 additions & 196 deletions cypress/e2e/models/migration/applicationinventory/archetype.ts

This file was deleted.

62 changes: 57 additions & 5 deletions cypress/e2e/models/migration/archetypes/archetype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
selectUserPerspective,
submitForm,
click,
clickKebabMenuOptionArchetype,
} from "../../../../utils/utils";
import { migration, trTag } from "../../../types/constants";
import { navMenu } from "../../../views/menu.view";
Expand Down Expand Up @@ -132,14 +133,65 @@ export class Archetype {

delete(cancel = false): void {
Archetype.open();
cy.contains(this.name)
.closest(trTag)
.within(() => {
click(sideKebabMenu);
});
clickKebabMenuOptionArchetype(this.name, "Delete");
cy.get(actionMenuItem).contains("Delete").click();
if (cancel) {
cancelForm();
} else click(confirmButton);
}

edit(
updatedValues: {
name?: string;
criteriaTags?: string[];
archetypeTags?: string[];
description?: string;
stakeholders?: Stakeholders[];
stakeholderGroups?: Stakeholdergroups[];
comments?: string;
},
cancel = false
): void {
Archetype.open();
clickKebabMenuOptionArchetype(this.name, "Edit");

if (cancel) {
cancelForm();
} else {
if (updatedValues.name && updatedValues.name != this.name) {
this.fillName(updatedValues.name);
this.name = updatedValues.name;
}
if (updatedValues.description && updatedValues.description != this.description) {
this.fillDescription(updatedValues.description);
this.description = updatedValues.description;
}
if (updatedValues.criteriaTags && updatedValues.criteriaTags != this.criteriaTags) {
this.selectCriteriaTags(updatedValues.criteriaTags);
this.criteriaTags = updatedValues.criteriaTags;
}
if (updatedValues.archetypeTags && updatedValues.archetypeTags != this.archetypeTags) {
this.selectArchetypeTags(updatedValues.archetypeTags);
this.archetypeTags = updatedValues.archetypeTags;
}
if (updatedValues.stakeholders && updatedValues.stakeholders != this.stakeholders) {
this.selectStakeholders(updatedValues.stakeholders);
this.stakeholders = updatedValues.stakeholders;
}
if (
updatedValues.stakeholderGroups &&
updatedValues.stakeholderGroups != this.stakeholderGroups
) {
this.selectStakeholderGroups(updatedValues.stakeholderGroups);
this.stakeholderGroups = updatedValues.stakeholderGroups;
}
if (updatedValues.comments && updatedValues.comments != this.comments) {
this.fillComment(updatedValues.comments);
this.comments = updatedValues.comments;
}
if (updatedValues) {
submitForm();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import {
selectItemsPerPage,
deleteByList,
createMultipleApplications,
goToPage,
validatePagination,
itemsPerPageValidation,
} from "../../../../../utils/utils";
import * as commonView from "../../../../views/common.view";
import { Application } from "../../../../models/migration/applicationinventory/application";

let applicationsList: Array<Application> = [];
Expand All @@ -48,52 +47,9 @@ describe(["@tier3"], "Application inventory pagination validations", function ()
});

it("Items per page validations", function () {
// Navigate to Application inventory tab
Application.open();
cy.wait("@getApplications");

// Select 10 items per page
selectItemsPerPage(10);
cy.wait(2000);

// Verify that only 10 items are displayed
cy.get(commonView.appTable)
.find("td[data-label=Name]")
.then(($rows) => {
cy.wrap($rows.length).should("eq", 10);
});

// Select 20 items per page
selectItemsPerPage(20);
cy.wait(2000);

// Verify that items less than or equal to 20 and greater than 10 are displayed
cy.get(commonView.appTable)
.find("td[data-label=Name]")
.then(($rows) => {
cy.wrap($rows.length).should("be.lte", 20).and("be.gt", 10);
});
});

it("Page number validations", function () {
// Navigate to Application inventory tab
Application.open();
cy.wait("@getApplications");

// Select 10 items per page
selectItemsPerPage(10);
cy.wait(2000);

// Go to page number 2
goToPage(2);

// Verify that page number has changed, as previous page nav button got enabled
cy.get(commonView.prevPageButton).each(($previousBtn) => {
cy.wrap($previousBtn).should("not.be.disabled");
});

// Go back to page number 1
goToPage(1);
itemsPerPageValidation();
});

after("Perform test data clean up", function () {
Expand Down
Loading

0 comments on commit bcf9af5

Please sign in to comment.