Skip to content

Commit

Permalink
archetype CRUD tests (#854)
Browse files Browse the repository at this point in the history
* Add archetype update method

Signed-off-by: Nandini Chandra <[email protected]>

* Archetype CRUD tests

Signed-off-by: Nandini Chandra <[email protected]>

* Archetype CRUD tests

Signed-off-by: Nandini Chandra <[email protected]>

* Archetype CRUD tests

Signed-off-by: Nandini Chandra <[email protected]>

* Minor changes

Signed-off-by: Nandini Chandra <[email protected]>

---------

Signed-off-by: Nandini Chandra <[email protected]>
  • Loading branch information
nachandr authored Dec 1, 2023
1 parent 0a2916c commit 33a27a4
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 7 deletions.
64 changes: 57 additions & 7 deletions cypress/e2e/models/migration/applicationinventory/archetype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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.
*/
/// <reference types="cypress" />

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);
});
});
11 changes: 11 additions & 0 deletions cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 33a27a4

Please sign in to comment.