2011-09-06 12:30:56 +02:00
|
|
|
/*
|
2011-10-28 08:17:54 +02:00
|
|
|
* This file is part of LibrePlan
|
2011-09-06 12:30:56 +02:00
|
|
|
*
|
|
|
|
|
* 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 work report without any work report model (it should be a failure)
|
|
|
|
|
* 2 - Create a Work report from a lineal work report model
|
|
|
|
|
* 2.1 - Create a lineal work report model
|
|
|
|
|
* 2.2 - Create a work report
|
|
|
|
|
* 3 - Create a Work report from a heading work report model
|
|
|
|
|
* 3.1 - Create a heading work report model
|
2011-09-08 13:31:59 +02:00
|
|
|
* 3.2 - Try to create a work report from heading model without task (it should be a failure)
|
2011-09-06 12:30:56 +02:00
|
|
|
* 4 - Edit the work report including a line
|
|
|
|
|
* 4.1 - Create a machine
|
|
|
|
|
* 4.2 - Create a Work hour
|
|
|
|
|
* 4.3 - Create a project
|
|
|
|
|
* 4.4 - Complete the form and check the fields
|
2011-09-08 13:31:59 +02:00
|
|
|
* 5 - Delete all the work reports
|
|
|
|
|
* 6 - Delete all required elements
|
2011-09-06 12:30:56 +02:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
_include("../common_functions.sah");
|
|
|
|
|
|
|
|
|
|
function workReportCreateLineModel($modelName){
|
|
|
|
|
workReportModelLineCreate($modelName);
|
|
|
|
|
_click(_link("Work Reports"));
|
2011-11-07 10:33:14 +01:00
|
|
|
_setSelected(_select(0, _near(_span("Select type :"))), $modelName);
|
2011-09-06 12:30:56 +02:00
|
|
|
_click(_cell("New work report"));
|
|
|
|
|
_click(_cell("Save"));
|
|
|
|
|
workReportAcctionValidation("saved");
|
|
|
|
|
_log("Create a new work report from a model type line", "custom1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportModelLineCreate($name){
|
|
|
|
|
commonCreate("Work Report Models");
|
|
|
|
|
workReportModelLineForm($name);
|
|
|
|
|
commonSaveValidation("Work Report Type", $name);
|
|
|
|
|
_log("Create a new Work Report Model", "custom1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportModelLineForm($name){
|
2011-11-07 10:33:14 +01:00
|
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
|
|
|
_removeFocus(_textbox(0, _near(_div("Name"))));
|
2011-09-06 12:30:56 +02:00
|
|
|
_click(_cell("Add New Complementary Field"));
|
2011-11-07 10:33:14 +01:00
|
|
|
_setValue(_textbox(0, _near(_span("Complementary text fields"))), $name);
|
|
|
|
|
_setValue(_textbox(1, _near(_span("Complementary text fields"))), "12");
|
2011-09-06 12:30:56 +02:00
|
|
|
_click(_cell("Save"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportCreateHeadingModel($modelName){
|
|
|
|
|
workReportModelHeadingCreate($modelName);
|
|
|
|
|
_click(_link("Work Reports"));
|
|
|
|
|
_setSelected(_select(0, _near(_span("Select type :"))), $modelName);
|
|
|
|
|
_click(_cell("New work report"));
|
|
|
|
|
_click(_cell("Save"));
|
|
|
|
|
workReportHeadingCodeValidation();
|
|
|
|
|
_log("Do not allow create a new work report from a model type heading without task", "custom1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportModelHeadingCreate($name){
|
|
|
|
|
commonCreate("Work Report Models");
|
|
|
|
|
workReportModelHeadingForm($name);
|
|
|
|
|
commonSaveValidation("Work Report Type", $name);
|
|
|
|
|
_log("Create a new Work Report Model", "custom1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportModelHeadingForm($name){
|
2011-11-07 10:33:14 +01:00
|
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
|
|
|
_removeFocus(_textbox(0, _near(_div("Name"))));
|
|
|
|
|
_setSelected(_select(0, _near(_span("Task"))),"heading");
|
2011-09-06 12:30:56 +02:00
|
|
|
_click(_cell("Add New Complementary Field"));
|
2011-11-07 10:33:14 +01:00
|
|
|
_setValue(_textbox(0, _near(_span("Complementary text fields"))), $name);
|
|
|
|
|
_setValue(_textbox(1, _near(_span("Complementary text fields"))), "12");
|
2011-09-06 12:30:56 +02:00
|
|
|
_click(_cell("Save"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportEdit($name){
|
|
|
|
|
workReportLinesCreateRequiredElements();
|
|
|
|
|
workReportEditForm($name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportEditForm($name){
|
|
|
|
|
_click(_link("Work Reports"));
|
|
|
|
|
commonEdit($name, 4);
|
|
|
|
|
_click(_cell("Add new row"));
|
|
|
|
|
_click(_cell("Save"));
|
|
|
|
|
workReportResourceValidation();
|
2011-11-07 10:33:14 +01:00
|
|
|
_setValue(_textbox(2, _near(_span("Work report lines"))), $machineName);
|
2011-09-06 12:30:56 +02:00
|
|
|
_click(_cell("Save"));
|
|
|
|
|
workReportTaskValidation();
|
2011-11-07 10:33:14 +01:00
|
|
|
_click(_italic(0, _near(_textbox(3, _near(_span("Work report lines"))))));
|
2011-09-06 12:30:56 +02:00
|
|
|
_click(_div($projectName+"[2]", _parentTable(_div("Project code[1]"))));
|
|
|
|
|
_click(_cell("Save"));
|
|
|
|
|
workReportHourValidation();
|
2011-09-22 18:03:19 +02:00
|
|
|
_setValue(_textbox("z-textbox z-textbox-text-invalid"), "8");
|
2011-09-06 12:30:56 +02:00
|
|
|
_click(_cell("Save"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportLinesCreateRequiredElements(){
|
|
|
|
|
commonCreateProject($projectName);
|
|
|
|
|
commonMachineCreate($machineName, $machineDescription);
|
|
|
|
|
commonWorkHourCreate($workhourName, $workhourPrice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportLinesDeleteRequiredElements(){
|
|
|
|
|
commonMachineDelete($machineName);
|
|
|
|
|
commonWorkHourDelete($workhourName);
|
|
|
|
|
commonDeleteProject($projectName);
|
|
|
|
|
commonWorkReportModelDelete($workReportModelName);
|
|
|
|
|
commonWorkReportModelDelete($workReportModelName2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DeleteRequiredElements(){
|
|
|
|
|
commonWorkReportModelDelete($modelName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Validations
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function workReportAcctionValidation($action){
|
|
|
|
|
_assertExists(_span("Work report "+$action));
|
|
|
|
|
_assert(_isVisible(_span("Work report "+$action)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportHeadingCodeValidation(){
|
|
|
|
|
_assertExists(_div("Task code cannot be null"));
|
|
|
|
|
_assert(_isVisible(_div("Task code cannot be null")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportResourceValidation(){
|
|
|
|
|
_assertExists(_div("The resource cannot be null"));
|
|
|
|
|
_assert(_isVisible(_div("The resource cannot be null")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportTaskValidation(){
|
|
|
|
|
_assertExists(_div("The task code cannot be null"));
|
|
|
|
|
_assert(_isVisible(_div("The task code cannot be null")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function workReportHourValidation(){
|
2011-09-22 18:03:19 +02:00
|
|
|
_assertExists(_div("Effort must be greater than zero"));
|
|
|
|
|
_assert(_isVisible(_div("Effort must be greater than zero")));
|
2011-09-06 12:30:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* test values */
|
|
|
|
|
var $workReportModelName = "line";
|
|
|
|
|
var $workReportModelName2 = "heading";
|
|
|
|
|
var $workReportNewName = "newSon";
|
|
|
|
|
var $workReportNewName2 = "newSon";
|
|
|
|
|
var $workhourName = "hourForWorkReport";
|
|
|
|
|
var $workhourPrice = 12;
|
|
|
|
|
var $machineName = "machineForWorkReport";
|
|
|
|
|
var $machineDescription = "forWorkReport";
|
|
|
|
|
var $projectName = "projectForWorkReport";
|
|
|
|
|
|
|
|
|
|
commonLogin("admin", "admin");
|
|
|
|
|
|
|
|
|
|
workReportCreateLineModel($workReportModelName);
|
|
|
|
|
workReportCreateHeadingModel($workReportModelName2);
|
|
|
|
|
workReportEdit($workReportModelName);
|
2011-09-22 18:03:19 +02:00
|
|
|
commonWorkReportDelete($workReportModelName);
|
2011-09-06 12:30:56 +02:00
|
|
|
workReportLinesDeleteRequiredElements();
|
|
|
|
|
|
|
|
|
|
commonLogout();
|