Skip to content

Commit

Permalink
[RFR] Task manager enable premeption (#1220)
Browse files Browse the repository at this point in the history
* Task manager enable premeption

Signed-off-by: Shveta Sachdeva <[email protected]>

* Task manager enable premeption

Signed-off-by: Shveta Sachdeva <[email protected]>

* Task manager enable premeption

Signed-off-by: Shveta Sachdeva <[email protected]>

* Task manager enable premeption

Signed-off-by: Shveta Sachdeva <[email protected]>

* Task manager enable premeption

Signed-off-by: Shveta Sachdeva <[email protected]>

---------

Signed-off-by: Shveta Sachdeva <[email protected]>
  • Loading branch information
sshveta authored Sep 17, 2024
1 parent 5f87f94 commit c1a615f
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 3 deletions.
36 changes: 33 additions & 3 deletions cypress/e2e/models/migration/task-manager/task-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ limitations under the License.
/// <reference types="cypress" />

import {
clearAllFilters,
click,
clickByText,
inputText,
selectFilter,
selectItemsPerPage,
selectUserPerspective,
validateNumberPresence,
} from "../../../../utils/utils";
import {
SEC,
Expand All @@ -34,7 +32,8 @@ import {
TaskFilter,
trTag,
} from "../../../types/constants";
import { searchButton, searchInput } from "../../../views/common.view";
import { sideKebabMenu } from "../../../views/applicationinventory.view";
import { actionMenuItem, searchButton, searchInput } from "../../../views/common.view";
import { navMenu } from "../../../views/menu.view";
import { tasksStatusColumn } from "../../../views/taskmanager.view";

Expand Down Expand Up @@ -77,4 +76,35 @@ export class TaskManager {
click(searchButton);
cy.wait(2 * SEC);
}

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

TaskManager.open(10);
cy.contains("Pending")
.closest(trTag)
.within(() => {
click(sideKebabMenu);
});
cy.get(actionMenuItem).contains(setPreemption).click();
}

public static cancelTask(status: string): void {
TaskManager.open(10);
cy.contains(status)
.closest(trTag)
.within(() => {
click(sideKebabMenu);
});
if (
status == TaskStatus.pending ||
status == TaskStatus.running ||
status == TaskStatus.ready ||
status == TaskStatus.postponed
) {
cy.get(actionMenuItem).contains("Cancel").click();
} else {
cy.get(actionMenuItem).contains("Cancel").should("not.be.enabled");
}
}
}
81 changes: 81 additions & 0 deletions cypress/e2e/tests/migration/task-manager/miscellaneous.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
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 {
checkSuccessAlert,
deleteApplicationTableRows,
getRandomAnalysisData,
getRandomApplicationData,
login,
validateTextPresence,
} from "../../../../utils/utils";
import { Analysis } from "../../../models/migration/applicationinventory/analysis";
import { TaskManager } from "../../../models/migration/task-manager/task-manager";
import { TaskManagerColumns } from "../../../views/taskmanager.view";
import * as commonView from "../../../views/common.view";

describe(["@tier2"], "Actions in Task Manager Page", function () {
const applicationsList: 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("Test Enable and Disable Premeption", function () {
const bookServerApp = new Analysis(
getRandomApplicationData("TaskApp1_", {
sourceData: this.appData["bookserver-app"],
}),
getRandomAnalysisData(this.analysisData["analysis_for_openSourceLibraries"])
);
bookServerApp.create();
TaskManager.setPreemption(true);
checkSuccessAlert(commonView.infoAlertMessage, "Update request submitted.");
validateTextPresence(TaskManagerColumns.preemption, "true");
TaskManager.setPreemption(false);
checkSuccessAlert(commonView.infoAlertMessage, "Update request submitted.");
validateTextPresence(TaskManagerColumns.preemption, "false");
});

it("Cancel Task", function () {
const bookServerApp = new Analysis(
getRandomApplicationData("TaskApp1_", {
sourceData: this.appData["bookserver-app"],
}),
getRandomAnalysisData(this.analysisData["analysis_for_openSourceLibraries"])
);
bookServerApp.create();
TaskManager.cancelTask("Pending");
checkSuccessAlert(commonView.infoAlertMessage, "Cancelation request submitted");
validateTextPresence(TaskManagerColumns.status, "Canceled");
TaskManager.cancelTask("Running");
checkSuccessAlert(commonView.infoAlertMessage, "Cancelation request submitted");
validateTextPresence(TaskManagerColumns.status, "Canceled");
// Succeeded tasks cannot be cancelled.
TaskManager.cancelTask("Succeeded");
});
});

0 comments on commit c1a615f

Please sign in to comment.