/* * This file is part of LibrePlan * * Copyright (C) 2011 Igalia, S.L. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ /* Included tests * * 1 - Create a new Virtual Worker * 2 - Create a Virtual Worker with duplicate type (it should be a failure) * 3 - Create a Virtual Worker with empty type (it should be a failure) * 4 - Create a Virtual Worker with duplicate name (it should be a failure) * 5 - Edit a Virtual Worker * 6 - Check other tabs * 6.1 - Check assigned criteria tab * 6.1.1 - Create a criterion * 6.1.2 - Assign this criterion to the Virtual worker * 6.1.3 - Try to delete the criterion * 6.2 - Check assigned calendar tab * 6.2.1 - Create a calendar * 6.2.2 - Assign this calendar to the Virtual worker * 6.2.3 - Try to delete the calendar * 6.3 - Check assigned cost category tab * 6.3.1 - Create a work hour * 6.3.2 - Create a cost category * 6.3.3 - Assign this cost category to the Virtual worker * 6.3.4 - Try to delete the cost category * 7 - Try create a Virtual worker without Code * 7.1 - Change configuration * 7.2 - create a Virtual worker without Code (it should be a failure) * 8 - Assign the virtual worker in a project * 8.1 - Create a project * 8.2 - Create a task * 8.3 - Assign the virtual worker in limiting resource form * 8.4 - Try to delete the asigned Virtual worker * 8.5 - Delete the Project * 9 - Delete Virtual Worker * 10 - Delete all required elements * */ _include("../common_functions.sah"); function virtualWorkerCreateDuplicateType($name) { commonVirtualWorkerGoToCreate(); commonVirtualWorkerForm($name); virtualWorkerNotValid($name); _log("Create a duplicate virtual worker", "custom1"); } function virtualWorkerCreateEmpty($name) { commonVirtualWorkerGoToCreate(); commonVirtualWorkerForm(""); _log("Create a empty virtual worker", "custom1"); } function virtualWorkerEdit($oldName, $newName, $cell) { commonEdit($oldName, $cell); commonVirtualWorkerForm($newName); commonVirtualWorkerAcctionValidation("saved"); _log("Edit a virtual worker", "custom1"); } function virtualWorkerCheckCode($name){ commonConfigurationChangeCheckboxMainPreferences("Resources"); virtualWorkerCreateWithoutCode($name); commonConfigurationChangeCheckboxMainPreferences("Resources"); _log("Check code label", "custom1"); } function virtualWorkerCreateWithoutCode($name){ commonVirtualWorkerGoToCreate(); commonVirtualWorkerForm($name); commonEmptyCodeValidation(); } function virtualWorkerCheckTabs(){ virtualWorkerCheckAssignedCriteria($workerNewName, 3, $criteriaName); virtualWorkerCheckAssignedCalendar($workerNewName, 3, $calendarName); virtualWorkerCheckAssignedCostCategory($workerNewName, 3, $costCategoryName); } function virtualWorkerCheckAssignedCriteria($workerName, $cell, $criterion){ commonCriteriaCreate($criteriaName, [$criteriaName]); commonResourceEditAssignedCriteriaForm("Virtual Workers", $workerName, $cell, $criterion); commonCriteriaTryDeleteAssigned($criteriaName); } function virtualWorkerCheckAssignedCalendar($workerName, $cell, $calendar){ commonCalendarCreate($calendar); commonResourceEditAssignedCalendarForm("Virtual Workers", $workerName, $cell, $calendar); commonCalendarTryDeleteAssignedCalendar($calendar, 3); } function virtualWorkerCheckAssignedCostCategory($workerName, $cell, $cCategory){ commonWorkHourCreate("HourForWorker", "12"); commonCostCategoryCreate($cCategory, "HourForWorker"); commonResourceEditAssignedCostCategoryForm("Virtual Workers", $workerName, $cell, $cCategory); commonVirtualWorkerAcctionValidation("saved"); _log("Assign the created cost category", "custom1"); commonCostCategoryTryDeleteAssignedCostCategory($cCategory, 3); } function virtualWorkerDeleteRequiredElements(){ commonCriteriaDelete($criteriaName); commonCalendarDelete($calendarName); commonCostCategoryDelete($costCategoryName); commonWorkHourDelete("HourForWorker"); _log("All required elements deleted", "custom1"); } function virtualWorkerAssignProject($project, $worker){ commonCreateProject($project); commonCreateTask($project, "taskForVirtual", "100"); virtualWorkerAssignProjectForm($worker); virtualWorkerTryDeleteAssigned($worker); commonDeleteProject($project); } function virtualWorkerAssignProjectForm($workerName){ _click(_cell("Project Scheduling")); _doubleClick(_div("box standard-task yui-resize unassigned")); _setValue(_textbox(0, _near(_span("Select criteria or resources"))), $workerName); _removeFocus(_textbox(0, _near(_span("Select criteria or resources")))); _click(_div($workerName)); _click(_cell($workerName)); _click(_cell("Add")); _click(_row("Accept[2]")); _assertExists(_div("box standard-task assigned")); _log("Task assigned", "custom1"); _click(_image("ico_save.png")); _click(_cell("OK")); } function virtualWorkerTryDeleteAssigned($worker){ _click(_link("Virtual Workers")); _click(_image("ico_borrar1.png", _in(_cell(3, _near(_cell($worker)))))); commonResourceTryDeleteAssignedValidation(); } /* Validations */ function virtualWorkerNotValid($worker){ _assertExists(_span("Virtual worker group name must be unique")); _assert(_isVisible(_span("Virtual worker group name must be unique"))); } /* test values */ var $workerName = "new"; var $workerSurName = "newSon"; var $workerID = "12345678"; var $workerName2 = "new2"; var $workerNewName = "newest"; var $criteriaName = "CriteriaForWorkers"; var $costCategoryName ="costCategoryForWorker" var $calendarName = "calendarForWorker" var $projectName = "projectForVirtual"; /* test actions */ commonLogin("admin", "admin"); commonVirtualWorkerCreate($workerName, $workerSurName, $workerID); virtualWorkerCreateDuplicateType($workerName, $workerSurName, $workerID); virtualWorkerCreateEmpty($workerName, $workerSurName, $workerID); virtualWorkerEdit($workerName, $workerNewName, 3); virtualWorkerCheckTabs(); virtualWorkerCheckCode($workerName, $workerSurName, $workerID) virtualWorkerAssignProject($projectName, $workerNewName); commonVirtualWorkerDelete($workerNewName); virtualWorkerDeleteRequiredElements(); commonLogout();