Skip to content

Commit

Permalink
New TC (#1299)
Browse files Browse the repository at this point in the history
Signed-off-by: Maayan Hadasi <[email protected]>
  • Loading branch information
mguetta1 authored Dec 24, 2024
1 parent 3108569 commit d6ba101
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
69 changes: 40 additions & 29 deletions cypress/e2e/models/migration/task-manager/task-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import {
SEC,
TaskKind,
TaskStatus,
itemsPerPage,
migration,
TaskFilter,
trTag,
MIN,
taskDetails,
} from "../../../types/constants";
import { sideKebabMenu } from "../../../views/applicationinventory.view";
import {
Expand All @@ -52,7 +52,7 @@ export class TaskManager {
static fullUrl = Cypress.env("tackleUrl") + "/tasks";
static menuName = "Task Manager";

static open(itemsPerPage = 100, forceReload = false) {
static open(itemsPerPage = 10, forceReload = false) {
if (forceReload) {
cy.visit(TaskManager.fullUrl, { timeout: 15 * SEC }).then((_) =>
selectItemsPerPage(itemsPerPage)
Expand All @@ -70,20 +70,21 @@ export class TaskManager {
selectItemsPerPage(itemsPerPage);
}

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

public static verifyTaskStatus(application: string, kind: TaskKind, status: TaskStatus) {
TaskManager.open();
TaskManager.getTaskRow(application, kind)
.find(tasksStatusColumn)
.contains(status, { timeout: 10 * MIN });
}

public static applyFilter(filterType: TaskFilter, filterValue: string) {
Expand All @@ -95,8 +96,7 @@ export class TaskManager {

public static setPreemption(preemption: boolean): void {
const setPreemption = preemption === true ? "Enable preemption" : "Disable preemption";

TaskManager.open(10);
TaskManager.open();
cy.contains("Pending")
.closest(trTag)
.within(() => {
Expand All @@ -106,7 +106,7 @@ export class TaskManager {
}

public static cancelTask(status: string): void {
TaskManager.open(10);
TaskManager.open();
cy.contains(status)
.closest(trTag)
.within(() => {
Expand All @@ -130,33 +130,44 @@ export class TaskManager {
enabled = true
): void {
TaskManager.open();
selectItemsPerPage(itemsPerPage);
this.verifyTaskStatus(appName, TaskKind.analyzer, status).within(() => {
click(sideKebabMenu);
});
TaskManager.verifyTaskStatus(appName, TaskKind.analyzer, status);
TaskManager.getTaskRow(appName, TaskKind.analyzer).find(sideKebabMenu).click();
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();
});
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}`);
expect(normalizedText).to.include(`state: ${taskStatus}`);
if (taskStatus) {
expect(normalizedText).to.include(`state: ${taskStatus}`);
}
});
}

public static openTaskDetailsByStatus(
appName: string,
taskKind: TaskKind,
taskStatus: TaskStatus = TaskStatus.succeeded
) {
TaskManager.open(10, true);
TaskManager.verifyTaskStatus(appName, taskKind, taskStatus);
TaskManager.getTaskRow(appName, taskKind).find(TaskManagerColumns.status).click();
TaskManager.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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe(["@tier3"], "Filtering, sorting and pagination in Task Manager Page", f
});

it("Pagination validation", function () {
TaskManager.open(10);
TaskManager.open();
validatePagination();
});

Expand Down
5 changes: 5 additions & 0 deletions cypress/e2e/tests/migration/task-manager/task_details.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ describe(["@tier3"], "Task details validation", function () {
TaskManager.openTaskDetailsByStatus(application.name, TaskKind.techDiscovery);
});

it("Open task details from right kebab menu", function () {
TaskManager.openTaskDetailsByKebabMenu(application.name, TaskKind.languageDiscovery);
TaskManager.openTaskDetailsByStatus(application.name, TaskKind.techDiscovery);
});

after("Perform test data clean up", function () {
deleteApplicationTableRows();
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const reports = "Reports";
export const repositoryType = "Repository type";
export const save = "Save";
export const cancel = "Cancel";

export const taskDetails = "Task details";
export const stakeholders = "Stakeholders";
export const stakeholderGroups = "Stakeholder groups";
export const subversion = "Subversion";
Expand Down

0 comments on commit d6ba101

Please sign in to comment.