217 lines
7.4 KiB
Text
217 lines
7.4 KiB
Text
/*
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/* Included tests
|
|
*
|
|
* 1 - Create a new Machine
|
|
* 2 - Create a Machine with empty name (it should be a failure)
|
|
* 3 - Edit a Machine
|
|
* 4 - Assign a criteria to a Machine
|
|
* 5.1 - Create a criteria
|
|
* 5.2 - Edit Assigned criteria tab
|
|
* 5.3 - Try to delete a assigned criteria
|
|
* 5 - Assign a calendar
|
|
* 5.1 - Create a calendar
|
|
* 5.2 - Edit Calendar tab
|
|
* 5.3 - Try to delete a assigned calendar
|
|
* 6 - Assign a cost category
|
|
* 6.1 - Create a cost category
|
|
* 6.2 - Edit cost category tab
|
|
* 6.3 - Try to delete a assigned cost category
|
|
* 7 - Try create a Machine without Code
|
|
* 7.1 - Change configuration
|
|
* 7.2 - Create a Machine without Code (it should be a failure)
|
|
* 8 - Assign the Machine in a project
|
|
* 8.1 - Create a project
|
|
* 8.2 - Create a task
|
|
* 8.3 - Assign the Machine in limiting resource form
|
|
* 8.4 - Try to delete the assigned Machine
|
|
* 8.5 - Delete the Project
|
|
* 9 - Delete Machine
|
|
* 10 - Delete all required elements
|
|
*
|
|
*/
|
|
_include("../common_functions.sah");
|
|
|
|
function machineCreateEmpty() {
|
|
commonCreate("Machines");
|
|
_click(_cell("Save"));
|
|
machineNameEmptyValidation();
|
|
_setValue(_textbox(0, _near(_span("Name"))), "something");
|
|
_click(_cell("Save"));
|
|
machineDescriptionEmptyValidation();
|
|
_log("Do not allow create a machine without name or description", "custom1");
|
|
}
|
|
|
|
function machineEdit($oldName, $newName, $cell) {
|
|
commonEdit($oldName, $cell);
|
|
_setValue(_textbox(0, _near(_span("Name"))), $newName);
|
|
_setValue(_textbox(0, _near(_span("Description"))), $newName);
|
|
_click(_cell("Save & Continue"));
|
|
commonSaveValidation("Machine", $newName);
|
|
_log("Edit the machine", "custom1");
|
|
}
|
|
|
|
function machineCheckCode($name){
|
|
commonConfigurationChangeCheckboxMainPreferences("Resources");
|
|
machineCreateWithoutCode($name);
|
|
commonConfigurationChangeCheckboxMainPreferences("Resources");
|
|
_log("Check code label", "custom1");
|
|
}
|
|
|
|
function machineCreateWithoutCode($type){
|
|
commonCreate("Machines");
|
|
commonMachineForm($type);
|
|
commonEmptyCodeValidation();
|
|
}
|
|
|
|
function machineCheckTabs(){
|
|
machineCheckAssignedCriteria($machineNewName, 4, $criteriaName);
|
|
machineCheckAssignedCalendar($machineNewName, 4, $calendarName);
|
|
machineCheckAssignedCostCategory($machineNewName, 4, $costCategoryName);
|
|
}
|
|
|
|
function machineCheckAssignedCriteria($machineName, $cell, $criterion){
|
|
criteriaCreate($criteriaName);
|
|
commonResourceEditAssignedCriteriaForm("Machines", $machineName, $cell, $criterion);
|
|
commonCriteriaTryDeleteAssigned($criteriaName);
|
|
}
|
|
|
|
function machineCheckAssignedCalendar($machineName, $cell, $calendar){
|
|
commonCalendarCreate($calendar);
|
|
commonResourceEditAssignedCalendarForm("Machines", $machineName, $cell, $calendar);
|
|
commonCalendarTryDeleteAssignedCalendar($calendar, 3);
|
|
}
|
|
|
|
function machineCheckAssignedCostCategory($machineName, $cell, $cCategory){
|
|
commonWorkHourCreate("HourForMachine", "12");
|
|
commonCostCategoryCreate($cCategory, "HourForMachine");
|
|
commonResourceEditAssignedCostCategoryForm("Machines", $machineName, $cell, $cCategory);
|
|
commonSaveValidation("Machine", $machineName);
|
|
_log("Assign the created cost category", "custom1");
|
|
commonCostCategoryTryDeleteAssignedCostCategory($cCategory, 3);
|
|
}
|
|
|
|
function machineDeleteRequiredElements(){
|
|
commonCalendarDelete($calendarName);
|
|
commonCostCategoryDelete($costCategoryName);
|
|
commonCriteriaDelete($criteriaName);
|
|
commonWorkHourDelete("HourForMachine");
|
|
_log("All required elements deleted", "custom1");
|
|
}
|
|
|
|
function machineAssignProject($project, $machine){
|
|
commonCreateProject($project);
|
|
commonCreateTask($project, "taskForMachine", "100");
|
|
machineAssignProjectForm($machine);
|
|
machineTryDeleteAssigned($machine);
|
|
commonDeleteProject($project);
|
|
}
|
|
|
|
function machineAssignProjectForm($machine){
|
|
_click(_cell("Project Scheduling"));
|
|
_doubleClick(_div("box standard-task yui-resize unassigned"));
|
|
_setValue(_textbox(0, _near(_span("Select criteria or resources"))), $machine);
|
|
_removeFocus(_textbox(0, _near(_span("Select criteria or resources"))));
|
|
_click(_div($machine));
|
|
_click(_cell($machine));
|
|
_click(_cell("Add"));
|
|
_setValue(_textbox(0, _near(_span("Total"))), "1");
|
|
_click(_row("Accept[2]"));
|
|
_assertExists(_div("box standard-task assigned"));
|
|
_log("Task assigned", "custom1");
|
|
_click(_image("ico_save.png"));
|
|
_click(_cell("OK"));
|
|
}
|
|
|
|
function machineTryDeleteAssigned($machine){
|
|
_click(_link("Machines"));
|
|
_click(_image("ico_borrar1.png", _in(_cell(5, _near(_cell($machine))))));
|
|
machineTryDeleteAssignedValidation();
|
|
}
|
|
|
|
/*
|
|
* Special Criteria form
|
|
*/
|
|
|
|
function criteriaCreate($type){
|
|
commonCreate("Criteria");
|
|
criteriaForm($type);
|
|
commonSaveValidation("Criterion Type", $type);
|
|
_log("Create a new criterion", "custom1");
|
|
}
|
|
|
|
function criteriaForm($name){
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
_click(_italic(0, _near(_span("Type"))));
|
|
_click(_cell("MACHINE", _near(_span("Type"))));
|
|
_click(_checkbox(0, _near(_div("Multiple values per resource"))));
|
|
_click(_checkbox(0, _near(_div("Hierarchy"))));
|
|
_click(_cell("OK"));
|
|
_setValue(_textbox(0, _near(_span("New criterion"))), $name);
|
|
_click(_cell("Add"));
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
/*
|
|
* Validation functions
|
|
* */
|
|
|
|
function machineNameEmptyValidation(){
|
|
_assertExists(_div("cannot be empty"));
|
|
_assert(_isVisible(_div("cannot be empty")));
|
|
}
|
|
|
|
function machineDescriptionEmptyValidation(){
|
|
_assertExists(_div("cannot be empty"));
|
|
_assert(_isVisible(_div("cannot be empty")));
|
|
}
|
|
|
|
function machineEmptyFields(){
|
|
_assertExists(_div("This field may not be empty or contain only spaces."));
|
|
_assert(_isVisible(_div("This field may not be empty or contain only spaces.")));
|
|
}
|
|
|
|
function machineTryDeleteAssignedValidation(){
|
|
_assertExists(_span("Machine cannot be deleted. Machine is allocated to a project or contains imputed hours"));
|
|
_assert(_isVisible(_span("Machine cannot be deleted. Machine is allocated to a project or contains imputed hours")));
|
|
}
|
|
|
|
/* test values */
|
|
var $machineName = "new";
|
|
var $machineDescription = "something new";
|
|
var $machineNewName = "newest";
|
|
var $criteriaName = "criteriaForMachine";
|
|
var $calendarName = "calendarForMachine";
|
|
var $costCategoryName = "costCategoryforMachines";
|
|
var $projectName = "ProjectForMachine";
|
|
|
|
/* test actions */
|
|
commonLogin("admin", "admin");
|
|
|
|
commonMachineCreate($machineName, $machineDescription);
|
|
machineCreateEmpty();
|
|
machineEdit($machineName, $machineNewName, 4);
|
|
machineCheckTabs();
|
|
machineCheckCode($machineName);
|
|
machineAssignProject($projectName, $machineNewName);
|
|
commonMachineDelete($machineNewName);
|
|
machineDeleteRequiredElements();
|
|
|
|
commonLogout();
|