Skip to content

Commit

Permalink
Task manager: cancel analysis test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Maayan Hadasi <[email protected]>
  • Loading branch information
mguetta1 committed Nov 26, 2024
1 parent c5c3689 commit 6cf6c36
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 1 deletion.
28 changes: 27 additions & 1 deletion cypress/e2e/models/migration/task-manager/task-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ import {
trTag,
} from "../../../types/constants";
import { sideKebabMenu } from "../../../views/applicationinventory.view";
import { actionMenuItem, searchButton, searchInput } from "../../../views/common.view";
import {
actionMenuItem,
kebabActionButton,
searchButton,
searchInput,
} from "../../../views/common.view";
import { navMenu } from "../../../views/menu.view";
import { tasksStatusColumn } from "../../../views/taskmanager.view";

Expand Down Expand Up @@ -107,4 +112,25 @@ export class TaskManager {
cy.get(actionMenuItem).contains("Cancel").should("not.be.enabled");
}
}

public static cancelAnalysiskByStatus(
appName: string,
status: TaskStatus,
enabled = true
): void {
TaskManager.open();
selectItemsPerPage(itemsPerPage);
cy.get(trTag)
.filter(':contains("' + TaskKind.analyzer + '")')
.filter(':contains("' + appName + '")')
.filter(':contains("' + status + '")')
.within(() => {
click(sideKebabMenu);
});
if (enabled) {
cy.get(kebabActionButton).contains("Cancel").click();
} else {
cy.get(kebabActionButton).contains("Cancel").should("not.be.enabled");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
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 { getRandomUserData } from "../../../../utils/data_utils";
import {
deleteApplicationTableRows,
getRandomAnalysisData,
getRandomApplicationData,
login,
logout,
} from "../../../../utils/utils";
import { User } from "../../../models/keycloak/users/user";
import { UserArchitect } from "../../../models/keycloak/users/userArchitect";
import { UserMigrator } from "../../../models/keycloak/users/userMigrator";
import { Analysis } from "../../../models/migration/applicationinventory/analysis";
import { Application } from "../../../models/migration/applicationinventory/application";
import { TaskManager } from "../../../models/migration/task-manager/task-manager";
import { TaskKind, TaskStatus } from "../../../types/constants";

describe(["@tier2"], "Negative: cancel task created by another user", function () {
let userMigrator = new UserMigrator(getRandomUserData());
let userArchitect = new UserArchitect(getRandomUserData());
let applicationsList: Array<Analysis> = [];

before("Login", function () {
// Creating RBAC users
User.loginKeycloakAdmin();
userMigrator.create();
userArchitect.create();

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("Bug MTA-3819: Run analysis by admin and cancel by migrator user - should not be allowed", function () {
let application = new Analysis(
getRandomApplicationData("bookserverApp", {
sourceData: this.appData["bookserver-app"],
}),
getRandomAnalysisData(this.analysisData["source_analysis_on_bookserverapp"])
);
application.create();
application.analyze();

userMigrator.login();
TaskManager.cancelAnalysiskByStatus(application.name, TaskStatus.running, false);

logout();
userArchitect.login();
TaskManager.cancelAnalysiskByStatus(application.name, TaskStatus.running, false);
});
});
2 changes: 2 additions & 0 deletions cypress/e2e/types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ export enum TaskStatus {
succeeded = "Succeeded",
pending = "Pending",
running = "Running",
ready = "Ready",
postponed = "Postponed",
}

export enum TaskKind {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/views/common.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const helperBusiness = 'span[class*="helper-text__item"]';
export const stakeHolderGroupHelper = "div.pf-v5-c-helper-text";
export const actionMenuItem = "span.pf-v5-c-menu__item-text";
export const kebabMenuItem = "a.pf-c-dropdown__menu-item";
export const kebabActionButton = "li.pf-v5-c-menu__list-item";
export const commonTable = "table.pf-v5-c-table.pf-m-grid-md";
export const tableRowActions = ".pf-v5-c-table__tr.actions-row";
export const plainButton = "button.pf-v5-c-button.pf-m-plain";
Expand Down

0 comments on commit 6cf6c36

Please sign in to comment.