Skip to content

Commit

Permalink
Checking task details via the status link (#1297)
Browse files Browse the repository at this point in the history
Signed-off-by: Maayan Hadasi <[email protected]>
  • Loading branch information
mguetta1 authored Dec 23, 2024
1 parent c59b03d commit 3108569
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 11 deletions.
48 changes: 37 additions & 11 deletions cypress/e2e/models/migration/task-manager/task-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
click,
clickByText,
inputText,
normalizeText,
selectFilter,
selectItemsPerPage,
selectUserPerspective,
Expand All @@ -31,6 +32,7 @@ import {
migration,
TaskFilter,
trTag,
MIN,
} from "../../../types/constants";
import { sideKebabMenu } from "../../../views/applicationinventory.view";
import {
Expand All @@ -40,7 +42,11 @@ import {
searchInput,
} from "../../../views/common.view";
import { navMenu } from "../../../views/menu.view";
import { tasksStatusColumn } from "../../../views/taskmanager.view";
import {
taskDetailsEditor,
TaskManagerColumns,
tasksStatusColumn,
} from "../../../views/taskmanager.view";

export class TaskManager {
static fullUrl = Cypress.env("tackleUrl") + "/tasks";
Expand All @@ -64,14 +70,19 @@ export class TaskManager {
selectItemsPerPage(itemsPerPage);
}

static verifyTaskStatus(application: string, kind: TaskKind, status: TaskStatus): void {
static verifyTaskStatus(
application: string,
kind: TaskKind,
status: TaskStatus
): Cypress.Chainable {
TaskManager.open();
selectItemsPerPage(itemsPerPage);
cy.get(trTag)
return cy
.get(trTag)
.filter(':contains("' + application + '")')
.filter(':contains("' + kind + '")')
.within(() => {
cy.get(tasksStatusColumn).contains(status, { timeout: 30 * SEC });
return cy.get(tasksStatusColumn).contains(status, { timeout: 10 * MIN });
});
}

Expand Down Expand Up @@ -120,17 +131,32 @@ export class TaskManager {
): void {
TaskManager.open();
selectItemsPerPage(itemsPerPage);
cy.get(trTag)
.filter(':contains("' + TaskKind.analyzer + '")')
.filter(':contains("' + appName + '")')
.filter(':contains("' + status + '")')
.within(() => {
click(sideKebabMenu);
});
this.verifyTaskStatus(appName, TaskKind.analyzer, status).within(() => {
click(sideKebabMenu);
});
if (enabled) {
cy.get(kebabActionButton).contains("Cancel").click();
} else {
cy.get(kebabActionButton).contains("Cancel").should("not.be.enabled");
}
}

public static openTaskDetailsByStatus(
appName: string,
taskKind: TaskKind,
taskStatus: TaskStatus = TaskStatus.succeeded
) {
this.open(10, true);
this.verifyTaskStatus(appName, taskKind, taskStatus).within(() => {
cy.get(TaskManagerColumns.status).click();
});
cy.wait(2 * SEC);
cy.get(taskDetailsEditor)
.invoke("text")
.then((text) => {
const normalizedText = normalizeText(text);
expect(normalizedText).to.include(`kind: ${taskKind}`);
expect(normalizedText).to.include(`state: ${taskStatus}`);
});
}
}
62 changes: 62 additions & 0 deletions cypress/e2e/tests/migration/task-manager/task_details.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
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,
} from "../../../../utils/utils";
import { Analysis } from "../../../models/migration/applicationinventory/analysis";
import { TaskManager } from "../../../models/migration/task-manager/task-manager";
import { TaskKind } from "../../../types/constants";

describe(["@tier3"], "Task details validation", function () {
let application: Analysis;
before("Login", function () {
login();
deleteApplicationTableRows();
});

beforeEach("Load data", function () {
cy.fixture("application").then(function (appData) {
this.appData = appData;
});
cy.fixture("analysis").then(function (analysisData) {
this.analysisData = analysisData;
});
});

it("Open language-discovery details by clicking on the status link", function () {
application = new Analysis(
getRandomApplicationData("", {
sourceData: this.appData["bookserver-app"],
}),
getRandomAnalysisData(this.analysisData["source_analysis_on_bookserverapp"])
);
application.create();
TaskManager.openTaskDetailsByStatus(application.name, TaskKind.languageDiscovery);
});

it("Open tech-discovery details by clicking on the status link", function () {
TaskManager.openTaskDetailsByStatus(application.name, TaskKind.techDiscovery);
});

after("Perform test data clean up", function () {
deleteApplicationTableRows();
});
});
1 change: 1 addition & 0 deletions cypress/e2e/views/taskmanager.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export enum TaskManagerColumns {
createdBy = 'td[data-label="Created By"]',
}
export const tasksTable = "table[aria-label='Tasks table']";
export const taskDetailsEditor = "div[class='pf-v5-c-code-editor__code']";
9 changes: 9 additions & 0 deletions cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,3 +1965,12 @@ export function getUniqueNamesMap<T extends { name: string }>(instanceArrays: T[

return instanceMap;
}

/**
* Normalizes text by:
* - Collapsing all sequences of whitespace into a single space.
* - Trimming leading and trailing whitespace.
*/
export function normalizeText(text: string): string {
return text.replace(/\s+/g, " ").trim();
}

0 comments on commit 3108569

Please sign in to comment.