From 51858dd138b96c0839e1fdd45d8ad41f530ab776 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 15 Sep 2014 21:39:00 -0400 Subject: [PATCH] Fix MultiRecordProfileAddTest --- .../Profile/MultiRecordProfileAddTest.php | 78 ++++++++----------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php index 1d38f8875c..95e1585e81 100644 --- a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php @@ -90,11 +90,6 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { //Profile Advance Settings $this->click("//form[@id='Group']/div[2]/div[2]/div[1]"); - //If you want member(s) of your organization to receive a - //notification email whenever this Profile - //form is used to enter or update contact information, enter one or more email addresses here. - $this->type('notify', 'This is notify email'); - //Drupal user account registration option $this->click('CIVICRM_QFID_0_8'); @@ -114,13 +109,16 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->click('is_uf_link'); //click on save - $this->click('_qf_Group_next'); + $this->clickLink('_qf_Group_next', NULL, TRUE); //check for profile create $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); + $gid = $this->urlArg('gid'); + + $this->openCiviPage('admin/uf/group/field/add', array('action' => 'add', 'reset' => 1, 'gid' => $gid), 'field_name[0]'); + //Add field to profile - $this->waitForElementPresent('field_name[0]'); $this->click('field_name[0]'); $this->select('field_name[0]', 'value=Contact'); $this->click("//option[@value='Contact']"); @@ -179,9 +177,8 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->click('is_searchable'); $this->click('in_selector'); $this->type('help_post', 'This is help for profile field'); - $this->click('_qf_Field_next_new-top'); + $this->clickLink('_qf_Field_next_new-top'); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click('field_name[0]'); $this->select('field_name[0]', 'value=Contact'); $this->click("//option[@value='Contact']"); @@ -190,18 +187,14 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->select('visibility', 'value=Public Pages and Listings'); $this->click('is_searchable'); $this->type('help_post', 'This is help for profile field'); - $this->click('_qf_Field_next'); - //click on save - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink('_qf_Field_next'); $uselink = explode('?', $this->getAttribute("xpath=//*[@id='field_page']/div[1]/a[4]@href")); - $this->openCiviPage('profile/create', "$uselink[1]", '_qf_Edit_cancel'); + $this->openCiviPage('profile/create', "$uselink[1]", '_qf_Edit_next'); $recordNew = $this->_addRecords('Create'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $elements = $this->parseURL(); - $gid = $elements['queryString']['gid']; - $id = $elements['queryString']['id']; + $id = $this->urlArg('id'); if ($userCheck) { //add drupal user @@ -222,8 +215,8 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { } $this->waitForElementPresent("//a/span[contains(text(), 'Add New Record')]"); $this->click("//a/span[contains(text(), 'Add New Record')]"); - $this->waitForElementPresent("_qf_Edit_cancel"); - $record1 = $this->_addRecords(); + $this->waitForElementPresent("_qf_Edit_next"); + $record1 = $this->_addRecords('Edit', TRUE); $this->waitForElementPresent("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[2]/td[1]"); $alertText = $this->getAlert(); $this->assertEquals("Thank you. Your information has been saved.", $alertText); @@ -231,7 +224,8 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->verifyText("//div[@id='custom--table-wrapper']/div/div/table/thead/tr/th[1]", preg_quote($params['textFieldLabel'])); $this->verifyText("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[2]/td[1]", preg_quote($record1['text'])); $this->click("//a/span[contains(text(), 'Add New Record')]"); - $record2 = $this->_addRecords(); + $this->waitForElementPresent("_qf_Edit_next"); + $record2 = $this->_addRecords('Edit', TRUE); $this->waitForElementPresent("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[3]/td[1]"); $alertText = $this->getAlert(); $this->assertEquals("Thank you. Your information has been saved.", $alertText); @@ -242,15 +236,11 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->verifyElementNotPresent("//a/span[contains(text(), 'Add New Record')]"); //Check for edit functionality - // Because it tends to cause problems, all uses of sleep() must be justified in comments - // Sleep should never be used for wait for anything to load from the server - // Justification for this instance: FIXME - sleep(3); $this->click("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr/td[3]/span/a[text()='Edit']"); - $this->waitForElementPresent("xpath=//div[@class='ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']/form/div[2]//div[@id='crm-profile-block']//div[@class='crm-submit-buttons']/span/input[@class='validate crm-form-submit default crm-form-submit']"); + $this->waitForElementPresent("xpath=//div[@class='ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']/form/div[2]//div[@id='crm-profile-block']"); $this->verifyText("//div[@id='custom--table-wrapper']/div/div/table/thead/tr/th[1]", preg_quote($params['textFieldLabel'])); $this->type("//div[@id='crm-profile-block']/div/div[2]/input[@class='crm-form-text required']", $recordNew['text'].'edit'); - $this->click("xpath=//div[@class='ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']/form/div[2]//div[@id='crm-profile-block']//div[@class='crm-submit-buttons']/span/input[@class='validate crm-form-submit default crm-form-submit']"); + $this->click("css=.ui-dialog-buttonset button[data-identifier=_qf_Edit_next]"); $this->waitForText("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr[1]/td[1]", $recordNew['text'].'edit'); $editalertText = $this->getAlert(); $this->assertEquals("Thank you. Your information has been saved.", $editalertText); @@ -258,24 +248,16 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { // Check the delete functionality $this->click("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr/td[3]/span/a[text()='Delete']"); - $this->waitForElementPresent("xpath=//div[@class='ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']/form/div[2]/div"); - $this->assertElementContainsText("xpath=//div[@class='ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']/form/div[2]/div", 'Are you sure you want to delete this record?'); + $this->waitForText("css=.ui-dialog-content.crm-ajax-container", 'Are you sure you want to delete this record?'); $this->click('_qf_Edit_upload_delete'); - // Because it tends to cause problems, all uses of sleep() must be justified in comments - // Sleep should never be used for wait for anything to load from the server - // Justification for this instance: FIXME - sleep(3); + $this->waitForElementPresent("//a/span[contains(text(), 'Add New Record')]"); $delText = $this->getAlert(); $this->assertEquals("Deleted Your record has been deleted.", $delText); - // Check the view functionality - // Because it tends to cause problems, all uses of sleep() must be justified in comments - // Sleep should never be used for wait for anything to load from the server - // Justification for this instance: FIXME - sleep(3); + $this->click("//div[@id='custom--table-wrapper']/div/div/table/tbody/tr/td[3]/span/a[text()='View']"); - $this->waitForText("xpath=//div[@class='ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix']", 'View '.$params['customGroupTitle']); - $this->assertElementContainsText("xpath=//div[@class='ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']", $params['textFieldLabel']); + $this->waitForText("css=.ui-dialog-title", 'View '.$params['customGroupTitle'] . ' Record'); + $this->assertElementContainsText("css=.ui-dialog-content.crm-ajax-container", $params['textFieldLabel']); if ($checkSearchable) { $this->verifyElementNotPresent("//div[@id='profile-dialog']/div/div/div/div/div[1]/div[2]/a"); return array($gid, $profileTitle); @@ -331,11 +313,14 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->waitForElementPresent("//input[@id='is_multiple']"); $this->click("//input[@id='is_multiple']"); $this->type("max_multiple", 3); - $this->click("//form[@id='Group']/div[2]/div[3]/span[1]/input"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink("//form[@id='Group']/div[2]/div[3]/span[1]/input"); //Is custom group created? $this->assertElementContainsText('crm-container', $params['customGroupTitle']); + + $gid = $this->urlArg('gid'); + $this->openCiviPage('admin/custom/group/field/add', 'reset=1&action=add&gid=' . $gid); + //add custom field - alphanumeric text $params['textFieldLabel'] = 'test_text_field' . substr(sha1(rand()), 0, 3); $this->click("header"); @@ -373,7 +358,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->click("is_searchable"); //clicking save - $this->click("_qf_Field_next-bottom"); + $this->click("_qf_Field_done-bottom"); //Is custom field created? $this->waitForText('crm-notification-container', $params['selectFieldLabel']); @@ -386,7 +371,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { * * @return mixed */ - function _addRecords($context = 'Edit', $parentElement = '//') { + function _addRecords($context = 'Edit', $dialog = FALSE) { $params['text'] = 'text' . substr(sha1(rand()), 0, 3); $this->waitForElementPresent("//div[@id='crm-profile-block']/div/div[2]/input[@class='crm-form-text required']"); $this->type("//div[@id='crm-profile-block']/div/div[2]/input[@class='crm-form-text required']", $params['text']); @@ -399,12 +384,17 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->type('email-Primary', $params['email']); $this->waitForElementPresent("//div[@id='crm-profile-block']//div/div[2]/select"); $this->select("//div[@id='crm-profile-block']//div/div[2]/select",'value=1'); - $this->click("xpath=//div[@id='crm-profile-block']//div[@class='crm-submit-buttons']/span/input[@class='validate crm-form-submit default crm-form-submit']"); } else { $this->waitForElementPresent("//div[@id='crm-profile-block']//div/div[2]/select"); $this->select("//div[@id='crm-profile-block']//div/div[2]/select",'value=1'); - $this->click("xpath=//div[@class='ui-dialog-content ui-widget-content modal-dialog crm-ajax-container']/form/div[2]//div[@id='crm-profile-block']//div[@class='crm-submit-buttons']/span/input[@class='validate crm-form-submit default crm-form-submit']"); + + } + if ($dialog) { + $this->click("css=.ui-dialog-buttonset button[data-identifier=_qf_Edit_next]"); + } + else { + $this->click("_qf_Edit_next"); } return $params; } -- 2.25.1