Adds work hours data type test
new file: scripts/functional-tests/data-types/work_hours_test.sah FEA: ItEr75S18DataTypesTests
This commit is contained in:
parent
bb41783930
commit
133578ea42
1 changed files with 243 additions and 0 deletions
243
scripts/functional-tests/data-types/work_hours_test.sah
Normal file
243
scripts/functional-tests/data-types/work_hours_test.sah
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* 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 Work Hour
|
||||
* 2 - Create a Work Hour with duplicate name (it should be a failure)
|
||||
* 3 - Create a Work Hour with empty name (it should be a failure)
|
||||
* 4 - Edit a Work Hour
|
||||
* 5 - Assign a work Hour to a project with Work Report Model
|
||||
* 5.1 - Create a new Work Report Models
|
||||
* 5.2 - Create a new proyect
|
||||
* 5.3 - Create a new Machine
|
||||
* 5.4 - Create a new Work Report and assign our Work hour and Work Report Models
|
||||
* 5.5 - Try to delete the assigned Work Hour (it should be a failure)
|
||||
* 5.6 - Try to delete the assigned Work Report Models (it should be a failure)
|
||||
* 5.7 - Try to delete the project (it should be a failure)
|
||||
* 5.8 - Delete the Work Report
|
||||
* 5.9 - Delete the project
|
||||
* 5.10 - Delete the machine
|
||||
* 5.11 - Delete the work report model
|
||||
* 6 - Delete Work Hour
|
||||
* 7 - Assign a work Hour to a Cost Category
|
||||
* 7.1 - Create a Work Hour again
|
||||
* 7.2 - Create a Cost Category and associate our Work Hour
|
||||
* 7.3 - Try to delete the Work Hour
|
||||
* 7.4 - Delete the Cost Category
|
||||
* 7.5 - Delete the Work Hour
|
||||
*/
|
||||
_include("../common_functions.sah");
|
||||
|
||||
function workHourCreate($type, $price){
|
||||
commonCreate("Work Hours");
|
||||
workHourForm($type, $price);
|
||||
commonSaveValidation("Type of hours", $type);
|
||||
_log("Create a new Work Hour SUCCESS", "success");
|
||||
}
|
||||
|
||||
function workHourCreateDuplicateType($type, $price){
|
||||
commonCreate("Work Hours");
|
||||
workHourForm($type, $price);
|
||||
workHourNotValid($type);
|
||||
_log("Do not allow create a duplicate Work Hour SUCCESS", "success");
|
||||
}
|
||||
|
||||
function workHourCreateEmpty(){
|
||||
commonCreate("Work Hours");
|
||||
workHourForm("", 10);
|
||||
_assertExists(_div("cannot be null or empty"));
|
||||
_assert(_isVisible(_div("cannot be null or empty")));
|
||||
_log("Do not allow create a empty Work Hour SUCCESS", "success");
|
||||
}
|
||||
|
||||
function workHourForm($name, $price){
|
||||
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
||||
_setValue(_textbox(0, _near(_span("Default price"))), $price);
|
||||
_click(_cell("Save"));
|
||||
}
|
||||
|
||||
/* test to check a that naval plan give us a error */
|
||||
function workHourNotValid($hWorkType){
|
||||
_assertExists(_span("checkConstraintUniqueName: the type of work hours name has to be unique. It is already used"));
|
||||
_assert(_isVisible(_span("checkConstraintUniqueName: the type of work hours name has to be unique. It is already used")));
|
||||
}
|
||||
|
||||
function workHourEdit($oldName, $newName, $hWorkPrice, $cell) {
|
||||
commonEdit($oldName, $cell);
|
||||
workHourForm($newName, $hWorkPrice);
|
||||
commonSaveValidation("Type of hours", $newName);
|
||||
_log("Edit the Work Hour SUCCESS", "success");
|
||||
}
|
||||
|
||||
function workHourAssign($hWorkNewName, $ModelName, $materialName, $materialDescription){
|
||||
reportModelCreate($ModelName);
|
||||
commonCreateProject("new project");
|
||||
machineCreate($materialName, $materialDescription);
|
||||
workReportCreate($materialName, "new project", $hWorkNewName);
|
||||
workHourTryDelete($hWorkNewName, "work report line");
|
||||
reportModelTryDelete($ModelName);
|
||||
commonTryDeleteProject("new project");
|
||||
commonDelete("Work Reports", $ModelName, 4);
|
||||
commonDeleteProject("new project");
|
||||
commonDelete("Machines", $materialName, 4);
|
||||
commonDeleteValidation("Machine", $materialName);
|
||||
commonDeleteValidation("Machine", $materialName);
|
||||
commonDelete("Work Report Models", $ModelName, 1);
|
||||
commonDeleteValidation("Work Report Type", $ModelName);
|
||||
}
|
||||
|
||||
function workHourTryDelete($hWorkNewName,$something){
|
||||
_click(_link("Work Hours"));
|
||||
_click(_image("ico_borrar1.png", _in(_cell(4, _near(_cell($hWorkNewName))))));
|
||||
_assertExists(_span("Cannot delete type of work hours. It is being used at this moment in some "+$something+"."));
|
||||
_assert(_isVisible(_span("Cannot delete type of work hours. It is being used at this moment in some "+$something+".")));
|
||||
_click(_cell("OK"));
|
||||
_log("Do not allow delete the Work Hour SUCCESS", "success");
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions of Maquines
|
||||
* */
|
||||
|
||||
function machineCreate($name, $description){
|
||||
commonCreate("Machines");
|
||||
machineForm($name, $description);
|
||||
commonSaveValidation("Machine", $name);
|
||||
_log("Create a new machine SUCCESS", "success");
|
||||
}
|
||||
|
||||
function machineForm($name, $description){
|
||||
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
||||
_setValue(_textbox(0, _near(_span("Description"))), $description);
|
||||
_click(_cell("Save"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions of Report Model
|
||||
* */
|
||||
|
||||
function reportModelCreate($modelName) {
|
||||
commonCreate("Work Report Models");
|
||||
reportModelForm($modelName);
|
||||
commonSaveValidation("Work Report Type", $modelName);
|
||||
_log("Create a Work Report Model SUCCESS", "success");
|
||||
}
|
||||
|
||||
function reportModelForm($name) {
|
||||
_setValue(_textbox(0, _near(_span("Name:"))), $name);
|
||||
_removeFocus(_textbox(0, _near(_span("Name:"))));
|
||||
_click(_cell("Save & Continue"));
|
||||
_click(_cell("Save"));
|
||||
}
|
||||
|
||||
function reportModelTryDelete($ModelName){
|
||||
_click(_link("Work Report Models"));
|
||||
_click(_image("ico_borrar1.png", _in(_cell(1, _near(_cell($ModelName))))));
|
||||
_assertExists(_span("Cannot delete work report type. There are some work reports bound to it."));
|
||||
_assert(_isVisible(_span("Cannot delete work report type. There are some work reports bound to it.")));
|
||||
_click(_cell("OK"));
|
||||
_log("Do not allow delete Work Report Model SUCCESS", "success");
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions of Work Report
|
||||
* */
|
||||
|
||||
function workReportCreate($wReport, $project, $workHour) {
|
||||
_click(_link("Work Reports"));
|
||||
workReportForm($wReport, $project, $workHour);
|
||||
_log("Create a Work Report SUCCESS", "success");
|
||||
}
|
||||
|
||||
function workReportForm($machine, $project, $workHour) {
|
||||
_click(_cell("New work report"));
|
||||
_click(_cell("Add new row"));
|
||||
_setValue(_textbox(2, _near(_parentTable(_div("Date")))),$machine);
|
||||
_click(_italic(0, _near(_textbox(3, _near(_parentTable(_div("Date")))))));
|
||||
_click(_div($project+"[2]", _parentTable(_div("Project code[1]"))));
|
||||
_setValue(_textbox("z-intbox"),"8");
|
||||
_setSelected(_select(2), $workHour);
|
||||
_click(_cell("Save"));
|
||||
_assertExists(_div("Work report saved"));
|
||||
_assert(_isVisible(_div("Work report saved")));
|
||||
}
|
||||
|
||||
function commonTryDeleteProject($name){
|
||||
_click(_link("Projects"));
|
||||
_click(_image("ico_borrar1.png", _in(_cell(8, _near(_cell($name))))));
|
||||
_click(_cell("OK"));
|
||||
_assertExists(_div("You can not remove the project \"new project\" because of any of its tasks are already in use in some work reports and the project just exists in the current scenario"));
|
||||
_assert(_isVisible(_div("You can not remove the project \"new project\" because of any of its tasks are already in use in some work reports and the project just exists in the current scenario")));
|
||||
_log("Do not allow delete Work Report SUCCESS", "success");
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions of Cost Category
|
||||
* */
|
||||
|
||||
function workHourAssignCostCategory($categoryName, $hworkName){
|
||||
costCategoryCreate($categoryName, $hworkName);
|
||||
workHourTryDelete($hWorkName,"cost category");
|
||||
commonDelete("Cost Categories", $categoryName, 2);
|
||||
commonDeleteValidation("Cost Category", $categoryName);
|
||||
_log("Delete the Cost Category SUCCESS", "success");
|
||||
}
|
||||
|
||||
function costCategoryCreate($name, $hworkName){
|
||||
commonCreate("Cost Categories");
|
||||
costCategoryForm($name, $hworkName);
|
||||
commonSaveValidation("Cost Category", $name);
|
||||
_log("Create a Cost Category SUCCESS", "success");
|
||||
}
|
||||
|
||||
function costCategoryForm($name, $hworkName){
|
||||
_setValue(_textbox(0, _near(_span("Name:"))), $name);
|
||||
_click(_cell("Add new row"));
|
||||
_setSelected(_select(0), $hworkName);
|
||||
_click(_cell("Save"));
|
||||
}
|
||||
|
||||
/* test values */
|
||||
var $hWorkName = "new";
|
||||
var $hWorkNewName = "newest";
|
||||
var $hWorkPrice = "20";
|
||||
var $ModelName = "newModel";
|
||||
var $cCategoryName = "newModel";
|
||||
var $materialName = "newMachine";
|
||||
var $materialDescription = "strongeMachine";
|
||||
|
||||
/* test actions */
|
||||
commonLogin("admin", "admin");
|
||||
|
||||
workHourCreate($hWorkName, $hWorkPrice);
|
||||
workHourCreateDuplicateType($hWorkName, $hWorkPrice);
|
||||
workHourCreateEmpty();
|
||||
workHourEdit($hWorkName, $hWorkNewName, $hWorkPrice, 4);
|
||||
workHourAssign($hWorkNewName, $ModelName, $materialName, $materialDescription);
|
||||
|
||||
commonDelete("Work Hours", $hWorkNewName, 4);
|
||||
commonDeleteValidation("Type of hours", $hWorkNewName);
|
||||
|
||||
workHourCreate($hWorkName, $hWorkPrice);
|
||||
workHourAssignCostCategory($cCategoryName, $hWorkName);
|
||||
commonDelete("Work Hours", $hWorkName, 4);
|
||||
commonDeleteValidation("Type of hours", $hWorkName);
|
||||
_log("Delete the work Hour SUCCESS", "success");
|
||||
commonLogout();
|
||||
Loading…
Add table
Reference in a new issue