From: Aaditya Walawalkar Date: Mon, 5 Aug 2013 11:19:46 +0000 (+0530) Subject: Fixed CRM-12812 & added a webtest for the same. Correct syntax error in ActivityChang... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7c20a3bd3115115705b1ca99acf5b6dfb23badb2;p=civicrm-core.git Fixed CRM-12812 & added a webtest for the same. Correct syntax error in ActivityChangeStatus.js [added missing ');' at the end of page] ---------------------------------------- * CRM-12812: case custom field using wysiwyg fails to load http://issues.civicrm.org/jira/browse/CRM-12812 * CRM-12812-Fixes: http://issues.civicrm.org/jira/browse/CRM-12812-Fixes * CRM-12439-org: http://issues.civicrm.org/jira/browse/CRM-12439-org * CRM-12439: Add description field for Profiles and expose the created_id field http://issues.civicrm.org/jira/browse/CRM-12439 * CRM-12995-1: http://issues.civicrm.org/jira/browse/CRM-12995-1 * CRM-12995-2: http://issues.civicrm.org/jira/browse/CRM-12995-2 --- diff --git a/templates/CRM/Case/Form/ActivityChangeStatus.js b/templates/CRM/Case/Form/ActivityChangeStatus.js index 694f61a4eb..650661bbb3 100644 --- a/templates/CRM/Case/Form/ActivityChangeStatus.js +++ b/templates/CRM/Case/Form/ActivityChangeStatus.js @@ -62,6 +62,4 @@ cj(function($) { ); return false; }); -} - - +}); \ No newline at end of file diff --git a/templates/CRM/Case/Page/CustomDataView.tpl b/templates/CRM/Case/Page/CustomDataView.tpl index dd85887cbf..a430b955f2 100644 --- a/templates/CRM/Case/Page/CustomDataView.tpl +++ b/templates/CRM/Case/Page/CustomDataView.tpl @@ -23,6 +23,10 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} +{* include wysiwyg related files*} +{if !$includeWysiwygEditor} + {include file="CRM/common/wysiwyg.tpl" includeWysiwygEditor=true} +{/if} {* Custom Data view mode*} {foreach from=$viewCustomData item=customValues key=customGroupId} {foreach from=$customValues item=cd_edit key=cvID} diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 480a5b31df..31a9f12694 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -526,7 +526,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { // Is new contact created? if ($lname) { - $this->assertTrue($this->isTextPresent("$lname, $fname has been created."), "Status message didn't show up after saving!"); + $this->assertTrue($this->isTextPresent("$fname $lname has been created."), "Status message didn't show up after saving!"); } else { $this->assertTrue($this->isTextPresent("$fname has been created."), "Status message didn't show up after saving!"); diff --git a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php index 4ec08bf485..b0939b211a 100644 --- a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php +++ b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php @@ -214,63 +214,229 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->assertElementPresent("name=case_report_all", "Print Case Summary button is missing."); } - function _testGetCustomFieldId($customGrpId1) { + function _testGetCustomFieldId($customGrpId1, $noteRichEditor=FALSE) { $customId = array(); - // Create a custom data to add in profile - $field1 = "Fname" . substr(sha1(rand()), 0, 7); - $field2 = "Mname" . substr(sha1(rand()), 0, 7); - $field3 = "Lname" . substr(sha1(rand()), 0, 7); - - // add custom fields for group 1 - $this->openCiviPage('admin/custom/group/field/add', array('reset' => 1, 'action' => 'add', 'gid' => $customGrpId1)); - $this->type("label", $field1); - $this->check("is_searchable"); - $this->click("_qf_Field_next_new-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - $this->type("label", $field2); - $this->check("is_searchable"); - $this->click("_qf_Field_next_new-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - $this->type("label", $field3); - $this->check("is_searchable"); - $this->click("_qf_Field_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - // get id of custom fields - $this->openCiviPage("admin/custom/group/field", array('reset' => 1, 'action' => 'browse', 'gid' => $customGrpId1)); - $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href")); - $custom1 = $custom1[1]; - array_push($customId, $custom1); - $custom2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[2]/td[8]/span/a[text()='Edit Field']/@href")); - $custom2 = $custom2[1]; - array_push($customId, $custom2); - $custom3 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[3]/td[8]/span/a[text()='Edit Field']/@href")); - $custom3 = $custom3[1]; - array_push($customId, $custom3); + if ($noteRichEditor) { + // Create a custom data to add in profile + $field1 = "Note_Textarea" . substr(sha1(rand()), 0, 7); + $field2 = "Note_Richtexteditor" . substr(sha1(rand()), 0, 7); + + // add custom fields for group 1 + $this->openCiviPage('admin/custom/group/field/add', array('reset' => 1, 'action' => 'add', 'gid' => $customGrpId1)); + $this->type("label", $field1); + $this->select("data_type_0", "value=4"); + $this->select("data_type_1", "value=TextArea"); + $this->check("is_searchable"); + $this->clickLink("_qf_Field_next_new-bottom"); + + $this->type("label", $field2); + $this->select("data_type_0", "value=4"); + //$this->select("data_type_1", "value=TextArea"); + $this->select("data_type_1", "value=RichTextEditor"); + $this->check("is_searchable"); + $this->clickLink("_qf_Field_next_new-bottom"); + + // get id of custom fields + $this->openCiviPage("admin/custom/group/field", array('reset' => 1, 'action' => 'browse', 'gid' => $customGrpId1)); + $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href")); + $custom1 = $custom1[1]; + array_push($customId, $custom1); + $custom2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[2]/td[8]/span/a[text()='Edit Field']/@href")); + $custom2 = $custom2[1]; + array_push($customId, $custom2); + } + else { + // Create a custom data to add in profile + $field1 = "Fname" . substr(sha1(rand()), 0, 7); + $field2 = "Mname" . substr(sha1(rand()), 0, 7); + $field3 = "Lname" . substr(sha1(rand()), 0, 7); + + // add custom fields for group 1 + $this->openCiviPage('admin/custom/group/field/add', array('reset' => 1, 'action' => 'add', 'gid' => $customGrpId1)); + $this->type("label", $field1); + $this->check("is_searchable"); + $this->click("_qf_Field_next_new-bottom"); + $this->waitForPageToLoad($this->getTimeoutMsec()); + + $this->type("label", $field2); + $this->check("is_searchable"); + $this->click("_qf_Field_next_new-bottom"); + $this->waitForPageToLoad($this->getTimeoutMsec()); + + $this->type("label", $field3); + $this->check("is_searchable"); + $this->click("_qf_Field_next-bottom"); + $this->waitForPageToLoad($this->getTimeoutMsec()); + + // get id of custom fields + $this->openCiviPage("admin/custom/group/field", array('reset' => 1, 'action' => 'browse', 'gid' => $customGrpId1)); + $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href")); + $custom1 = $custom1[1]; + array_push($customId, $custom1); + $custom2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[2]/td[8]/span/a[text()='Edit Field']/@href")); + $custom2 = $custom2[1]; + array_push($customId, $custom2); + $custom3 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[3]/td[8]/span/a[text()='Edit Field']/@href")); + $custom3 = $custom3[1]; + array_push($customId, $custom3); + } return $customId; } function _testDeleteCustomData($customGrpId1, $customId) { // delete all custom data - $this->openCiviPage("admin/custom/group/field", array('action' => 'delete', 'reset' => '1', 'gid' => $customGrpId1, 'id' => $customId[0])); - $this->click("_qf_DeleteField_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + foreach ($customId as $cKey => $cValue) { + $this->openCiviPage("admin/custom/group/field", array('action' => 'delete', 'reset' => '1', 'gid' => $customGrpId1, 'id' => $cValue)); + $this->clickLink("_qf_DeleteField_next-bottom"); + } + + // delete custom group + $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=" . $customGrpId1); + $this->clickLink("_qf_DeleteGroup_next-bottom"); + } - $this->openCiviPage("admin/custom/group/field", array('action' => 'delete', 'reset' => '1', 'gid' => $customGrpId1, 'id' => $customId[1])); - $this->click("_qf_DeleteField_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + /** + * CRM-12812 + */ + function testCaseCustomNoteRichEditor() { + $this->webtestLogin('admin'); - $this->openCiviPage("admin/custom/group/field", array('action' => 'delete', 'reset' => '1', 'gid' => $customGrpId1, 'id' => $customId[2])); - $this->click("_qf_DeleteField_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + // Enable CiviCase module if necessary + $this->enableComponents("CiviCase"); - $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=" . $customGrpId1); - $this->click("_qf_DeleteGroup_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $customGrp1 = "CaseCustom_Data1_" . substr(sha1(rand()), 0, 7); + + // create custom group1 + $this->openCiviPage('admin/custom/group', 'reset=1'); + $this->clickLink("newCustomDataGroup"); + $this->type("title", $customGrp1); + $this->select("extends[0]", "value=Case"); + $this->select("extends_1", "value=2"); + $this->clickLink("_qf_Group_next-bottom"); + + // get custom group id + $customGrpId1 = $this->urlArg('gid'); + + $customId = $this->_testGetCustomFieldId($customGrpId1, TRUE); + $cusId_1 = 'custom_' . $customId[0] . '_-1'; + $cusId_2 = 'custom_' . $customId[1] . '_-1'; + + // let's give full CiviCase permissions. + $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); + $this->changePermissions($permission); + + // Log in as normal user + $this->webtestLogin(); + + // Go to reserved New Individual Profile to set value for logged in user's contact name (we'll need that later) + $this->openCiviPage('profile/edit', 'reset=1&gid=4', '_qf_Edit_next'); + $testUserFirstName = "Testuserfirst"; + $testUserLastName = "Testuserlast"; + $this->type("first_name", $testUserFirstName); + $this->type("last_name", $testUserLastName); + $this->clickLink("_qf_Edit_next", "profilewrap4"); + + $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); + + // Try submitting the form without creating or selecting a contact (test for CRM-7971) + $this->clickLink("_qf_Case_upload-bottom", "css=span.crm-error"); + + // Adding contact with randomized first name (so we can then select that contact when creating case) + // We're using pop-up New Contact dialog + $firstName = substr(sha1(rand()), 0, 7); + $lastName = "Fraser"; + $contactName = "{$lastName}, {$firstName}"; + $displayName = "{$firstName} {$lastName}"; + $email = "{$lastName}.{$firstName}@example.org"; + $custFname = "Mike" . substr(sha1(rand()), 0, 7); + $custLname = "Krist" . substr(sha1(rand()), 0, 7); + $this->webtestNewDialogContact($firstName, $lastName, $email, $type = 4); + + // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. + $caseTypeLabel = "Adult Day Care Referral"; + + // activity types we expect for this case type + $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation"); + $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client"); + $caseStatusLabel = "Ongoing"; + $subject = "Safe daytime setting - senior female"; + $this->select("medium_id", "value=1"); + $location = "Main offices"; + $this->type("activity_location", $location); + $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented."; + $this->fillRichTextField("activity_details", $details, 'CKEditor'); + $this->type("activity_subject", $subject); + + $this->select("case_type_id", "label={$caseTypeLabel}"); + $this->select("status_id", "label={$caseStatusLabel}"); + + // Choose Case Start Date. + // Using helper webtestFillDate function. + $this->webtestFillDate('start_date', 'now'); + $today = date('F jS, Y', strtotime('now')); + + $this->type("duration", "20"); + $this->type("{$cusId_1}", $custFname); + $this->type("{$cusId_2}", $custLname); + $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom"); + + // Is status message correct? + $this->assertTextPresent("Case opened successfully.", "Save successful status message didn't show up after saving!"); + $this->clickLink("_qf_CaseView_cancel-bottom"); + + $this->openCiviPage('case', 'reset=1'); + $this->waitForElementPresent("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[8]/a[text()='Open Case']"); + + $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[8]/a[text()='Open Case']"); + $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Done']"); + + $openCaseData = array( + "Client" => $displayName, + "Activity Type" => "Open Case", + "Subject" => $subject, + "Created By" => "{$testUserFirstName} {$testUserLastName}", + "Reported By" => "{$testUserFirstName} {$testUserLastName}", + "Medium" => "In Person", + "Location" => $location, + "Date and Time" => $today, + "Status" => "Completed", + "Priority" => "Normal", + ); + // wait for elements to load + foreach ($openCaseData as $label => $value) { + $this->waitForElementPresent("xpath=//table/tbody/tr/td[text()='{$label}']/following-sibling::td"); + } + $this->webtestVerifyTabularData($openCaseData); + $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Done']"); + + // verify if custom data is present + $this->openCiviPage('case', 'reset=1'); + $this->clickLink("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[9]/span/a[text()='Manage']", "css=#{$customGrp1} .crm-accordion-header"); + + $this->click("css=#{$customGrp1} .crm-accordion-header"); + + $cusId_1 = 'custom_' . $customId[0] . '_1'; + $cusId_2 = 'custom_' . $customId[1] . '_1'; + $this->click("css=#{$customGrp1} a.button"); + + // wait for dialog element + $this->waitForElementPresent("css=div.ui-dialog div.ui-dialog-titlebar"); + // check for dialog box Title + $this->assertElementContainsText("css=div.ui-dialog div.ui-dialog-titlebar", 'Update Case Information'); + + $custFname = "Miky" . substr(sha1(rand()), 0, 7); + $custLname = "Kristy" . substr(sha1(rand()), 0, 7); + $this->type("{$cusId_1}", $custFname); + + // Wait for rich text editor element + $this->waitForElementPresent("css=div#cke_{$cusId_2}"); + + $this->fillRichTextField("{$cusId_2}", $custLname, 'CKEditor'); + $this->click("_qf_CustomData_upload"); + // delete custom data + $this->_testDeleteCustomData($customGrpId1, $customId); } function _testAdvansearchCaseData($customId, $custFname, $custMname, $custLname) {