diff --git a/cypress/e2e/models/migration/applicationinventory/archetype.ts b/cypress/e2e/models/migration/applicationinventory/archetype.ts index 6d10dd8e7..518460be1 100644 --- a/cypress/e2e/models/migration/applicationinventory/archetype.ts +++ b/cypress/e2e/models/migration/applicationinventory/archetype.ts @@ -22,7 +22,7 @@ import { selectUserPerspective, submitForm, click, - clickItemInKebabMenu, + clickKebabMenuOptionArchetype, } from "../../../../utils/utils"; import { migration, SEC, trTag } from "../../../types/constants"; import { navMenu } from "../../../views/menu.view"; @@ -133,14 +133,64 @@ export class Archetype { delete(cancel = false): void { Archetype.open(); - cy.contains(this.name) - .closest(trTag) - .within(() => { - click(sideKebabMenu); - }); - cy.get(commonView.actionMenuItem).contains("Delete").click(); + clickKebabMenuOptionArchetype(this.name, "Delete"); if (cancel) { cancelForm(); } else click(commonView.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(); + } + } + } } diff --git a/cypress/e2e/tests/migration/applicationinventory/archetypes/crud.test.ts b/cypress/e2e/tests/migration/applicationinventory/archetypes/crud.test.ts new file mode 100644 index 000000000..01fc7fa1d --- /dev/null +++ b/cypress/e2e/tests/migration/applicationinventory/archetypes/crud.test.ts @@ -0,0 +1,82 @@ +/* +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 { + login, + exists, + createMultipleStakeholders, + createMultipleStakeholderGroups, + checkSuccessAlert, + createMultipleTags, + notExists, +} from "../../../../../utils/utils"; + +import { successAlertMessage } from "../../../../views/common.view"; +import * as data from "../../../../../utils/data_utils"; +import { Archetype } from "../../../../models/migration/applicationinventory/archetype"; +import { Stakeholders } from "../../../../models/migration/controls/stakeholders"; +import { Stakeholdergroups } from "../../../../models/migration/controls/stakeholdergroups"; +import { Tag } from "../../../../models/migration/controls/tags"; + +let stakeholders: Stakeholders[]; +let stakeholderGroups: Stakeholdergroups[]; +let tagList: Tag[]; + +describe(["@tier1"], "Archetype CRUD operations", () => { + before("Login", function () { + login(); + stakeholders = createMultipleStakeholders(2); + stakeholderGroups = createMultipleStakeholderGroups(2); + tagList = createMultipleTags(2); + }); + + // Automates Polarion MTA-395 + it("Archetype CRUD operations", function () { + const archetype = new Archetype( + data.getRandomWord(8), + [tagList[0].name], + [tagList[1].name], + null, + stakeholders, + stakeholderGroups + ); + archetype.create(); + checkSuccessAlert( + successAlertMessage, + `Success alert:Archetype ${archetype.name} was successfully created.`, + true + ); + exists(archetype.name); + + const updatedArchetypeName = data.getRandomWord(8); + archetype.edit({ name: updatedArchetypeName }); + checkSuccessAlert( + successAlertMessage, + `Success alert:Archetype was successfully saved.`, + true + ); + exists(updatedArchetypeName); + + archetype.delete(); + checkSuccessAlert( + successAlertMessage, + `Success alert:Archetype ${archetype.name} was successfully deleted.`, + true + ); + notExists(archetype.name); + }); +}); diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index 00ca9abe0..9e9945625 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -803,6 +803,17 @@ export function clickItemInKebabMenu(rowItem, itemName: string): void { cy.get(commonView.actionMenuItem).contains(itemName).click(); } +export function clickKebabMenuOptionArchetype(rowItem: string, itemName: string): void { + // The clickItemInKebabMenu() fn can't be used on the Archetype page just yet because the + // the individual archetypes don't have an id for their kebab menu. + cy.contains(rowItem) + .closest(trTag) + .within(() => { + click(sideKebabMenu); + }); + cy.get(commonView.actionMenuItem).contains(itemName).click(); +} + export function createMultipleJiraConnections( numberOfJiras: number, jiraCredential: JiraCredentials,