From eeaee15d9dabef973671d7dee6f79c44c3656a13 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Tue, 12 Aug 2014 15:26:37 +0530 Subject: [PATCH] CaseType Webtest CRM-15098 --- .../phpunit/WebTest/Case/AddCaseTypeTest.php | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 tests/phpunit/WebTest/Case/AddCaseTypeTest.php diff --git a/tests/phpunit/WebTest/Case/AddCaseTypeTest.php b/tests/phpunit/WebTest/Case/AddCaseTypeTest.php new file mode 100644 index 0000000000..a01e96b7be --- /dev/null +++ b/tests/phpunit/WebTest/Case/AddCaseTypeTest.php @@ -0,0 +1,145 @@ + 'Parent of', 2 => 'Spouse of', 3 => 'Partner of'); + $activityTypes = array(1 => 'Meeting',2 => 'Contribution',3 => 'Event Registration'); + $timelineActivityTypes = array(1 => 'Meeting',2 => 'Phone Call',3 => 'Email'); + // Log in as admin first to verify permissions for CiviCase + $this->webtestLogin('admin'); + + // Enable CiviCase module if necessary + $this->enableComponents("CiviCase"); + + // let's give full CiviCase permissions to demo user (registered user). + $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(); + + $this->openCiviPage('a/#/caseType/new'); + + $caseTypeLabel = "Case Type". substr(sha1(rand()), 0, 7); + $this->waitForElementPresent('title'); + $this->type('title', $caseTypeLabel); + + foreach ($caseRoles as $cRoles) { + $this->select2("xpath=//tr[@class='addRow']/td/span/div/a", $cRoles, FALSE, TRUE); + } + + foreach ($activityTypes as $aType) { + $this->select2("xpath=//tr[@class='addRow']/td[contains(text(),'Add activity type:')]/span/div/a", $aType, FALSE, TRUE); + } + + $this->click("xpath=//a[text()='Standard Timeline']"); + foreach ($timelineActivityTypes as $tActivityType) { + $this->select2("xpath=//tr[@class='addRow']/td[contains(text(),'Add activity:')]/span/div/a", $tActivityType, FALSE, TRUE); + } + + $this->click("xpath=//div[@class='crm-submit-buttons']/span/input[@value='Save']"); + + $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); + $firstName = substr(sha1(rand()), 0, 7); + $lastName = "Fraser"; + $contactName = "{$lastName}, {$firstName}"; + $displayName = "{$firstName} {$lastName}"; + $email = "{$lastName}.{$firstName}@example.org"; + $this->webtestNewDialogContact($firstName, $lastName, $email, $type = 4, "s2id_client_id"); + + $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->fireEvent('activity_details', 'focus'); + $this->fillRichTextField("activity_details", $details, 'CKEditor'); + $this->type("activity_subject", $subject); + + $this->select("case_type_id", "label={$caseTypeLabel}"); + $this->select("status_id", "label={$caseStatusLabel}"); + + $this->webtestFillDate('start_date', 'now'); + $today = date('F jS, Y', strtotime('now')); + + $this->type("duration", "20"); + $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom"); + + // Is status message correct? + $this->waitForText('crm-notification-container', "Case opened successfully."); + + foreach ($activityTypes as $aType) { + $this->assertText("add_activity_type_id", $aType); + } + + $this->click("xpath=//div[contains(text(), 'Roles')]"); + + // check that expected roles are listed in the Case Roles pane + foreach ($caseRoles as $key => $role) { + $this->assertText("css=div.crm-case-roles-block", $role); + } + + $id = $this->urlArg('id'); + // check that expected activities are listed in the Case Activities table + foreach ($timelineActivityTypes as $tActivityType) { + $this->assertText("case_id_$id", $tActivityType); + } + + // for edit case type + $this->openCiviPage('a/#/caseType'); + $this->waitForElementPresent("xpath=//*[@id='crm-main-content-wrapper']/div/div/div[2]/a/span[contains(text(),'New Case Type')]"); + + $this->click("xpath=//table/tbody//tr/td[1][text()='{$caseTypeLabel}']/../td[5]/span/a[text()='Edit']"); + $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']/span/input[@value='Save']"); + + $editCaseTypeLabel = "Case Type Edit". substr(sha1(rand()), 0, 7); + $this->waitForElementPresent('title'); + $this->type('title', $editCaseTypeLabel); + + $this->select2("xpath=//tr[@class='addRow']/td/span/div/a", 'Sibling of', FALSE, TRUE); + $this->click("xpath=//*[@id='crm-main-content-wrapper']/div/div/form/div/div[3]/table/tbody/tr[4]/td[2]/input[@type='checkbox']"); + + $this->click("xpath=//a[text()='Standard Timeline']"); + $this->select2("xpath=//tr[@class='addRow']/td[contains(text(),'Add activity:')]/span/div/a", 'SMS', FALSE, TRUE); + + $this->click("xpath=//div[@class='crm-submit-buttons']/span/input[@value='Save']"); + $this->waitForElementPresent("xpath=//*[@id='crm-main-content-wrapper']/div/div/div[2]/a/span[contains(text(),'New Case Type')]"); + + $this->verifyText("xpath=//table/tbody//tr/td[contains(text(),'$editCaseTypeLabel')]", $editCaseTypeLabel); + } +} -- 2.25.1