diff --git a/cypress/e2e/tests/migration/task-manager/manage_columns.test.ts b/cypress/e2e/tests/migration/task-manager/manage_columns.test.ts new file mode 100644 index 000000000..6af79b1f5 --- /dev/null +++ b/cypress/e2e/tests/migration/task-manager/manage_columns.test.ts @@ -0,0 +1,74 @@ +/* +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. +*/ +/// + +import { + clickByText, + login, + openManageColumns, + restoreColumnsToDefault, + selectColumns, + validateCheckBoxIsDisabled, + validateTextPresence, +} from "../../../../utils/utils"; +import { TaskManager } from "../../../models/migration/task-manager/task-manager"; +import { button, cancel, save } from "../../../types/constants"; +import { tableHead } from "../../../views/common.view"; +import { TaskManagerTableHeaders } from "../../../views/taskmanager.view"; + +describe(["@tier3"], "Task manager - table column management validation", function () { + const taskManagerDefaultColumns = Object.values(TaskManagerTableHeaders).slice(0, 6); + const columnsToSelect = [ + TaskManagerTableHeaders.pod, + TaskManagerTableHeaders.started, + TaskManagerTableHeaders.terminated, + ]; + + before("Login", function () { + login(); + }); + + it("Open task manager page - table default columns should be visible", function () { + TaskManager.open(); + taskManagerDefaultColumns.forEach((column) => validateTextPresence(tableHead, column)); + columnsToSelect.forEach((column) => validateTextPresence(tableHead, column, false)); + }); + + it("Select columns to display in the table view - they should be visible", function () { + // Check the unchecked columns and verify that all columns are visible + selectColumns(columnsToSelect); + Object.values(TaskManagerTableHeaders).forEach((column) => + validateTextPresence(tableHead, column) + ); + }); + + it("Validate ID checbox in the manage columns window is checked and disabled", function () { + openManageColumns(); + validateCheckBoxIsDisabled(TaskManagerTableHeaders.id, true); + clickByText(button, save); + }); + + it("Validate restoring columns to default", function () { + restoreColumnsToDefault(); + taskManagerDefaultColumns.forEach((column) => validateTextPresence(tableHead, column)); + }); + + it("Validate cancel button in the manage columns window", function () { + openManageColumns(); + clickByText(button, cancel); + taskManagerDefaultColumns.forEach((column) => validateTextPresence(tableHead, column)); + }); +}); diff --git a/cypress/e2e/views/common.view.ts b/cypress/e2e/views/common.view.ts index 7ad2f6101..da01fc665 100644 --- a/cypress/e2e/views/common.view.ts +++ b/cypress/e2e/views/common.view.ts @@ -59,6 +59,7 @@ 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 tableHead = "thead[class='pf-v5-c-table__thead']"; export const plainButton = "button.pf-v5-c-button.pf-m-plain"; export const dropdownClearSelection = "pf-v5-c-select__toggle-clear"; export const footer = "footer"; diff --git a/cypress/e2e/views/taskmanager.view.ts b/cypress/e2e/views/taskmanager.view.ts index e39f9e921..50d80f0ff 100644 --- a/cypress/e2e/views/taskmanager.view.ts +++ b/cypress/e2e/views/taskmanager.view.ts @@ -25,3 +25,15 @@ export enum TaskManagerColumns { createdBy = 'td[data-label="Created By"]', } export const tasksTable = "table[aria-label='Tasks table']"; +export enum TaskManagerTableHeaders { + id = "ID", + application = "Application", + status = "Status", + kind = "Kind", + priority = "Priority", + preemption = "Preemption", + createdBy = "Created By", + pod = "Pod", + started = "Started", + terminated = "Terminated", +} diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index 169a7ecef..290610655 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -1914,7 +1914,7 @@ export function validateCheckBoxIsDisabled(checkBoxText: string, isChecked?: boo } export function getCheckboxSelector(text: string) { - text = text.charAt(0).toLowerCase() + text.slice(1).replace(/\s+/g, ""); + text = text.toLowerCase().replace(/\s+/g, ""); return `input[aria-labelledby='check-${text}']`; }