Skip to content

Commit

Permalink
Validate task links from application popover
Browse files Browse the repository at this point in the history
Signed-off-by: Maayan Hadasi <[email protected]>
  • Loading branch information
mguetta1 committed Jan 15, 2025
1 parent 18fcb8f commit 7d38f2d
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
details,
legacyPathfinder,
review,
TaskKind,
} from "../../../types/constants";
import { navMenu } from "../../../views/menu.view";
import {
Expand Down Expand Up @@ -921,4 +922,11 @@ export class Application {
cy.get(tdTag).contains(this.name).trigger("mouseenter").wait(4000);
cy.contains("View all tasks for the application").click({ force: true });
}

// Opens a task details from application popover
openTaskDetailsFromPopover(kind: TaskKind): void {
Application.open();
cy.get(tdTag).contains(this.name).trigger("mouseenter").wait(4000);
cy.contains(kind).click();
}
}
19 changes: 3 additions & 16 deletions cypress/e2e/models/migration/task-manager/task-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
selectFilter,
selectItemsPerPage,
selectUserPerspective,
taskDetailsSanity,
} from "../../../../utils/utils";
import {
SEC,
Expand Down Expand Up @@ -137,20 +138,6 @@ export class TaskManager {
}
}

private static taskDetailsSanity(appName: string, taskKind: TaskKind, taskStatus?: TaskStatus) {
cy.wait(2 * SEC);
cy.get(taskDetailsEditor)
.invoke("text")
.then((text) => {
const normalizedText = normalizeText(text);
expect(normalizedText).to.include(`name: ${appName}-${taskKind}`);
expect(normalizedText).to.include(`kind: ${taskKind}`);
if (taskStatus) {
expect(normalizedText).to.include(`state: ${taskStatus}`);
}
});
}

public static openTaskDetailsByStatus(
appName: string,
taskKind: TaskKind,
Expand All @@ -159,13 +146,13 @@ export class TaskManager {
TaskManager.open(10, true);
TaskManager.verifyTaskStatus(appName, taskKind, taskStatus);
TaskManager.getTaskRow(appName, taskKind).find(TaskManagerColumns.status).click();
TaskManager.taskDetailsSanity(appName, taskKind, taskStatus);
taskDetailsSanity(appName, taskKind, taskStatus);
}

public static openTaskDetailsByKebabMenu(appName: string, taskKind: TaskKind) {
TaskManager.open(10, true);
TaskManager.getTaskRow(appName, taskKind).find(sideKebabMenu).click();
cy.get(kebabActionButton).contains(taskDetails).click();
TaskManager.taskDetailsSanity(appName, taskKind);
taskDetailsSanity(appName, taskKind);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
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 {
deleteApplicationTableRows,
getRandomAnalysisData,
getRandomApplicationData,
login,
taskDetailsSanity,
} from "../../../../../utils/utils";
import { Analysis } from "../../../../models/migration/applicationinventory/analysis";
import { Application } from "../../../../models/migration/applicationinventory/application";
import { AnalysisStatuses, SEC, TaskKind } from "../../../../types/constants";

describe(["@tier3"], "Validate task links from application popover", function () {
let bookServerApp: Analysis;

before("Login", function () {
login();
deleteApplicationTableRows();
cy.fixture("application").then((appData) => {
cy.fixture("analysis").then((analysisData) => {
bookServerApp = new Analysis(
getRandomApplicationData("bookserver", {
sourceData: appData["bookserver-app"],
}),
getRandomAnalysisData(analysisData["source_analysis_on_bookserverapp"])
);
bookServerApp.create();
cy.wait(2 * SEC);
bookServerApp.analyze();
bookServerApp.verifyAnalysisStatus(AnalysisStatuses.completed);
});
});
});

it("Click the tech-discovery link in application popover - task details page should open", function () {
const taskKind = TaskKind.techDiscovery;
bookServerApp.openTaskDetailsFromPopover(taskKind);
taskDetailsSanity(bookServerApp.name, taskKind);
});

it("Click the language-discovery link in application popover - task details page should open", function () {
const taskKind = TaskKind.languageDiscovery;
bookServerApp.openTaskDetailsFromPopover(taskKind);
taskDetailsSanity(bookServerApp.name, taskKind);
});

it("Click the analyzer link in application popover - task details page should open", function () {
const taskKind = TaskKind.analyzer;
bookServerApp.openTaskDetailsFromPopover(taskKind);
taskDetailsSanity(bookServerApp.name, taskKind);
});

after("Perform test data clean up", function () {
Application.open(true);
deleteApplicationTableRows();
});
});
5 changes: 2 additions & 3 deletions cypress/e2e/tests/migration/task-manager/task_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe(["@tier1"], "Task Manager", () => {
validateTextPresence(TaskManagerColumns.application, applicationsList[1].name);
});

it("Navigation to the task manager page is allowed from the application table", function () {
it("Navigation to the task manager page is allowed from the application popover", function () {
applicationsList[0].openAllTasksLink();
validateTextPresence(TaskManagerColumns.application, applicationsList[0].name);
validateTextPresence(TaskManagerColumns.application, applicationsList[1].name, false);
Expand Down Expand Up @@ -107,7 +107,7 @@ describe(["@tier1"], "Task Manager", () => {
cy.wait("@getApplication", { timeout: 5 * SEC });
applicationsList.push(app);
TaskManager.open();
validateTextPresence(TaskManagerColumns.application, app.name, false);
notExists(app.name, tasksTable);
});

it("Delete an application - related tasks are deleted", function () {
Expand All @@ -119,7 +119,6 @@ describe(["@tier1"], "Task Manager", () => {
});

after("Perform test data clean up", function () {
cy.wait(2000);
Application.open(true);
deleteByList(applicationsList);
});
Expand Down
17 changes: 17 additions & 0 deletions cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import {
issueFilter,
save,
SortType,
TaskKind,
TaskStatus,
} from "../e2e/types/constants";
import {
date,
Expand Down Expand Up @@ -90,6 +92,7 @@ import {
standardFilter,
submitButton,
successAlertMessage,
taskDetailsEditor,
} from "../e2e/views/common.view";
import { tagLabels, tagMenuButton } from "../e2e/views/tags.view";
import { Credentials } from "../e2e/models/administration/credentials/credentials";
Expand Down Expand Up @@ -1977,6 +1980,20 @@ export function normalizeText(text: string): string {
return text.replace(/\s+/g, " ").trim();
}

export function taskDetailsSanity(appName: string, taskKind: TaskKind, taskStatus?: TaskStatus) {
cy.wait(2 * SEC);
cy.get(taskDetailsEditor)
.invoke("text")
.then((text) => {
const normalizedText = normalizeText(text);
expect(normalizedText).to.include(`name: ${appName}`);
expect(normalizedText).to.include(`kind: ${taskKind}`);
if (taskStatus) {
expect(normalizedText).to.include(`state: ${taskStatus}`);
}
});
}

export function downloadTaskDetails(format = downloadFormatDetails.yaml) {
cy.url().should("include", "tasks");
cy.url().then((url) => {
Expand Down

0 comments on commit 7d38f2d

Please sign in to comment.