diff --git a/scripts/functional-tests/administration-management/calendar_test.sah b/scripts/functional-tests/administration-management/calendar_test.sah index 073eb5e4b..120c2092f 100644 --- a/scripts/functional-tests/administration-management/calendar_test.sah +++ b/scripts/functional-tests/administration-management/calendar_test.sah @@ -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 */ diff --git a/scripts/functional-tests/common_functions.sah b/scripts/functional-tests/common_functions.sah index d90c5f18c..2267440d0 100644 --- a/scripts/functional-tests/common_functions.sah +++ b/scripts/functional-tests/common_functions.sah @@ -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"); diff --git a/scripts/functional-tests/resources/worker_test.sah b/scripts/functional-tests/resources/worker_test.sah index 195e8c755..8947709f6 100644 --- a/scripts/functional-tests/resources/worker_test.sah +++ b/scripts/functional-tests/resources/worker_test.sah @@ -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();