Skip to content

Commit

Permalink
[RFR] Automate TC 582 (#1185)
Browse files Browse the repository at this point in the history
* Automate TC 582

Signed-off-by: midays <midays@redhat.com>

* try with commented application creation

Signed-off-by: midays <midays@redhat.com>

* added before each clause

Signed-off-by: midays <midays@redhat.com>

* change clause type and name

Signed-off-by: midays <midays@redhat.com>

* change navTav selector

Signed-off-by: midays <midays@redhat.com>

* revert changes

Signed-off-by: midays <midays@redhat.com>

* revert changes

Signed-off-by: midays <midays@redhat.com>

* final changes passed

Signed-off-by: midays <midays@redhat.com>

* fix applicationList variable initialization

Signed-off-by: midays <midays@redhat.com>

* remove comment

Signed-off-by: midays <midays@redhat.com>

---------

Signed-off-by: midays <midays@redhat.com>
Signed-off-by: yael-spinner <yaels83191@gmail.com>
  • Loading branch information
midays authored and yael-spinner committed Nov 4, 2024
1 parent daadbc1 commit e0583ec
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,24 @@ limitations under the License.
*/
/// <reference types="cypress" />

import { login, getRandomApplicationData, sidedrawerTab } from "../../../../../utils/utils";
import {
login,
getRandomApplicationData,
sidedrawerTab,
deleteByList,
} from "../../../../../utils/utils";
import { Application } from "../../../../models/migration/applicationinventory/application";
import { SEC } from "../../../../types/constants";
import { labelTagText } from "../../../../views/applicationinventory.view";

let application: Application;
let applicationList: Application[] = [];

describe(["@tier2"], "Test if application language is discovered and tagged correctly", () => {
before("Login", function () {
login();
});

beforeEach("Load Data", function () {
cy.fixture("application").then(function (appData) {
this.appData = appData;
});
Expand All @@ -38,36 +46,62 @@ describe(["@tier2"], "Test if application language is discovered and tagged corr
Tooling: ["Maven"],
Framework: ["Quarkus"],
};
application = new Application(
const application = new Application(
getRandomApplicationData("Java_language_maven_tooling_quarkus_framework", {
sourceData: this.appData["Java_language_maven_tooling_quarkus_framework"],
})
);
application.create();
applicationList.push(application);
cy.wait(2 * SEC);
sidedrawerTab("Java_language_maven_tooling_quarkus_framework", "Tags");
cy.contains("No tags available", { timeout: 60 * SEC }).should("not.exist");
assertTagsInSection(sectionsTags);
});

it("Application written in java and typescript with Maven and NodeJS tooling ", function () {
// Automates Polarion MTA-582
const sectionsTags = {
Language: ["Java", "TypeScript"],
Tooling: ["Maven", "NodeJs", "Node.js"],
};
const application = new Application(
getRandomApplicationData("Java_TS_language_maven_nodeJS_tooling", {
sourceData: this.appData["Java_TS_language_maven_nodeJS_tooling"],
})
);
application.create();
applicationList.push(application);
cy.wait(2 * SEC);
sidedrawerTab("Java_TS_language_maven_nodeJS_tooling", "Tags");
cy.contains("No tags available", { timeout: 60 * SEC }).should("not.exist");
assertTagsInSection(sectionsTags);
});

afterEach("Persist session", function () {
Application.open(true);
});

after("Perform test data clean up", function () {
application.delete();
deleteByList(applicationList);
});

function assertTagsInSection(sectionsTags: {
Language: string[];
Tooling: string[];
Framework: string[];
Tooling?: string[];
Framework?: string[];
}): void {
Cypress._.forEach(sectionsTags, (tags, section) => {
cy.contains("h4", section)
.parentsUntil("section")
.next()
.within(() => {
tags.forEach((tag) => {
cy.contains(labelTagText, tag).should("have.length", 1);
if (section) {
cy.contains("h4", section)
.parentsUntil("section")
.next()
.within(() => {
tags.forEach((tag) => {
cy.contains(labelTagText, tag).should("have.length", 1);
});
});
});
}
});
}
});
4 changes: 4 additions & 0 deletions cypress/fixtures/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
"repoType": "Git",
"sourceRepo": "https://github.com/quarkusio/quarkus-super-heroes"
},
"Java_TS_language_maven_nodeJS_tooling": {
"repoType": "Git",
"sourceRepo": "https://github.com/pkaul/maven-typescript-example"
},
"java-example-app": {
"repoType": "Git",
"sourceRepo": "https://github.com/ibraginsky/book-server"
Expand Down

0 comments on commit e0583ec

Please # to comment.