579 lines
18 KiB
Text
579 lines
18 KiB
Text
/*
|
|
* This file is part of LibrePlan
|
|
*
|
|
* Copyright (C) 2011-2012 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/>.
|
|
*/
|
|
|
|
/* Function to login in LibrePlan */
|
|
function commonLogin($user, $password) {
|
|
_setValue(_textbox("j_username"), $user);
|
|
_setValue(_password("j_password"), $password);
|
|
_click(_submit("Log in"));
|
|
}
|
|
|
|
/* Function to logout in LibrePlan */
|
|
function commonLogout() {
|
|
_click(_link("[Log out]"));
|
|
}
|
|
|
|
/* Function to access to create form */
|
|
function commonCreate($something) {
|
|
_click(_link($something));
|
|
_click(_cell("Create"));
|
|
}
|
|
|
|
/* Function to edit something */
|
|
function commonEdit($name, $cell) {
|
|
_click(_image("ico_editar1.png", _in(_cell($cell, _near(_cell($name))))));
|
|
}
|
|
|
|
/* Function to delete something */
|
|
function commonDelete ($something, $name, $cell) {
|
|
_click(_link($something));
|
|
_click(_image("ico_borrar1.png", _in(_cell($cell, _near(_cell($name))))));
|
|
_click(_cell("OK"));
|
|
}
|
|
|
|
/* Create new project */
|
|
function commonCreateProject($name, $calendar){
|
|
_click(_link("Projects"));
|
|
_click(_image("ico_add.png"));
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
if ($calendar != null){
|
|
_click(_italic(0, _near(_span("Calendar"))));
|
|
_click(_cell($calendar));
|
|
}
|
|
_click(_cell("Accept"));
|
|
_click(_image("ico_save.png"));
|
|
_click(_cell("OK"));
|
|
}
|
|
|
|
function commonEditProject($name){
|
|
_click(_link("Projects"));
|
|
_click(_image("ico_editar1.png", _in(_cell(8,_near(_cell($name))))));
|
|
}
|
|
|
|
/* Delete a project */
|
|
function commonDeleteProject($name){
|
|
_click(_link("Projects"));
|
|
_click(_image("ico_borrar1.png", _in(_cell(8, _near(_cell($name))))));
|
|
_click(_cell("OK"));
|
|
_assertExists(_div("Removed "+$name));
|
|
_assert(_isVisible(_div("Removed "+$name)));
|
|
_assertEqual("Removed "+$name, _getText(_div("Removed "+$name)));
|
|
}
|
|
|
|
/* Create a task in a project */
|
|
function commonCreateTask($projectName, $name, $hours){
|
|
_click(_link("Projects"));
|
|
_click(_image("ico_editar1.png", _in(_cell(8,_near(_cell($projectName))))));
|
|
_setValue(_textbox(0, _near(_span("New task"))), $name);
|
|
_setValue(_textbox("z-intbox", _near(_span("Hours"))), $hours);
|
|
_click(_cell("Add"));
|
|
_click(_image("ico_save.png"));
|
|
_click(_cell("OK"));
|
|
_log("Create a task", "custom1");
|
|
}
|
|
|
|
function commonConfigurationChangeCheckboxMainPreferences($element){
|
|
_click(_link("Main Settings"));
|
|
_click(_checkbox(0, _near(_label($element))));
|
|
_click(_cell("Save"));
|
|
commonSaveConfigurationValidation();
|
|
}
|
|
|
|
/* Use the filter of Project Planning */
|
|
function commonProjectPlanningFilter($label, $labelName){
|
|
_click(_italic(0, _near(_span("with"))));
|
|
_click(_div($labelName+" ( "+$label+" )"));
|
|
_click(_cell("Filter"));
|
|
commonProjectPlanningFilterValidation();
|
|
_log("Check if the labels are filtered", "custom1");
|
|
}
|
|
|
|
/*
|
|
* Common functions for Validations
|
|
*/
|
|
|
|
function commonSaveConfigurationValidation(){
|
|
_assertExists(_span("Changes saved"));
|
|
_assert(_isVisible(_span("Changes saved")));
|
|
}
|
|
|
|
function commonEmptyCodeValidation(){
|
|
_assertExists(_div("cannot be empty"));
|
|
_assert(_isVisible(_div("cannot be empty")));
|
|
}
|
|
|
|
function commonProjectPlanningFilterValidation(){
|
|
_assertNotTrue(_isVisible(_span("z-tree-ico z-tree-firstspacer[1]")));
|
|
}
|
|
|
|
/* test to check a correct save */
|
|
function commonSaveValidation($something, $name){
|
|
_assertExists(_div($something+" \""+$name+"\" saved"));
|
|
_assert(_isVisible(_div($something+" \""+$name+"\" saved")));
|
|
_assertEqual($something+" \""+$name+"\" saved", _getText(_div($something+" \""+$name+"\" saved")));
|
|
}
|
|
|
|
/* test to check a correct delete */
|
|
function commonDeleteValidation($something, $name){
|
|
_assertExists(_div($something+" \""+$name+"\" deleted"));
|
|
_assert(_isVisible(_div($something+" \""+$name+"\" deleted")));
|
|
_assertEqual($something+" \""+$name+"\" deleted", _getText(_div($something+" \""+$name+"\" deleted")));
|
|
}
|
|
|
|
/*
|
|
* commmon functions for Workers, Machines and Virtual Workers
|
|
*/
|
|
|
|
function commonResourceEditAssignedCriteriaForm($element, $name, $cell, $criterion){
|
|
_click(_link($element));
|
|
commonEdit($name, $cell);
|
|
_click(_span("Assigned criteria"));
|
|
_click(_cell("Add", _near(_span("New criterion"))));
|
|
_click(_cell("Save"));
|
|
commmonResourceEmptyFields();
|
|
_click(_italic(0, _near(_tableHeader("Criterion name"))));
|
|
_click(_div($criterion));
|
|
_click(_cell("Save"));
|
|
_log("Assign the created Criterion", "custom1");
|
|
}
|
|
|
|
function commonResourceEditAssignedCalendarForm($element, $name, $cell, $calendar){
|
|
_click(_link($element));
|
|
commonEdit($name, $cell);
|
|
_click(_cell("Remove calendar"));
|
|
_click(_span("Calendar"))
|
|
_click(_italic(0, _near(_span("Select parent calendar"))));
|
|
_click(_cell($calendar));
|
|
_click(_cell("Save"));
|
|
_log("Assign the created calendar", "custom1");
|
|
}
|
|
|
|
function commonResourceEditAssignedCostCategoryForm($element, $name, $cell, $ccategory){
|
|
_click(_link($element));
|
|
commonEdit($name, $cell);
|
|
_click(_cell("Add new row"));
|
|
_click(_cell("Save"));
|
|
commonResourceEmptyCategoryName();
|
|
_click(_italic(0, _near(_div("Category name"))));
|
|
_click(_cell($ccategory+"[1]"));
|
|
_click(_cell("Save"));
|
|
commonResourceEmptyCategoryDate();
|
|
_click(_italic(1, _near(_div("Category name"))));
|
|
_click(_cell("z-calendar-weekday z-calendar-selected", _near(_div("Category name"))));
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commmonResourceEmptyFields(){
|
|
_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 commonResourceFilter($resource, $criterion, $name){
|
|
_click(_link($resource));
|
|
_click(_italic(0, _near(_span("Filter by"))));
|
|
_click(_div($name+" ( "+$criterion+" )"));
|
|
_click(_cell("Filter"));
|
|
commonProjectPlanningFilterValidation();
|
|
_log("Create a criteria filter", "custom1");
|
|
}
|
|
|
|
function commonResourceEmptyCategoryName(){
|
|
_assertExists(_div("A category must be selected"));
|
|
_assert(_isVisible(_div("A category must be selected")));
|
|
}
|
|
|
|
function commonResourceEmptyCategoryDate(){
|
|
_assertExists(_div("Start date cannot be empty"));
|
|
_assert(_isVisible(_div("Start date cannot be empty")));
|
|
}
|
|
|
|
function commonResourceTryDeleteAssignedValidation(){
|
|
_assertExists(_span("This worker cannot be deleted because it has assignments to projects or imputed hours"));
|
|
_assert(_isVisible(_span("This worker cannot be deleted because it has assignments to projects or imputed hours")));
|
|
}
|
|
|
|
/*
|
|
* Common functions for Workers
|
|
*/
|
|
|
|
function commonWorkerCreate($name, $surName, $id) {
|
|
commonCreate("Workers");
|
|
commonWorkerForm($name, $surName, $id);
|
|
commonWorkerAcctionValidation("saved");
|
|
_log("Create a new worker", "custom1");
|
|
}
|
|
|
|
function commonWorkerForm($name, $surName, $id) {
|
|
_setValue(_textbox(0, _near(_span("First name"))), $name);
|
|
_setValue(_textbox(0, _near(_span("Last name"))), $surName);
|
|
_setValue(_textbox(0, _near(_span("ID"))), $id);
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonWorkerDelete($name){
|
|
commonDelete("Workers", $name, 5);
|
|
commonWorkerAcctionValidation("deleted");
|
|
_log("Delete the worker", "custom1");
|
|
}
|
|
|
|
function commonWorkerAcctionValidation($action){
|
|
_assertExists(_span("Worker "+$action));
|
|
_assert(_isVisible(_span("Worker "+$action)));
|
|
}
|
|
|
|
/*
|
|
* Common functions for Machines
|
|
*/
|
|
|
|
function commonMachineCreate($name, $description) {
|
|
commonCreate("Machines");
|
|
commonMachineForm($name, $description);
|
|
commonSaveValidation("Machine", $name);
|
|
_log("Create a new Machine", "custom1");
|
|
}
|
|
|
|
function commonMachineForm($name, $description) {
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
_setValue(_textbox(0, _near(_span("Description"))), $description);
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonMachineDelete($name){
|
|
commonDelete("Machines", $name, 4);
|
|
commonDeleteValidation("Machine", $name);
|
|
_log("Delete the machine", "custom1");
|
|
}
|
|
|
|
/*
|
|
* Common functions for Virtual Workers
|
|
*/
|
|
|
|
|
|
function commonVirtualWorkerCreate($name) {
|
|
commonVirtualWorkerGoToCreate();
|
|
commonVirtualWorkerForm($name);
|
|
commonVirtualWorkerAcctionValidation("saved");
|
|
_log("Create a new virtual worker", "custom1");
|
|
}
|
|
|
|
function commonVirtualWorkerGoToCreate (){
|
|
_click(_link("Virtual Workers"));
|
|
_click(_cell("Create Virtual Worker"));
|
|
}
|
|
|
|
function commonVirtualWorkerForm($name) {
|
|
_setValue(_textbox(0, _near(_span("Group name"))), $name);
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonVirtualWorkerDelete($name){
|
|
commonDelete("Virtual Workers", $name, 3);
|
|
commonVirtualWorkerAcctionValidation("deleted");
|
|
_log("Delete the virtual worker", "custom1");
|
|
}
|
|
|
|
function commonVirtualWorkerAcctionValidation($action){
|
|
_assertExists(_span("Worker "+$action));
|
|
_assert(_isVisible(_span("Worker "+$action)));
|
|
}
|
|
|
|
/*
|
|
* Common functions for Work report
|
|
*/
|
|
|
|
function commonWorkReportDelete ($name){
|
|
commonDelete("Timesheets", $name, 5);
|
|
commonWorkReportDeleteValidation();
|
|
_log("Delete the work report", "custom1");
|
|
}
|
|
|
|
function commonWorkReportDeleteValidation (){
|
|
_assertExists(_span("Timesheet removed successfully"));
|
|
_assert(_isVisible(_span("Timesheet removed successfully")));
|
|
}
|
|
|
|
/*
|
|
* Common functions for Companies
|
|
*/
|
|
|
|
function commonCompanyCreate($name, $ID) {
|
|
commonCreate("Companies");
|
|
commonCompanyForm($name, $ID);
|
|
commonSaveValidation("Company", $name);
|
|
_log("Create a company", "custom1");
|
|
}
|
|
|
|
function commonCompanyForm($name, $ID) {
|
|
_setValue(_textbox(0, _near(_span("Company name:"))), $name);
|
|
_setValue(_textbox(0, _near(_span("Company ID:"))), $ID);
|
|
_click(_checkbox(0, _near(_span("Client:"))));
|
|
_click(_checkbox(0, _near(_span("Subcontractor:"))));
|
|
_setValue(_textbox(0, _near(_span("User:"))), "wssubcontracting");
|
|
_click(_checkbox(0, _near(_span("Interacts with applications:"))));
|
|
_setValue(_textbox(0, _near(_span("Application URI:"))), "http://localhost:8080/libreplan-webapp/");
|
|
_setValue(_textbox(0, _near(_span("Our company username:"))), "wssubcontracting");
|
|
_setValue(_textbox(0, _near(_span("Company password:"))), "wssubcontracting");
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonCompanyDelete($name){
|
|
commonDelete("Companies", $name, 5);
|
|
commonDeleteValidation("Company", $name);
|
|
_log("Delete a company", "custom1");
|
|
}
|
|
|
|
/*
|
|
* Common functions for Calendars
|
|
*/
|
|
|
|
function commonCalendarCreate($name) {
|
|
commonCreate("Calendars");
|
|
commonCalendarForm($name);
|
|
commonSaveValidation("Base calendar", $name);
|
|
_log("Create a new calendar", "custom1");
|
|
}
|
|
|
|
function commonCalendarForm($name) {
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonCalendarTryDeleteAssignedCalendar($name, $cell) {
|
|
_click(_link("Calendars"));
|
|
_click(_image("ico_borrar1.png", _in(_cell($cell, _near(_cell($name))))));
|
|
_assertExists(_span("Cannot delete calendar. It is being used at this moment by some resources."));
|
|
_assert(_isVisible(_span("Cannot delete calendar. It is being used at this moment by some resources.")));
|
|
_log("Do not allow delete assigned calendar", "custom1");
|
|
}
|
|
|
|
function commonCalendarDelete($name){
|
|
commonDelete("Calendars", $name, 3);
|
|
commonCalendarDeleteValidation($name);
|
|
_log("Delete de Calendar", "custom1");
|
|
}
|
|
|
|
function commonCalendarDeleteValidation($name) {
|
|
_assertExists(_span("Removed calendar \""+$name+"\""));
|
|
_assert(_isVisible(_span("Removed calendar \""+$name+"\"")));
|
|
}
|
|
|
|
/*
|
|
* Common functions for Cost Category
|
|
*/
|
|
|
|
function commonCostCategoryCreate($name, $hworkName){
|
|
commonCreate("Cost Categories");
|
|
commonCostCategoryForm($name, $hworkName);
|
|
commonSaveValidation("Cost Category", $name);
|
|
_log("Create a Cost Category", "custom1");
|
|
}
|
|
|
|
function commonCostCategoryForm($name, $hworkName){
|
|
_setValue(_textbox(0, _near(_span("Name:"))), $name);
|
|
_click(_cell("Add new row"));
|
|
_setSelected(_select(0), $hworkName);
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonCostCategoryDelete($name){
|
|
commonDelete("Cost Categories", $name, 2);
|
|
commonDeleteValidation("Cost Category", $name);
|
|
_log("Delete de cost category", "custom1");
|
|
}
|
|
|
|
function commonCostCategoryTryDeleteAssignedCostCategory($cCategory, $cell){
|
|
_click(_link("Cost Categories"));
|
|
_assertExists(_image("ico_borrar_out.png"));
|
|
_assert(_isVisible(_image("ico_borrar_out.png")));
|
|
_log("Do not allow delete assigned cost category", "custom1");
|
|
}
|
|
|
|
/*
|
|
* Common functions for Progress
|
|
*/
|
|
|
|
function commonProgressCreate($name) {
|
|
commonCreate("Progress Types");
|
|
commonProgressForm($name);
|
|
commonSaveValidation("Progress Type", $name);
|
|
_log("Create a progress", "custom1");
|
|
}
|
|
|
|
|
|
function commonProgressForm($name) {
|
|
_setValue(_textbox(0, _near(_div("Unit name"))), $name);
|
|
_removeFocus(_textbox(0, _near(_div("Unit name"))));
|
|
_click(_cell("Save & Continue"));
|
|
}
|
|
|
|
function commonProgressAssigned($projectName, $progressNewName){
|
|
commonCreateProject($projectName);
|
|
commonProgressAssignProject($projectName, $progressNewName);
|
|
_click(_link("Progress Types"));
|
|
commonDeleteProject($projectName);
|
|
}
|
|
|
|
function commonProgressAssignProject($projectName, $progressNewName){
|
|
commonEditProject($projectName);
|
|
_click(_span("Progress"));
|
|
_click(_cell("Add new progress assignment"));
|
|
_setValue(_textbox("z-combobox-inp", _near(_row("footer"))), $progressNewName);
|
|
_click(_cell("z-button-cm", _near(_textbox("z-combobox-inp"))));
|
|
_setValue(_textbox(0, _near(_parentTable(_div("Value[1]")))), "30");
|
|
_click(_image("ico_save.png"));
|
|
_click(_cell("OK"));
|
|
_log("Progress assigned", "custom1");
|
|
}
|
|
|
|
function commonProgressDelete($name){
|
|
commonDelete("Progress Types", $progressNewName, 3);
|
|
commonDeleteValidation("Progress Type", $progressNewName);
|
|
_log("Delete the progress", "custom1");
|
|
}
|
|
|
|
/*
|
|
* Common functions for Criteria
|
|
*/
|
|
|
|
function commonCriteriaCreate($type, $list){
|
|
commonCreate("Criteria");
|
|
commonCriteriaForm($type, $list);
|
|
commonSaveValidation("Criterion Type", $type);
|
|
_log("Create criterion" + $type, "custom1");
|
|
}
|
|
|
|
function commonCriteriaEdit($oldName, $newName, $cell){
|
|
commonEdit($oldName, $cell);
|
|
_setValue(_textbox(0, _near(_span("Name"))), $newName);
|
|
_removeFocus(_textbox(0, _near(_span("Name"))), $newName);
|
|
_click(_cell("Save & Continue"));
|
|
commonSaveValidation("Criterion Type", $newName);
|
|
_log("Edit a criterion", "custom1");
|
|
}
|
|
|
|
function commonCriteriaForm($name, $list){
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
_click(_checkbox(0, _near(_div("Multiple values per resource"))));
|
|
_click(_checkbox(0, _near(_div("Hierarchy"))));
|
|
_click(_cell("OK"));
|
|
for (var $i = 0; $i < $list.length; $i++){
|
|
_setValue(_textbox(0, _near(_span("New criterion"))), $list[$i]);
|
|
_click(_cell("Add"));
|
|
}
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonCriteriaDelete($criteriaName){
|
|
commonDelete("Criteria", $criteriaName, 4);
|
|
commonDeleteValidation("Criterion Type", $criteriaName);
|
|
_log("Delete the criteria", "custom1");
|
|
}
|
|
|
|
function commonCriteriaTryDeleteAssigned($criteriaName){
|
|
_click(_link("Criteria"));
|
|
_click(_image("ico_borrar1.png", _in(_cell(4, _near(_cell($criteriaName))))));
|
|
_assertExists(_span("This criterion type cannot be deleted because it is assigned to projects or resources"));
|
|
_assert(_isVisible(_span("This criterion type cannot be deleted because it is assigned to projects or resources")));
|
|
_log("Do not allow criteria because it's assigned", "custom1");
|
|
}
|
|
|
|
/*
|
|
* Common functions for Labels
|
|
*/
|
|
|
|
function commonLabelCreate($type, $name){
|
|
commonCreate("Labels");
|
|
commonLabelForm($type, $name);
|
|
commonSaveValidation("Label Type", $type);
|
|
_log("Create a new label", "custom1");
|
|
}
|
|
|
|
function commonLabelForm($name, $list){
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
if ($list != null){
|
|
for (var $i = 0; $i < $list.length; $i++){
|
|
_setValue(_textbox(0, _near(_span("New label"))), $list[$i]);
|
|
_click(_cell("Add"));
|
|
}
|
|
}
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonLabelDelete($name){
|
|
commonDelete("Labels", $name, 2);
|
|
commonDeleteValidation("Label Type", $name);
|
|
_log("Label Deleted", "custom1");
|
|
}
|
|
|
|
/*
|
|
* Common functions for Timesheet Model
|
|
*/
|
|
|
|
function commonWorkReportModelCreate($name, $type){
|
|
commonCreate("Timesheets Templates");
|
|
commonWorkReportModelForm($name, $type);
|
|
commonSaveValidation("Timesheets Template", $name);
|
|
_log("Create a new Timesheet Model", "custom1");
|
|
}
|
|
|
|
function commonWorkReportModelForm($name, $type){
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
_removeFocus(_textbox(0, _near(_div("Name"))));
|
|
_setSelected(_select(0, _near(_span("Task"))), $type);
|
|
_click(_cell("Add New Complementary Field"));
|
|
_setValue(_textbox(0, _near(_span("Complementary text fields"))), $name);
|
|
_setValue(_textbox(1, _near(_span("Complementary text fields"))), "12");
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonWorkReportModelEdit($oldName, $newName, $cell){
|
|
commonEdit($oldName, $cell);
|
|
commonWorkReportModelForm($newName);
|
|
commonSaveValidation("Timesheets Template", $newName);
|
|
_log("Edit a Timesheet Model", "custom1");
|
|
}
|
|
|
|
function commonWorkReportModelDelete($name){
|
|
commonDelete("Timesheets Templates", $name, 1);
|
|
commonDeleteValidation("Timesheets Template", $name);
|
|
_log("Delete the Timesheet Model", "custom1");
|
|
}
|
|
|
|
/*
|
|
* Common functions for Work hours
|
|
*/
|
|
|
|
function commonWorkHourCreate($type, $price){
|
|
commonCreate("Hours Types");
|
|
commonWorkHourForm($type, $price);
|
|
commonSaveValidation("Hours Type", $type);
|
|
_log("Create a new Hours Type", "custom1");
|
|
}
|
|
|
|
function commonWorkHourForm($name, $price){
|
|
_setValue(_textbox(0, _near(_span("Name"))), $name);
|
|
_setValue(_textbox(0, _near(_span("Default price"))), $price);
|
|
_click(_cell("Save"));
|
|
}
|
|
|
|
function commonWorkHourDelete($name){
|
|
commonDelete("Hours Types", $name, 8);
|
|
commonDeleteValidation("Hours Type", $name);
|
|
_log("Delete the Hours Type", "custom1");
|
|
}
|