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) {
workerCreate($name, $id, $calendar);
commonWorkerCreate($name, $name, $id);
commonResourceEditAssignedCalendarForm("Workers", $name, 5, $calendar);
commonCalendarTryDeleteAssignedCalendar($calendar, 3);
commonWorkerDelete($name);
_log("Assign a calendar to a Worker", "custom1");
@ -107,28 +108,6 @@ function calendarAssignProject($projectName, $calendar){
_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
*/

View file

@ -190,6 +190,20 @@ function commonResourceTryDeleteAssignedValidation(){
* 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");

View file

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