Include some functions of workers in common_functions.sah and use them

FEA: ItEr75S24ResourcesTests
This commit is contained in:
Pablo Fernández de la Cigoña Nóvoa 2011-09-14 12:38:32 +02:00 committed by Manuel Rego Casasnovas
parent 87a81a6fb4
commit 24b34efd6e
3 changed files with 25 additions and 51 deletions

View file

@ -94,7 +94,8 @@ function calendarCreateWithoutCode($name){
} }
function calendarAssignWorker($name, $id, $calendar) { function calendarAssignWorker($name, $id, $calendar) {
workerCreate($name, $id, $calendar); commonWorkerCreate($name, $name, $id);
commonResourceEditAssignedCalendarForm("Workers", $name, 5, $calendar);
commonCalendarTryDeleteAssignedCalendar($calendar, 3); commonCalendarTryDeleteAssignedCalendar($calendar, 3);
commonWorkerDelete($name); commonWorkerDelete($name);
_log("Assign a calendar to a Worker", "custom1"); _log("Assign a calendar to a Worker", "custom1");
@ -107,28 +108,6 @@ function calendarAssignProject($projectName, $calendar){
_log("Assign Calendar to a project", "custom1"); _log("Assign Calendar to a project", "custom1");
} }
/*
* Worker functions
* */
function workerCreate($name, $id, $calendar) {
commonCreate("Workers");
workerForm($name, $id, $calendar);
_assertExists(_span("Worker saved"));
_assert(_isVisible(_span("Worker saved")));
_log("Create a new worker", "custom1");
}
function workerForm($name, $id, $calendar) {
_setValue(_textbox(0, _near(_span("First name"))), $name);
_setValue(_textbox(0, _near(_span("Last name"))), $name);
_setValue(_textbox(0, _near(_span("ID"))), $id);
_click(_span("Calendar"));
_click(_italic(0, _near(_span("Select parent calendar"))));
_click(_cell($calendar));
_click(_cell("Save"));
}
/* /*
* Validations * Validations
*/ */

View file

@ -190,6 +190,20 @@ function commonResourceTryDeleteAssignedValidation(){
* Common functions for Workers * 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){ function commonWorkerDelete($name){
commonDelete("Workers", $name, 5); commonDelete("Workers", $name, 5);
commonWorkerAcctionValidation("deleted"); commonWorkerAcctionValidation("deleted");

View file

@ -54,16 +54,9 @@
_include("../common_functions.sah"); _include("../common_functions.sah");
function workerCreate($name, $surName, $id) {
commonCreate("Workers");
workerForm($name, $surName, $id);
workerAcctionValidation("saved");
_log("Create a new worker", "custom1");
}
function workerCreateDuplicateType($name, $surName, $id) { function workerCreateDuplicateType($name, $surName, $id) {
commonCreate("Workers"); commonCreate("Workers");
workerForm($name, $surName, $id); commonWorkerForm($name, $surName, $id);
workerNotValid($name); workerNotValid($name);
_log("Create a duplicate worker", "custom1"); _log("Create a duplicate worker", "custom1");
} }
@ -85,17 +78,10 @@ function workerEmptyForm($name, $surName, $id) {
workerEmptyFields(); workerEmptyFields();
} }
function workerForm($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 workerEdit($oldName, $newName, $cell) { function workerEdit($oldName, $newName, $cell) {
commonEdit($oldName, $cell); commonEdit($oldName, $cell);
workerForm($newName); commonWorkerForm($newName);
workerAcctionValidation("saved"); commonWorkerAcctionValidation("saved");
_log("Edit a worker", "custom1"); _log("Edit a worker", "custom1");
} }
@ -108,7 +94,7 @@ function workerCheckCode($name, $surName, $ID){
function workerCreateWithoutCode($name, $surName, $ID){ function workerCreateWithoutCode($name, $surName, $ID){
commonCreate("Workers"); commonCreate("Workers");
workerForm($name, $surName, $ID); commonWorkerForm($name, $surName, $ID);
commonEmptyCodeValidation(); commonEmptyCodeValidation();
} }
@ -134,7 +120,7 @@ function workerCheckAssignedCostCategory($workerName, $cell, $cCategory){
commonWorkHourCreate("HourForWorker", "12"); commonWorkHourCreate("HourForWorker", "12");
commonCostCategoryCreate($cCategory, "HourForWorker"); commonCostCategoryCreate($cCategory, "HourForWorker");
commonResourceEditAssignedCostCategoryForm("Workers", $workerName, $cell, $cCategory); commonResourceEditAssignedCostCategoryForm("Workers", $workerName, $cell, $cCategory);
workerAcctionValidation("saved"); commonWorkerAcctionValidation("saved");
_log("Assign the created cost category", "custom1"); _log("Assign the created cost category", "custom1");
commonCostCategoryTryDeleteAssignedCostCategory($cCategory, 3); commonCostCategoryTryDeleteAssignedCostCategory($cCategory, 3);
} }
@ -174,16 +160,12 @@ function workerTryDeleteAssigned($worker){
} }
/* Validations */ /* Validations */
function workerNotValid($worker){ function workerNotValid($worker){
_assertExists(_span("checkConstraintUniqueFiscalCode: ID already used. It has to be be unique")); _assertExists(_span("checkConstraintUniqueFiscalCode: ID already used. It has to be be unique"));
_assert(_isVisible(_span("checkConstraintUniqueFiscalCode: ID already used. It has to be be unique"))); _assert(_isVisible(_span("checkConstraintUniqueFiscalCode: ID already used. It has to be be unique")));
} }
function workerAcctionValidation($action){
_assertExists(_span("Worker "+$action));
_assert(_isVisible(_span("Worker "+$action)));
}
function workerEmptyFields(){ function workerEmptyFields(){
_assertExists(_div("This field may not be empty or contain only spaces.")); _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."))); _assert(_isVisible(_div("This field may not be empty or contain only spaces.")));
@ -203,15 +185,14 @@ var $projectName = "ProjectForWorker";
/* test actions */ /* test actions */
commonLogin("admin", "admin"); commonLogin("admin", "admin");
workerCreate($workerName, $workerSurName, $workerID); commonWorkerCreate($workerName, $workerSurName, $workerID);
workerCreateDuplicateType($workerName, $workerSurName, $workerID); workerCreateDuplicateType($workerName, $workerSurName, $workerID);
workerCreateEmpty($workerName, $workerSurName, $workerID); workerCreateEmpty($workerName, $workerSurName, $workerID);
workerEdit($workerName, $workerNewName, 5); workerEdit($workerName, $workerNewName, 5);
workerCheckTabs(); workerCheckTabs();
workerCheckCode($workerName, $workerSurName, $workerID); workerCheckCode($workerName, $workerSurName, $workerID);
workerAssignProject($projectName, $workerNewName, $workerSurName); workerAssignProject($projectName, $workerNewName, $workerSurName);
commonDelete("Workers", $workerNewName, 5); commonWorkerDelete($workerNewName);
workerAcctionValidation("deleted");
_log("Delete the worker", "custom1");
workerDeleteRequiredElements(); workerDeleteRequiredElements();
commonLogout(); commonLogout();