TASKPM/scripts/functional-tests/resources/companies_test.sah

94 lines
2.7 KiB
Text
Raw Normal View History

/*
* 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 <http://www.gnu.org/licenses/>.
*/
/* Included tests
*
* 1 - Create a new Company
* 2 - Create a Company with duplicate type (it should be a failure)
* 3 - Create a Company with empty type (it should be a failure)
* 4 - Create a Company with duplicate name (it should be a failure)
* 5 - Edit a Company
* 6 - Delete Company
*
*/
_include("../common_functions.sah");
function companyCreateDuplicateType($name, $ID) {
commonCreate("Companies");
commonCompanyForm($name, $ID);
companyDuplicatedName();
companyDuplicatedId();
}
function companyCreateEmpty($name, $ID) {
commonCreate("Companies");
_click(_cell("Save"));
companyEmptyField();
_setValue(_textbox(0, _near(_span("Company name:"))), $name);
_click(_cell("Save"));
companyEmptyField();
_setValue(_textbox(0, _near(_span("Company ID:"))), $ID);
}
function companyEdit($oldName, $newName, $cell) {
commonEdit($oldName, $cell);
commonCompanyForm($newName);
commonSaveValidation("Company", $newName);
}
/*
* Validations
*/
function companyDuplicatedName(){
_assertExists(_span("company name must be unique. Company name already used"));
_assert(_isVisible(_span("company name must be unique. Company name already used")));
}
function companyDuplicatedId(){
_assertExists(_span("Company ID already used. It must be unique"));
_assert(_isVisible(_span("Company ID already used. It must be unique")));
}
function companyEmptyField(){
_assertExists(_div("cannot be empty"));
_assert(_isVisible(_div("cannot be empty")));
}
/* test values */
var $companyName = "subcompany";
var $companyId = "SUbCOMPANY_CODE";
var $companyNewName = "newest";
/* test actions */
commonLogin("admin", "admin");
commonCompanyCreate($companyName, $companyId);
companyCreateDuplicateType($companyName, $companyId);
companyCreateEmpty("", $companyId);
companyEdit($companyName, $companyNewName, 5);
commonDelete("Companies", $companyNewName, 5);
commonDeleteValidation("Company", $companyNewName);
commonLogout();