-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RFR] Archetypes pagination test (#852)
* Archetype Pagination test Signed-off-by: Shveta Sachdeva <[email protected]> * Archetype Pagination test Signed-off-by: Shveta Sachdeva <[email protected]> * Archetype Pagination test Signed-off-by: Shveta Sachdeva <[email protected]> * Archetype Pagination test Signed-off-by: Shveta Sachdeva <[email protected]> * Archetype Pagination test Signed-off-by: Shveta Sachdeva <[email protected]> * Archetype Pagination test Signed-off-by: Shveta Sachdeva <[email protected]> * Archetype 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
Showing
3 changed files
with
260 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
Copyright © 2021 the Konveyor Contributors (https://konveyor.io/) | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
import { | ||
clickByText, | ||
cancelForm, | ||
inputText, | ||
selectFormItems, | ||
selectItemsPerPage, | ||
selectUserPerspective, | ||
submitForm, | ||
click, | ||
} from "../../../../utils/utils"; | ||
import { migration, trTag } from "../../../types/constants"; | ||
import { navMenu } from "../../../views/menu.view"; | ||
import { Stakeholdergroups } from "../controls/stakeholdergroups"; | ||
import { Stakeholders } from "../controls/stakeholders"; | ||
import * as archetype from "../../../views/archetype.view"; | ||
import { sideKebabMenu } from "../../../views/applicationinventory.view"; | ||
import { actionMenuItem, confirmButton } from "../../../views/common.view"; | ||
|
||
export interface Archetype { | ||
name: string; | ||
criteriaTags: string[]; | ||
archetypeTags: string[]; | ||
description?: string; | ||
stakeholders?: Stakeholders[]; | ||
stakeholderGroups?: Stakeholdergroups[]; | ||
comments?: string; | ||
} | ||
|
||
export class Archetype { | ||
constructor( | ||
name: string, | ||
criteriaTags: string[], | ||
archetypeTags: string[], | ||
description?: string, | ||
stakeholders?: Stakeholders[], | ||
stakeholderGroups?: Stakeholdergroups[], | ||
comments?: string | ||
) { | ||
this.name = name; | ||
this.criteriaTags = criteriaTags; | ||
this.archetypeTags = archetypeTags; | ||
this.description = description; | ||
this.stakeholders = stakeholders; | ||
this.stakeholderGroups = stakeholderGroups; | ||
this.comments = comments; | ||
} | ||
|
||
static fullUrl = Cypress.env("tackleUrl") + "/archetypes"; | ||
|
||
public static open(forceReload = false) { | ||
if (forceReload) { | ||
cy.visit(Archetype.fullUrl); | ||
} | ||
cy.url().then(($url) => { | ||
if (!$url.includes(Archetype.fullUrl)) { | ||
selectUserPerspective(migration); | ||
clickByText(navMenu, "Archetypes"); | ||
selectItemsPerPage(100); | ||
} | ||
}); | ||
} | ||
|
||
protected fillName(name: string): void { | ||
inputText(archetype.name, name); | ||
} | ||
|
||
protected selectCriteriaTags(tags: string[]): void { | ||
tags.forEach(function (tag) { | ||
selectFormItems(archetype.criteriaTags, tag); | ||
}); | ||
} | ||
|
||
protected selectArchetypeTags(tags: string[]): void { | ||
tags.forEach(function (tag) { | ||
selectFormItems(archetype.archetypeTags, tag); | ||
}); | ||
} | ||
|
||
protected fillDescription(description: string): void { | ||
inputText(archetype.description, description); | ||
} | ||
|
||
protected selectStakeholders(stakeholders: Stakeholders[]) { | ||
stakeholders.forEach((stakeholder) => { | ||
inputText(archetype.stakeholders, stakeholder.name); | ||
cy.get("button").contains(stakeholder.name).click(); | ||
}); | ||
} | ||
|
||
protected selectStakeholderGroups(stakeholderGroups: Stakeholdergroups[]) { | ||
stakeholderGroups.forEach((stakeholderGroup) => { | ||
inputText(archetype.stakeholderGroups, stakeholderGroup.name); | ||
cy.get("button").contains(stakeholderGroup.name).click(); | ||
}); | ||
} | ||
|
||
protected fillComment(comments: string): void { | ||
inputText(archetype.comments, comments); | ||
} | ||
|
||
create(cancel = false): void { | ||
Archetype.open(); | ||
cy.contains("button", "Create new archetype").should("be.enabled").click(); | ||
if (cancel) { | ||
cancelForm(); | ||
} else { | ||
this.fillName(this.name); | ||
this.selectCriteriaTags(this.criteriaTags); | ||
this.selectArchetypeTags(this.archetypeTags); | ||
if (this.description) this.fillDescription(this.description); | ||
if (this.stakeholders) this.selectStakeholders(this.stakeholders); | ||
if (this.stakeholderGroups) this.selectStakeholderGroups(this.stakeholderGroups); | ||
} | ||
if (this.comments) this.fillComment(this.comments); | ||
submitForm(); | ||
} | ||
|
||
delete(cancel = false): void { | ||
Archetype.open(); | ||
cy.contains(this.name) | ||
.closest(trTag) | ||
.within(() => { | ||
click(sideKebabMenu); | ||
}); | ||
cy.get(actionMenuItem).contains("Delete").click(); | ||
if (cancel) { | ||
cancelForm(); | ||
} else click(confirmButton); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright © 2021 the Konveyor Contributors (https://konveyor.io/) | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
/// <reference types="cypress" /> | ||
|
||
import { | ||
createMultipleArchetypes, | ||
deleteAllArchetypes, | ||
deleteAllRows, | ||
goToLastPage, | ||
itemsPerPageValidation, | ||
login, | ||
selectItemsPerPage, | ||
validatePagination, | ||
} from "../../../../utils/utils"; | ||
import { Archetype } from "../../../models/migration/archetypes/archetype"; | ||
|
||
describe(["@tier3"], "Archetypes pagination validations", function () { | ||
before("Login and Create Test Data", function () { | ||
login(); | ||
createMultipleArchetypes(11); | ||
}); | ||
|
||
it("Navigation button validations", function () { | ||
Archetype.open(); | ||
selectItemsPerPage(10); | ||
validatePagination(); | ||
}); | ||
|
||
it("Items per page validations", function () { | ||
Archetype.open(); | ||
itemsPerPageValidation(); | ||
}); | ||
|
||
it("Last page item(s) deletion, impact on page reload validation", function () { | ||
Archetype.open(); | ||
selectItemsPerPage(10); | ||
goToLastPage(); | ||
deleteAllRows(); | ||
// Verify that page is re-directed to previous page | ||
cy.get("td[data-label=Name]").then(($rows) => { | ||
cy.wrap($rows.length).should("eq", 10); | ||
}); | ||
}); | ||
|
||
after("Perform test data clean up", function () { | ||
deleteAllArchetypes(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters