From 377000f7a0a92948749ec7197c657cd2c160e9c4 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Mon, 7 Dec 2015 12:54:59 +0530 Subject: [PATCH] CRM-17656 - Cannot edit activities with custom fields in popup from a search results screen --- CRM/Activity/Form/Activity.php | 2 +- .../WebTest/Activity/StandaloneAddTest.php | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 0bb9b9152b..75d8161637 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -474,7 +474,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { $this->set('type', 'Activity'); $this->set('subType', $this->_activityTypeId); $this->set('entityId', $this->_activityId); - CRM_Custom_Form_CustomData::preProcess($this); + CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity', $this->_activityId); CRM_Custom_Form_CustomData::buildQuickForm($this); CRM_Custom_Form_CustomData::setDefaultValues($this); } diff --git a/tests/phpunit/WebTest/Activity/StandaloneAddTest.php b/tests/phpunit/WebTest/Activity/StandaloneAddTest.php index 324fc447f0..4f91841dbe 100644 --- a/tests/phpunit/WebTest/Activity/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Activity/StandaloneAddTest.php @@ -196,4 +196,72 @@ class WebTest_Activity_StandaloneAddTest extends CiviSeleniumTestCase { } } + /** + * CRM-17656 - Test Activity using Custom Data + */ + public function testActivityCustomData() { + $this->webtestLogin(); + + // Create new Custom Field Set + $this->openCiviPage('admin/custom/group', 'reset=1'); + $this->click("css=#newCustomDataGroup > span"); + $this->waitForElementPresent('_qf_Group_next-bottom'); + $customFieldSet = 'ActivityFieldset' . rand(); + $this->type("id=title", $customFieldSet); + $this->select("id=extends_0", "label=Activities"); + $this->addSelection("extends_1", "- Any -"); + $this->click("id=collapse_display"); + $this->clickLink("id=_qf_Group_next-bottom"); + $this->waitForText('crm-notification-container', "Your custom field set '$customFieldSet' has been added."); + $this->waitForElementPresent('_qf_Field_done-bottom'); + + // Add field to fieldset + $customField = 'TestCustomField' . rand(); + $this->type("id=label", $customField); + $this->select("id=data_type_0", "value=0"); + $this->click("is_required"); + $this->click("id=_qf_Field_done-bottom"); + $this->waitForText('crm-notification-container', "Custom field '$customField' has been saved."); + $textFieldId = explode('&id=', $this->getAttribute("xpath=//table[@id='options']/tbody//tr/td[1]/div[text()='$customField']/../../td[8]/span/a[1][text()='Edit Field']/@href")); + $textFieldId = $textFieldId[1]; + + $fname = substr(sha1(rand()), 0, 7); + $this->webtestAddContact("$fname", "Anderson", $fname . "@anderson.com"); + + $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload"); + $this->select("activity_type_id", "value=1"); + $this->select2('target_contact_id', $fname, TRUE); + $subject = "This is subject of test activity being added through standalone screen."; + $this->type("subject", $subject); + $textField = 'This is test custom data'; + $this->type("custom_{$textFieldId}_-1", $textField); + // Clicking save. + $this->clickLink('_qf_Activity_upload'); + $this->waitForText('crm-notification-container', "Activity '$subject' has been saved."); + + $this->openCiviPage("activity/search", "reset=1", "_qf_Search_refresh"); + $this->type("sort_name", $fname); + $this->click("_qf_Search_refresh"); + + $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='Anderson, {$fname}']/../../td[9]/span/a[text()='View']"); + $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='Anderson, {$fname}']/../../td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]"); + + $this->VerifyTabularData( + array( + 'Subject' => $subject, + 'Activity Status' => 'Scheduled', + ), + "/label" + ); + $this->verifyText("xpath=//td[text()='{$customField}']/following-sibling::td", preg_quote($textField), 'In line ' . __LINE__); + + $this->clickAjaxLink("xpath=//button//span[contains(text(),'Edit')]", "xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[contains(text(),'Save')]"); + + $editedTextField = 'This is test custom data - Edited'; + $this->type("custom_{$textFieldId}_1", $editedTextField); + $this->clickAjaxLink("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[contains(text(),'Save')]", "xpath=//button//span[contains(text(),'Edit')]"); + $this->verifyText("xpath=//td[text()='{$customField}']/following-sibling::td", preg_quote($editedTextField), 'In line ' . __LINE__); + } + } -- 2.25.1