/* * This file is part of LibrePlan * * 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 . */ /* Included tests * * 1 - Create a Criterion * 2 - Create a Calendar * 3 - Create a Worker * 4 - Assign elements to a worker * 4.1 - Assign Criterion * 4.2 - Assign Calendar (Incorrect dates) * 5 - Create a project * 6 - Create a Task * 7 - Try to assign the worker with the incorrect calendar * 8 - Assign elements to a worker * 8.1 - Assign Criterion (Incorrect dates) * 8.2 - Assign Calendar * 9 - Allocate criterion into the first task * 10 - Check Project planning filter * 11 - Delete all required elements * */ _include("../common_functions.sah"); function planningIncludeEndDates($worker, $dates, $dates2){ _click(_link("Workers")); commonEdit($worker, 5); planningIncludeCriterionEndDate($dates); planningIncludeCalendarEndDate($dates2); } function planningIncludeCriterionEndDate($dates){ _click(_span("Assigned criteria")); _setValue(_textbox("z-datebox-input", _near(_div("Starting date"))), $dates[0]); _setValue(_textbox(3, _near(_div("Starting date"))), $dates[1]); _click(_cell("Save & Continue")); commonWorkerAcctionValidation("saved"); _log("Include criterion dates", "custom1"); } function planningIncludeCalendarEndDate($dates){ _click(_span("Calendar")); _click(_span("Activation periods")); _setValue(_textbox(0, _near(_div("Expiry date"))), $dates[0]); _setValue(_textbox(2, _near(_div("Expiry date"))), $dates[1]); _click(_cell("Save")); commonWorkerAcctionValidation("saved"); _log("Include calendar dates", "custom1"); } function planningAssignWorker($workerName){ _click(_cell("Project Scheduling")); _doubleClick(_div("box standard-task yui-resize unassigned")); _setValue(_textbox(0, _near(_span("Select criteria or resources"))), $workerName); _removeFocus(_textbox(0, _near(_span("Select criteria or resources")))); _click(_div($workerName+", "+$workerName)); _click(_cell($workerName+", "+$workerName)); _click(_cell("Add")); _click(_row("Accept[2]")); planningCheckIncorrectWorkerValidation() _log("try to assign calendar", "custom1"); } function planningAssignCriterion($criterion){ _click(_cell("Project Scheduling")); _doubleClick(_div("box standard-task yui-resize unassigned")); _setValue(_textbox(0, _near(_span("Select criteria or resources"))), $criterion); _removeFocus(_textbox(0, _near(_span("Select criteria or resources")))); _click(_div($criterion+" ( "+$criterion+" )[1]")); _click(_cell($criterion+" ( "+$criterion+" )[1]")); _click(_cell("Add")); _click(_row("Accept[2]")); planningCheckIncorrectCriterionValidation() _log("Try to assign criterion", "custom1"); } function planningAssignCriterionInWBS($projectName, $criterion){ commonEditProject($projectName); _doubleClick(_span("z-dottree-ico z-dottree-firstspacer")); _click(_span("Criterion Requirement[1]")); _click(_cell("z-button-cm", _near(_div("Assigned criterion requirements[1]")))); _click(_italic(0, _near(_div("Criterion name[1]")))); _click(_div($criterion)); _click(_image("ico_save.png")); _click(_cell("OK")); } function planningCheckAssignedCriterion($criterion){ _click(_cell("Project Scheduling")); _click(_image("ico_resources.png")); commonProjectPlanningFilter($criterion, $criterion) } function planningCheckIncorrectWorkerValidation(){ _assertExists(_div("Resource is not available from task's start")); _assert(_isVisible(_div("Resource is not available from task's start"))); } function planningCheckIncorrectCriterionValidation(){ _assertExists(_div("There are no days available due to not satisfying the criteria. Another possibility is that the resources do not have days available due to their calendars.")); _assert(_isVisible(_div("There are no days available due to not satisfying the criteria. Another possibility is that the resources do not have days available due to their calendars."))); } function deleteRequiredElements(){ commonDeleteProject($projectName); commonWorkerDelete($workerName); commonCriteriaDelete($criterion); commonCalendarDelete($calendar); } /* test values */ var $criterion = "Formation"; var $calendar = "calendarForPlanning"; var $workerName = "workerForPlanning"; var $criteriaType2List = ["Spain", "USA"]; var $dates = ["Jul 1, 2011", "Sep 10, 2011"] var $dates2 = ["Jul 1, 2011", ""] var $projectName = "ProjectForPlannig"; var $taskName = "taskForPlanning"; var $taskName2 = "taskForPlanning2"; /* test actions */ commonLogin("admin", "admin"); commonCriteriaCreate($criterion, [$criterion]); commonCalendarCreate($calendar); commonWorkerCreate($workerName, $workerName, $workerName); commonResourceEditAssignedCriteriaForm("Workers", $workerName, 5, $criterion); commonResourceEditAssignedCalendarForm("Workers", $workerName, 5, $calendar); planningIncludeEndDates($workerName, $dates2, $dates); commonCreateProject($projectName); commonCreateTask($projectName, $taskName, "10"); commonCreateTask($projectName, $taskName2, "12"); planningAssignWorker($workerName); planningIncludeEndDates($workerName, $dates, $dates2); commonEditProject($projectName); planningAssignCriterion($criterion); planningAssignCriterionInWBS($projectName, $criterion); planningCheckAssignedCriterion($criterion); deleteRequiredElements(); commonLogout();