From 8bbf0042ec47bbf491f24d16be6f3f4de8dc3a19 Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Mon, 15 Apr 2024 11:31:23 +0800 Subject: [PATCH 1/8] refs #37463, Remove casperjs completely --- tests/casperjs/add_contact.test.js | 116 -- tests/casperjs/add_contribution_page.test.js | 397 ---- tests/casperjs/add_event.test.js | 296 --- tests/casperjs/add_group.test.js | 362 ---- tests/casperjs/add_profile.test.js | 970 --------- tests/casperjs/advanced_search.test.js | 191 -- tests/casperjs/batch_action.test.js | 886 -------- tests/casperjs/contribution_allpay.js | 72 - tests/casperjs/contribution_allpay_atm.js | 108 - tests/casperjs/contribution_allpay_barcode.js | 103 - tests/casperjs/custom_data.test.js | 1787 ----------------- tests/casperjs/edit_contact.test.js | 181 -- tests/casperjs/event_participant.test.js | 196 -- tests/casperjs/event_register.js | 268 --- tests/casperjs/files/import.csv | 3 - tests/casperjs/googletest.js | 22 - tests/casperjs/import.js | 193 -- tests/casperjs/new_contribution.test.js | 352 ---- tests/casperjs/pages.js | 124 -- 19 files changed, 6627 deletions(-) delete mode 100644 tests/casperjs/add_contact.test.js delete mode 100644 tests/casperjs/add_contribution_page.test.js delete mode 100644 tests/casperjs/add_event.test.js delete mode 100644 tests/casperjs/add_group.test.js delete mode 100644 tests/casperjs/add_profile.test.js delete mode 100644 tests/casperjs/advanced_search.test.js delete mode 100644 tests/casperjs/batch_action.test.js delete mode 100644 tests/casperjs/contribution_allpay.js delete mode 100644 tests/casperjs/contribution_allpay_atm.js delete mode 100644 tests/casperjs/contribution_allpay_barcode.js delete mode 100644 tests/casperjs/custom_data.test.js delete mode 100644 tests/casperjs/edit_contact.test.js delete mode 100644 tests/casperjs/event_participant.test.js delete mode 100644 tests/casperjs/event_register.js delete mode 100644 tests/casperjs/files/import.csv delete mode 100644 tests/casperjs/googletest.js delete mode 100644 tests/casperjs/import.js delete mode 100644 tests/casperjs/new_contribution.test.js delete mode 100644 tests/casperjs/pages.js diff --git a/tests/casperjs/add_contact.test.js b/tests/casperjs/add_contact.test.js deleted file mode 100644 index f76df6752..000000000 --- a/tests/casperjs/add_contact.test.js +++ /dev/null @@ -1,116 +0,0 @@ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var first_name = makeid(5); -var last_name = makeid(5); - -var vars = { - baseURL : port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - first_name: first_name, - last_name: last_name, - user_email: first_name.toLowerCase() + last_name.toLowerCase() + '123@gmail.com', - user_phone: '09' + Math.floor(Math.random() * 100000000).toString() -}; - -casper.on('page.error', function(msg, trace) { - this.echo('Error: ' + msg, 'ERROR'); - for (var i = 0; i < trace.length; i++) { - var step = trace[i]; - this.echo(' ' + step.file + ' (line ' + step.line + ')', 'ERROR'); - } -}); - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - //this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Start testing...', function(test){ - casper.thenOpen(vars.baseURL + 'civicrm/contact/add?reset=1&ct=Individual', function() { - this.capture('add_individual.png'); - }); - casper.waitForSelector("form[name=Contact]", function success() { - casper.echo('====================================='); - casper.echo('** Step 1: Add Individual. **'); - casper.echo('====================================='); - - this.sendKeys("input[name='last_name']", vars.last_name); - casper.echo('Add lastname.') - - this.sendKeys("input[name='first_name']", vars.first_name); - casper.echo('Add firstname.') - - this.sendKeys("input[name='email[1][email]']", vars.user_email); - casper.echo('Add email.') - - this.sendKeys("input[name='phone[1][phone]']", vars.user_phone); - casper.echo('Add phone.') - - this.evaluate(function () { - document.querySelector("#phone_1_phone_type_id").selectedIndex = 1; - }) - casper.echo('Change phone type.') - - this.click("form[name=Contact] input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form[name=Contact]", "Contact form exist."); - }); - - casper.wait(2000); - casper.then(function() { - //this.capture('personal_info.png'); - }) - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 2: Check If Personal Information Correct. **'); - casper.echo('====================================='); - test.assertTitle(vars.first_name + ' ' + vars.last_name + ' | netiCRM'); - }); - casper.waitForSelector("#contact-summary .contactCardLeft a", function success() { - var email = this.evaluate(function () { - return document.querySelector("#contact-summary .contactCardLeft a").text; - }); - test.assertEquals(email, vars.user_email); - }, function fail() { - test.assertExists("#contact-summary .contactCardLeft a", 'email exist.'); - }); - casper.waitForSelector("#contact-summary .contactCardRight .primary span", function success() { - var phone = this.evaluate(function() { - return document.querySelector("#contact-summary .contactCardRight .primary span").textContent; - }); - test.assertEquals(phone, vars.user_phone); - }, function fail() { - test.assertExists("#contact-summary .contactCardRight .primary span"); - }); - - casper.run(function() { - test.done(); - }); -}); \ No newline at end of file diff --git a/tests/casperjs/add_contribution_page.test.js b/tests/casperjs/add_contribution_page.test.js deleted file mode 100644 index 19b51bbd5..000000000 --- a/tests/casperjs/add_contribution_page.test.js +++ /dev/null @@ -1,397 +0,0 @@ -/* basic setting */ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var vars = { - baseURL : port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/' -}; - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0-0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - /* open add contribution page */ - casper.thenOpen(vars.baseURL + "civicrm/admin/contribute/add?reset=1&action=add", function() { - casper.echo('====================================='); - casper.echo('** Step 0-1: Enter "New Contribution Page" Page. **'); - casper.echo('====================================='); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Start testing...', function(test) { - - /* - * Step 1: Title - */ - - /* sendKeys to Title */ - casper.waitForSelector("form#Settings input[name='title']", function success() { - casper.echo('====================================='); - casper.echo('** Step 1: Title. **'); - casper.echo('====================================='); - test.assertExists("form#Settings input[name='title']"); - this.sendKeys("form#Settings input[name='title']", makeid(10)); - }, function fail() { - test.assertExists("form#Settings input[name='title']"); - }); - - casper.then(function() { - // this.capture('1_Title.png'); - }); - - /* click Continue >> */ - casper.waitForSelector("form#Settings input[type=submit][value='Continue >>']", function success() { - test.assertExists("form#Settings input[type=submit][value='Continue >>']"); - this.click("form#Settings input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form#Settings input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - - /* - * Step 2: Amounts - */ - - /* click pay later */ - casper.waitForSelector('#is_pay_later', function success() { - casper.echo('====================================='); - casper.echo('** Step 2: Amounts. **'); - casper.echo('====================================='); - test.assertExists('#is_pay_later'); - this.click('#is_pay_later'); - }, function fail() { - test.assertExists('#is_pay_later'); - }); - - /* sendKeys to Pay later instructions */ - casper.waitForSelector("#pay_later_receipt", function success() { - test.assertExists("#pay_later_receipt"); - this.sendKeys("#pay_later_receipt", "I will send payment by check"); - }, function fail() { - test.assertExists("#pay_later_receipt"); - }); - - /* sendKeys to Fixed Contribution Options */ - casper.waitForSelector("form#Amount input[name='label[1]']", function success() { - test.assertExists("form#Amount input[name='label[1]']"); - this.sendKeys("form#Amount input[name='label[1]']", '100'); - }, function fail() { - test.assertExists("form#Amount input[name='label[1]']"); - }); - casper.waitForSelector("form#Amount input[name='value[1]']", function success() { - test.assertExists("form#Amount input[name='value[1]']"); - this.sendKeys("form#Amount input[name='value[1]']", '100'); - }, function fail() { - test.assertExists("form#Amount input[name='value[1]']"); - }); - - casper.waitForSelector("form#Amount input[name='label[2]']", function success() { - test.assertExists("form#Amount input[name='label[2]']"); - this.sendKeys("form#Amount input[name='label[2]']", '200'); - }, function fail() { - test.assertExists("form#Amount input[name='label[2]']"); - }); - casper.waitForSelector("form#Amount input[name='value[2]']", function success() { - test.assertExists("form#Amount input[name='value[2]']"); - this.sendKeys("form#Amount input[name='value[2]']", '200'); - }, function fail() { - test.assertExists("form#Amount input[name='value[2]']"); - }); - - casper.then(function() { - // this.capture('2_Amount.png'); - }); - - /* click submit */ - casper.waitForSelector("form#Amount input[type=submit][value='Continue >>']", function success() { - test.assertExists("form#Amount input[type=submit][value='Continue >>']"); - this.click("form#Amount input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form#Amount input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - - /* - * Step 3: Memberships - */ - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 3: Memberships. **'); - casper.echo('====================================='); - // this.capture('3_Memberships.png'); - }); - /* click submit */ - casper.waitForSelector("form#MembershipBlock input[type=submit][value='Continue >>']", function success() { - test.assertExists("form#MembershipBlock input[type=submit][value='Continue >>']"); - this.click("form#MembershipBlock input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form#MembershipBlock input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - - /* - * Step 4: Thanks - */ - - /* sendKeys to Thank-you Page Title */ - casper.waitForSelector("#thankyou_title", function success() { - casper.echo('====================================='); - casper.echo('** Step 4: Thanks. **'); - casper.echo('====================================='); - test.assertExists("#thankyou_title"); - this.sendKeys("#thankyou_title", makeid(10)); - }, function fail() { - test.assertExists("#thankyou_title"); - }); - - /* sendKeys to Payment Notification From Email */ - casper.waitForSelector("#receipt_from_email", function success() { - test.assertExists("#receipt_from_email"); - this.sendKeys("#receipt_from_email", makeid(5) + "@fakemail.com"); - }, function fail() { - test.assertExists("#receipt_from_email"); - }); - - casper.then(function() { - // this.capture('4_Thanks.png'); - }); - - /* click submit */ - casper.waitForSelector("form#ThankYou input[type=submit][value='Continue >>']", function success() { - test.assertExists("form#ThankYou input[type=submit][value='Continue >>']"); - this.click("form#ThankYou input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form#ThankYou input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - - /* - * Step 5: Tell - */ - - /* click Tell a Friend enabled? */ - casper.waitForSelector('#tf_is_active', function success() { - casper.echo('====================================='); - casper.echo('** Step 5: Tell. **'); - casper.echo('====================================='); - test.assertExists('#tf_is_active'); - this.click('#tf_is_active'); - }, function fail() { - test.assertExists('#tf_is_active'); - }); - - casper.then(function() { - // this.capture('5_Tell.png'); - }); - - /* click submit */ - casper.waitForSelector("form#Contribute input[type=submit][value='Continue >>']", function success() { - test.assertExists("form#Contribute input[type=submit][value='Continue >>']"); - this.click("form#Contribute input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form#Contribute input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - - /* - * Step 6: Include - */ - - /* select Include Profile(top of page) */ - casper.waitForSelector("#custom_pre_id", function success() { - casper.echo('====================================='); - casper.echo('** Step 6: Include. **'); - casper.echo('====================================='); - test.assertExists("#custom_pre_id"); - this.evaluate(function () { - document.querySelector("#custom_pre_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#custom_pre_id"); - }); - - /* select Include Profile(bottom of page)*/ - casper.waitForSelector("#custom_post_id", function success() { - test.assertExists("#custom_post_id"); - this.evaluate(function () { - document.querySelector("#custom_post_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#custom_post_id"); - }); - - casper.then(function() { - // this.capture('6_Include.png'); - }); - - /* click submit */ - casper.waitForSelector("form#Custom input[type=submit][value='Continue >>']", function success() { - test.assertExists("form#Custom input[type=submit][value='Continue >>']"); - this.click("form#Custom input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form#Custom input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - - /* - * Step 7: Premimums - */ - - /* click Premiums Section Enabled? */ - casper.waitForSelector('#premiums_active', function success() { - casper.echo('====================================='); - casper.echo('** Step 7: Premimums. **'); - casper.echo('====================================='); - test.assertExists('#premiums_active'); - this.click('#premiums_active'); - }, function fail() { - test.assertExists('#premiums_active'); - }); - - /* sendKeys to Title */ - casper.waitForSelector("#premiums_intro_title", function success() { - test.assertExists("#premiums_intro_title"); - this.sendKeys("#premiums_intro_title", makeid(10)); - }, function fail() { - test.assertExists("#premiums_intro_title"); - }); - - casper.then(function() { - // this.capture('7_Premimums.png'); - }); - - /* click submit */ - casper.waitForSelector("form#Premium input[type=submit][value='Continue >>']", function success() { - test.assertExists("form#Premium input[type=submit][value='Continue >>']"); - this.click("form#Premium input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form#Premium input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - - /* - * Step 8: Widget - */ - - /* click Enable Widget? */ - casper.waitForSelector('#is_active', function success() { - casper.echo('====================================='); - casper.echo('** Step 8: Widget. **'); - casper.echo('====================================='); - test.assertExists('#is_active'); - // refs #34197, ckeditor not support old phantomjs - // this.click('#is_active'); - }, function fail() { - test.assertExists('#is_active'); - }); - - /* filled up About(ckeditor) */ - /* refs #34197, ckeditor not support old phantomjs - casper.waitForSelector("iframe.cke_wysiwyg_frame", function success() { - test.assertExists("iframe.cke_wysiwyg_frame"); - this.evaluate(function() { - document.querySelector('iframe.cke_wysiwyg_frame').contentWindow.document.querySelector("p").textContent = 'widget test'; - }); - }, function fail() { - test.assertExists("iframe.cke_wysiwyg_frame"); - }); - */ - - /* click Save and Preview */ - casper.waitForSelector('#_qf_Widget_refresh', function success() { - test.assertExists('#_qf_Widget_refresh'); - this.click('#_qf_Widget_refresh'); - }, function fail() { - test.assertExists('#_qf_Widget_refresh'); - }); - - casper.wait(2000); - - /* check if widget iframe exist */ - casper.waitForSelector('iframe.crm-container-embed', function success() { - test.assertExists('iframe.crm-container-embed'); - }, function fail() { - test.assertExists('iframe.crm-container-embed'); - }); - - casper.then(function() { - // this.capture('8_Widget.png'); - }); - - /* click submit */ - casper.waitForSelector("form#Widget input[type=submit][value='Continue >>']", function success() { - test.assertExists("form#Widget input[type=submit][value='Continue >>']"); - this.click("form#Widget input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form#Widget input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - - /* - * Step 9: Enable - */ - - /* click Enable Personal Campaign Pages (for this contribution page)? */ - casper.waitForSelector('#is_active', function success() { - casper.echo('====================================='); - casper.echo('** Step 9: Enable. **'); - casper.echo('====================================='); - test.assertExists('#is_active'); - this.click('#is_active'); - }, function fail() { - test.assertExists('#is_active'); - }); - - /* sendKeys to Notify Email */ - casper.waitForSelector("#notify_email", function success() { - test.assertExists("#notify_email"); - this.sendKeys("#notify_email", makeid(5) + "@fakemail.com"); - }, function fail() { - test.assertExists("#notify_email"); - }); - - casper.then(function() { - // this.capture('9_Enable.png'); - }); - - /* click submit */ - casper.waitForSelector("form#PCP input[type=submit][value='Continue >>']", function success() { - test.assertExists("form#PCP input[type=submit][value='Continue >>']"); - this.click("form#PCP input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form#PCP input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - - casper.run(function() { - test.done(); - }); -}); \ No newline at end of file diff --git a/tests/casperjs/add_event.test.js b/tests/casperjs/add_event.test.js deleted file mode 100644 index eda587d1e..000000000 --- a/tests/casperjs/add_event.test.js +++ /dev/null @@ -1,296 +0,0 @@ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var vars = { - baseURL: port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/' -}; - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Start testing...', function(test) { - /* open add event */ - casper.thenOpen(vars.baseURL + "civicrm/event/add?reset=1&action=add", function() { - // this.capture('1_add_event.png'); - }); - - /* - * Info and Settings - */ - - /* filled up add event form */ - casper.waitForSelector('form#EventInfo', function success() { - casper.echo('====================================='); - casper.echo('** Step 1: Info and Settings. **'); - casper.echo('====================================='); - test.assertExists('form#EventInfo'); - this.fill('form#EventInfo', { - 'event_type_id': '1', - 'title': makeid(5) - }, true); - }, function fail() { - test.assertExists('form#EventInfo'); - }); - casper.wait(2000); - casper.then(function() { - // this.capture('2_edit_event.png') - }); - - /* - * Event Location - */ - - /* select State/Province */ - casper.waitForSelector("#address_1_state_province_id", function success() { - casper.echo('====================================='); - casper.echo('** Step 2: Event Location. **'); - casper.echo('====================================='); - test.assertExists("#address_1_state_province_id"); - this.evaluate(function () { - document.querySelector("#address_1_state_province_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#address_1_state_province_id"); - }); - - /* click Save */ - casper.waitForSelector("form#Location input[type=submit][value='Save']", function success() { - test.assertExists("form#Location input[type=submit][value='Save']"); - this.click("form#Location input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form#Location input[type=submit][value='Save']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('3_location_save.png'); - }); - - /* - * Fees - */ - - /* click fees */ - casper.waitForSelector('li#tab_fee a', function success() { - casper.echo('====================================='); - casper.echo('** Step 3: Fees. **'); - casper.echo('====================================='); - test.assertExists('li#tab_fee a'); - this.click('li#tab_fee a'); - }, function fail() { - test.assertExists('li#tab_fee a'); - }); - casper.wait(2000); - - /* click Paid Event Yes */ - casper.waitForSelector('#CIVICRM_QFID_1_2', function success() { - test.assertExists('#CIVICRM_QFID_1_2'); - this.click('#CIVICRM_QFID_1_2'); - }, function fail() { - test.assertExists('#CIVICRM_QFID_1_2'); - }); - - /* select Contribution Type */ - casper.waitForSelector("#contribution_type_id", function success() { - test.assertExists("#contribution_type_id"); - this.evaluate(function () { - document.querySelector("#contribution_type_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#contribution_type_id"); - }); - - /* click pay later */ - casper.waitForSelector('#is_pay_later', function success() { - test.assertExists('#is_pay_later'); - this.click('#is_pay_later'); - }, function fail() { - test.assertExists('#is_pay_later'); - }); - - /* filled up Pay Later Instructions */ - casper.waitForSelector("#pay_later_receipt", function success() { - test.assertExists("#pay_later_receipt"); - this.sendKeys("#pay_later_receipt", "I will send payment by check"); - }, function fail() { - test.assertExists("#pay_later_receipt"); - }); - - /* Event Level */ - /* level 1 */ - casper.waitForSelector("#label_1", function success() { - test.assertExists("#label_1"); - this.sendKeys("#label_1", "aaa"); - }, function fail() { - test.assertExists("#label_1"); - }); - casper.waitForSelector("#value_1", function success() { - test.assertExists("#value_1"); - this.sendKeys("#value_1", "111"); - }, function fail() { - test.assertExists("#value_1"); - }); - - /* level 2 */ - casper.waitForSelector("#label_2", function success() { - test.assertExists("#label_2"); - this.sendKeys("#label_2", "bbb"); - }, function fail() { - test.assertExists("#label_2"); - }); - casper.waitForSelector("#value_2", function success() { - test.assertExists("#value_2"); - this.sendKeys("#value_2", "222"); - }, function fail() { - test.assertExists("#value_2"); - }); - - /* click Save */ - casper.waitForSelector("form#Fee input[type=submit][value='Save']", function success() { - test.assertExists("form#Fee input[type=submit][value='Save']"); - this.click("form#Fee input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form#Fee input[type=submit][value='Save']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('4_fees_save.png'); - }); - - /* - * Online Registration - */ - - /* click Online Registration */ - casper.waitForSelector('li#tab_registration a', function success() { - casper.echo('====================================='); - casper.echo('** Step 4: Online Registration. **'); - casper.echo('====================================='); - test.assertExists('li#tab_registration a'); - this.click('li#tab_registration a'); - }, function fail() { - test.assertExists('li#tab_registration a'); - }); - casper.wait(2000); - - /* click Allow Online Registration? */ - casper.waitForSelector('#is_online_registration', function success() { - test.assertExists('#is_online_registration'); - this.click('#is_online_registration'); - }, function fail() { - test.assertExists('#is_online_registration'); - }); - - /* click Confirmation Email accordion */ - casper.waitForSelector('div.crm-accordion-wrapper:nth-child(6) div.crm-accordion-header', function success() { - test.assertExists('div.crm-accordion-wrapper:nth-child(6) div.crm-accordion-header'); - this.click('div.crm-accordion-wrapper:nth-child(6) div.crm-accordion-header'); - }, function fail() { - test.assertExists('div.crm-accordion-wrapper:nth-child(6) div.crm-accordion-header'); - }); - - /* click Send Confirmation Email? */ - casper.waitForSelector('#CIVICRM_QFID_1_2', function success() { - test.assertExists('#CIVICRM_QFID_1_2'); - this.click('#CIVICRM_QFID_1_2'); - }, function fail() { - test.assertExists('#CIVICRM_QFID_1_2'); - }); - - /* filled up Confirm From Name */ - casper.waitForSelector("#confirm_from_name", function success() { - test.assertExists("#confirm_from_name"); - this.sendKeys("#confirm_from_name", "Name For Confirm"); - }, function fail() { - test.assertExists("#confirm_from_name"); - }); - - /* filled up Confirm From Email */ - casper.waitForSelector("#confirm_from_email", function success() { - test.assertExists("#confirm_from_email"); - this.sendKeys("#confirm_from_email", "confirm@fakemail.com"); - }, function fail() { - test.assertExists("#confirm_from_email"); - }); - - /* click Save */ - casper.waitForSelector("form#Registration input[type=submit][value='Save']", function success() { - test.assertExists("form#Registration input[type=submit][value='Save']"); - this.click("form#Registration input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form#Registration input[type=submit][value='Save']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('5_online_reg_save.png'); - }); - - /* - * Tell a Friend - */ - - /* click Tell a Friend */ - casper.waitForSelector('li#tab_friend a', function success() { - casper.echo('====================================='); - casper.echo('** Step 5: Tell a Friend. **'); - casper.echo('====================================='); - test.assertExists('li#tab_friend a'); - this.click('li#tab_friend a'); - }, function fail() { - test.assertExists('li#tab_friend a'); - }); - casper.wait(2000); - - /* click Allow Online Registration? */ - casper.waitForSelector('#tf_is_active', function success() { - test.assertExists('#tf_is_active'); - this.click('#tf_is_active'); - }, function fail() { - test.assertExists('#tf_is_active'); - }); - - /* click Save */ - casper.waitForSelector("form#Event input[type=submit][value='Save']", function success() { - test.assertExists("form#Event input[type=submit][value='Save']"); - this.click("form#Event input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form#Event input[type=submit][value='Save']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('6_friend_save.png'); - }); - - - casper.run(function() { - test.done(); - }); -}); \ No newline at end of file diff --git a/tests/casperjs/add_group.test.js b/tests/casperjs/add_group.test.js deleted file mode 100644 index 08991335f..000000000 --- a/tests/casperjs/add_group.test.js +++ /dev/null @@ -1,362 +0,0 @@ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var vars = { - baseURL : port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - group_name: makeid(5), - group_id: "", - mail_name: makeid(5) -}; - -casper.on('remote.message', function(msg) { - this.echo('remote message caught: ' + msg); -}); - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Start testing...', function(test) { - - /* open new group */ - casper.thenOpen(vars.baseURL + "civicrm/group/add?reset=1", function() { - // this.capture('new_group.png'); - }); - - casper.wait(2000); - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 1: Add New Group. **'); - casper.echo('====================================='); - }); - - /* sendKeys to Name */ - casper.waitForSelector("#title", function success() { - test.assertExists("#title"); - this.sendKeys("#title", vars.group_name); - }, function fail() { - test.assertExists("#title"); - }); - - /* click Mailing List */ - casper.waitForSelector('input[name="group_type[2]"]', function success() { - test.assertExists('input[name="group_type[2]"]'); - this.click('input[name="group_type[2]"]'); - }, function fail() { - test.assertExists('input[name="group_type[2]"]'); - }); - - /* click Continue */ - casper.waitForSelector('input[value="Continue"]', function success() { - test.assertExists('input[value="Continue"]'); - this.click('input[value="Continue"]'); - }, function fail() { - test.assertExists('input[value="Continue"]'); - }); - - casper.wait(2000); - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 2: Add User to Group. **'); - casper.echo('====================================='); - }); - - /* click Search */ - casper.waitForSelector('form#Basic input[value="Search"]', function success() { - test.assertExists('form#Basic input[value="Search"]'); - this.click('form#Basic input[value="Search"]'); - }, function fail() { - test.assertExists('form#Basic input[value="Search"]'); - }); - - casper.wait(2000); - - /* select user that have email */ - casper.waitForSelector('.selector', function success() { - this.echo('Select user that have email') - var id = this.evaluate(function (){ - var tr = document.querySelectorAll(".selector tr"); - for(var i=1; i>' button exist."); - }); - casper.wait(2000); - - casper.then(function() { - test.assertDoesntExist('.crm-error', "Assert '.crm-error' doesn't exist."); - }); - - casper.then(function() { - this.echo('Step 4-3: Track and Respond.'); - }); - - casper.waitForSelector(".messages strong", function success() { - var group_num = this.evaluate(function () { - return document.querySelector('.messages strong').textContent; - }); - test.assertEquals(group_num, "1", 'Assert recipient number of group correct.') - }, function fail() { - test.assertExists(".messages strong", "Assert number of 'Total Recipients' exist."); - }); - - casper.waitForSelector("select#visibility", function success() { - this.evaluate(function() { - document.querySelector('select#visibility').selectedIndex = 1; - }); - }, function fail() { - test.assertExists("select#visibility", "Visibility select field exist"); - }); - - casper.waitForSelector("input[value='Next >>']", function success() { - this.click("input[value='Next >>']"); - }, function fail() { - test.assertExists("input[value='Next >>']", "Assert 'Next >>' button exist."); - }); - casper.wait(2000); - - casper.then(function() { - test.assertDoesntExist('.crm-error', "Assert '.crm-error' doesn't exist."); - }); - - casper.then(function() { - this.echo('Step 4-4: Mailing Content.'); - }); - - casper.waitForSelector("input[name='subject']", function success() { - this.evaluate(function(subject) { - document.querySelector("input[name='subject']").value = subject; - }, makeid(5)); - }, function fail() { - test.assertExists("input[name='subject']", "Assert 'Mailing Subject' exist."); - }); - - casper.waitForSelector("#footer_id", function success() { - this.evaluate(function () { - document.getElementById('footer_id').selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#footer_id", "Assert 'Mailing footer' exist."); - }); - - - casper.waitForSelector("input[value='Next >>']", function success() { - this.click("input[value='Next >>']"); - }, function fail() { - test.assertExists("input[value='Next >>']", "Assert 'Next >>' button exist."); - }); - casper.wait(2000); - - casper.then(function() { - test.assertDoesntExist('.crm-error', "Assert '.crm-error' doesn't exist."); - }); - - casper.then(function() { - this.echo("Step 4-5: Test."); - }); - - casper.waitForSelector("input[value='Next >>']", function success() { - this.click("input[value='Next >>']"); - }, function fail() { - test.assertExists("input[value='Next >>']", "Assert 'Next >>' button exist."); - }); - casper.wait(2000); - - casper.then(function() { - this.echo('Step 4-6: Schedule or Send'); - }); - - casper.waitForSelector("input[value='Submit Mailing']", function success() { - this.click("input[value='Submit Mailing']"); - }, function fail() { - test.assertExists("input[value='Submit Mailing']", "Assert 'Submit Mailing' button exist."); - }); - casper.wait(2000); - casper.then(function() { - // this.capture("click_send.png"); - }); - casper.then(function() { - test.assertDoesntExist('.crm-error', "Assert '.crm-error' doesn't exist."); - }); - - casper.then(function() { - this.echo("Step 4-7: Check if mail in 'Scheduled and Sent Mailings'."); - }); - - casper.thenOpen(vars.baseURL + "civicrm/mailing/browse/scheduled?reset=1&scheduled=true", function() { - // this.capture("scheduled_and_sent_mailings.png"); - }); - - casper.waitForSelector(".selector tbody tr td:nth-child(2)", function success() { - var mail_name_from_page = this.evaluate(function () { - return document.querySelector('.selector tbody tr td:nth-child(2)').textContent; - }); - test.assertEquals(mail_name_from_page, vars.mail_name, "Assert mail name correct."); - }, function fail() { - test.assertExists(".selector tbody tr td:nth-child(2)", "Assert 'Mailing Name' exist."); - }); - - casper.run(function() { - test.done(); - }); -}); diff --git a/tests/casperjs/add_profile.test.js b/tests/casperjs/add_profile.test.js deleted file mode 100644 index c694ac521..000000000 --- a/tests/casperjs/add_profile.test.js +++ /dev/null @@ -1,970 +0,0 @@ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var vars = { - baseURL : port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - profile_id: '-1', - profile_url: '', - first_name: makeid(5), - last_name: makeid(5), - legal_identifier: makeid(5), - current_employer: makeid(5), - phone: makeid(5), - city: makeid(5), - postal_code: makeid(5), - street_address: makeid(5), - email: makeid(5) + '@test.com', - note: makeid(5) -}; -vars.email = vars.email.toLowerCase(); - -casper.on('remote.message', function(msg) { - this.echo('remote message caught: ' + msg); -}); - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Start testing...', function(test) { - - casper.thenOpen(vars.baseURL + "civicrm/admin/uf/group?reset=1", function() { - }); - - casper.waitForSelector("#newCiviCRMProfile-top", function success() { - this.click("#newCiviCRMProfile-top"); - }, function fail() { - test.assertExists("#newCiviCRMProfile-top", "Assert 'Add Profile' button exist."); - }); - - casper.wait(2000); - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 1: New Profile. **'); - casper.echo('====================================='); - }); - - var profile_name = makeid(5); - casper.waitForSelector("input[name='title']", function success() { - this.sendKeys("input[name='title']", profile_name); - }, function fail() { - test.assertExists("input[name='title']", "Assert 'Profile Name' field exist."); - }); - - casper.waitForSelector("input[name='uf_group_type_user[User Registration]']", function success() { - this.click("input[name='uf_group_type_user[User Registration]']"); - }, function fail() { - test.assertExists("input[name='uf_group_type_user[User Registration]']", "Assert 'Drupal User Registration' exist."); - }); - - casper.waitForSelector("input[name='uf_group_type_user[User Account]']", function success() { - this.click("input[name='uf_group_type_user[User Account]']"); - }, function fail() { - test.assertExists("input[name='uf_group_type_user[User Account]']", "Assert 'View/Edit Drupal User Account' exist."); - }); - - casper.waitForSelector("input[value='Save']", function success() { - this.click("input[value='Save']"); - }, function fail() { - test.assertExists("input[value='Save']", "Assert 'Save' button exist."); - }); - - casper.wait(2000); - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 2: Add Fields. **'); - casper.echo('====================================='); - }); - - casper.then(function() { - casper.echo("Step 2-1: Add individual: Fist Name."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Individual"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "first_name"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert individual options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "First Name"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-2: Add individual: Last Name."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Individual"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "last_name"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert individual options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Last Name"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-3: Add individual: Legal Identifier."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Individual"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "legal_identifier"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert individual options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Legal Identifier"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-4: Add individual: Current Employer."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Individual"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "current_employer"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert individual options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Current Employer"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-5: Add Contact info: Phone."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Contact"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "phone"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert contact info options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Phone"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-6: Add Contact info: State."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Contact"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "state_province"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert contact info options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "State"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-7: Add Contact info: City."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Contact"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "city"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert contact info options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "City"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-8: Add Contact info: Postal Code."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Contact"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "postal_code"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert contact info options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Postal Code"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-9: Add Contact info: Street Address."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Contact"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "street_address"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert contact info options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Street Address"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-10: Add Contact info: Email."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Contact"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "email"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert contact info options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Email"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-11: Add Contact info: Do Not Email."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Contact"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "do_not_email"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert contact info options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Do Not Email"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-12: Add Contact info: Image Url."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Contact"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "image_URL"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert contact info options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Image Url"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - casper.echo("Step 2-13: Add Contact info: Note(s)."); - }); - - casper.waitForSelector("select[name='field_name[0]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[0]"]').value = "Contact"; - var s = document.querySelector('select[name="field_name[0]"]'); - swapOptions(s.form, 'field_name', 0, 4, 'hs_field_name'); - }); - }, function fail() { - test.assertExists("select[name='field_name[0]']", "Assert 'Please select a field name' exist."); - }); - - casper.waitForSelector("select[name='field_name[1]']", function success() { - this.evaluate(function () { - document.querySelector('select[name="field_name[1]"]').value = "note"; - }); - }, function fail() { - test.assertExists("select[name='field_name[1]']", "Assert contact info options exist."); - }); - - casper.waitForSelector("input[name='label']", function success() { - this.sendKeys("input[name='label']", "Note(s)"); - }, function fail() { - test.assertExists("input[name='label']", "Assert 'Field Label' field exist."); - }); - - casper.waitForSelector("input[value='Save and New']", function success() { - this.click("input[value='Save and New']"); - }, function fail() { - test.assertExists("input[value='Save and New']", "Assert 'Save and New' button exist."); - }); - - casper.wait(1000); - - casper.then(function() { - // this.capture("add_fields_done.png"); - }); - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 3: Check All Fields Exists. **'); - casper.echo('====================================='); - }); - - casper.thenOpen(vars.baseURL + "civicrm/admin/uf/group?reset=1", function() { - }); - - casper.waitForSelector("#user-profiles table", function success() { - vars.profile_id = this.evaluate(function (profile_name) { - var tr_list = document.querySelectorAll("#user-profiles table tr"); - for(var i=1; i> ' button exist."); - }); - - casper.wait(2000); - - casper.then(function() { - test.assertDoesntExist('.error-ci', 'page has no error'); - }); - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 7: Check If Data of New Contact Correct. **'); - casper.echo('====================================='); - }); - - casper.then(function() { - casper.echo("Step 7-1: Search for new contact."); - }); - - casper.thenOpen(vars.baseURL + "civicrm/contact/search?reset=1", function() { - }); - - casper.waitForSelector("#sort_name", function success() { - this.sendKeys("#sort_name", vars.first_name + " " + vars.last_name); - }, function fail() { - test.assertExists("#sort_name", "'Name, Phone or Email' field exist."); - }); - - casper.waitForSelector("#_qf_Basic_refresh", function success() { - this.click("#_qf_Basic_refresh"); - }, function fail() { - test.assertExists("#_qf_Basic_refresh", "'Search' button exist."); - }); - - casper.wait(2000); - - casper.then(function() { - casper.echo("Step 7-2: Go to new contact page, check all data correct."); - }); - - casper.waitForSelector("table.selector tbody tr td.crm-search-display_name a", function success() { - this.click("table.selector tbody tr td.crm-search-display_name a"); - }, function fail() { - test.assertExists("table.selector tbody tr td.crm-search-display_name a", "New contact exist."); - }); - - casper.wait(2000); - - casper.waitForSelector("#page-title", function success() { - var name = this.evaluate(function () { - return document.getElementById('page-title').textContent.trim(); - }); - test.assertEquals(name, vars.first_name + ' ' + vars.last_name, 'First Name and Last Name correct.'); - }, function fail() { - test.assertExists("#page-title", "Contact name exist."); - }); - - casper.waitForSelector("#record-log div", function success() { - var legal_identifier_from_page = this.evaluate(function () { - var s = document.querySelector('#record-log div').textContent.trim(); - return s.slice(21 + 'Legal Identifier:'.length + 1); - }); - test.assertEquals(legal_identifier_from_page, vars.legal_identifier, 'Legal Identifier correct.') - }, function fail() { - test.assertExists("#record-log div", "Legal Identifier exist."); - }); - - casper.waitForSelector("a[title='view current employer']", function success() { - var current_employer_from_page = this.evaluate(function () { - return document.querySelector("a[title='view current employer']").textContent; - }); - test.assertEquals(current_employer_from_page, vars.current_employer, 'Current Employer correct.'); - }, function fail() { - test.assertExists("a[title='view current employer']", "Employer exist."); - }); - - casper.waitForSelector("td.primary span", function success() { - var phone_from_page = this.evaluate(function () { - return document.querySelector('td.primary span').textContent; - }); - test.assertEquals(phone_from_page, vars.phone, 'Phone correct.') - }, function fail() { - test.assertExists("td.primary span", "Phone exist."); - }); - - casper.waitForSelector("span.region", function success() { - var state_from_page = this.evaluate(function () { - return document.querySelector("span.region").textContent; - }); - test.assertEquals(state_from_page, 'AL', 'State correct.') - }, function fail() { - test.assertExists("span.region", "State exist."); - }); - - casper.waitForSelector("span.locality", function success() { - var city_from_page = this.evaluate(function () { - return document.querySelector("span.locality").textContent; - }); - test.assertEquals(city_from_page, vars.city, 'City correct.') - }, function fail() { - test.assertExists("span.locality", "City exist."); - }); - - casper.waitForSelector("span.postal-code", function success() { - var postal_code_from_page = this.evaluate(function () { - return document.querySelector("span.postal-code").textContent; - }); - test.assertEquals(postal_code_from_page, vars.postal_code, 'Postal Code correct.') - }, function fail() { - test.assertExists("span.postal-code", "Postal Code exist."); - }); - - casper.waitForSelector("span.street-address", function success() { - var street_address_from_page = this.evaluate(function () { - return document.querySelector("span.street-address").textContent; - }); - test.assertEquals(street_address_from_page, vars.street_address, 'Street Address correct.') - }, function fail() { - test.assertExists("span.street-address", "Street Address exist."); - }); - - casper.waitForSelector("span.do-not-email", function success() { - var email_from_page = this.evaluate(function () { - return document.querySelector('span.do-not-email a').textContent; - }); - test.assertEquals(email_from_page, vars.email, 'Email correct.'); - test.pass('Do Not Email correct.'); - }, function fail() { - test.assertExists("span.do-not-email", "Email exist."); - }); - - casper.waitForSelector("a[title='Notes']", function success() { - this.click("a[title='Notes']"); - }, function fail() { - test.assertExists("a[title='Notes']", "Notes link exist."); - }); - - casper.waitForSelector("#notes tr td:nth-child(2)", function success() { - var note_from_page = this.evaluate(function () { - return document.querySelector('#notes tr td:nth-child(2)').textContent; - }); - test.assertEquals(note_from_page, vars.note, 'Note(s) correct.') - }, function fail() { - test.assertExists("#notes tr td:nth-child(2)", "Note(s) exist."); - }); - - casper.run(function() { - test.done(); - }); -}); \ No newline at end of file diff --git a/tests/casperjs/advanced_search.test.js b/tests/casperjs/advanced_search.test.js deleted file mode 100644 index 6e62ef732..000000000 --- a/tests/casperjs/advanced_search.test.js +++ /dev/null @@ -1,191 +0,0 @@ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var vars = { - baseURL : port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/' -}; - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Start testing...', function(test) { - - casper.thenOpen(vars.baseURL + "civicrm/contact/search/advanced?reset=1", function() { - }); - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 1: Fill Up Search Criteria. **'); - casper.echo('====================================='); - }); - - casper.then(function() { - casper.echo("Step 1-1: Fill up 'Contact Information'."); - }); - - casper.waitForSelector("#group", function success() { - this.evaluate(function () { - document.getElementById("group").selectedIndex = 2; - }); - }, function fail() { - test.assertExists("#group", "Assert 'Group(s)' field does not exist."); - }); - - casper.waitForSelector("#contact_tags", function success() { - this.evaluate(function () { - document.getElementById("contact_tags").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#contact_tags", "Assert 'Select Tag(s)' field does not exist."); - }); - - casper.then(function() { - casper.echo("Step 1-2: Fill up 'Address Fields'."); - }); - - casper.waitForSelector("#location", function success() { - this.click("#location"); - }, function fail() { - test.assertExists("#location", "Assert 'Address Fields' exist."); - }); - - casper.wait(2000); - - casper.waitForSelector("#state_province", function success() { - test.assertExists('#state_province'); - this.evaluate(function () { - document.querySelector("#state_province").selectedIndex = 1; - }); - }, function fail() { - test.assertExists('#state_province', "Assert first option of 'State / Province dropdown list' does not exist."); - }); - - casper.then(function() { - casper.echo("Step 1-3: Fill up 'Notes'."); - }); - - casper.waitForSelector("#notes", function success() { - this.click("#notes"); - }, function fail() { - test.assertExists("#notes", "Assert 'Notes' exist"); - }); - - casper.wait(2000); - - casper.waitForSelector("input[name='note']", function success() { - this.sendKeys("input[name='note']", makeid(5)); - }, function fail() { - test.assertExists("input[name='note']", "Assert 'Note Text' field exist."); - }); - - casper.then(function() { - casper.echo("Step 1-4: Fill up 'Contribute'."); - }); - - casper.waitForSelector("#CiviContribute", function success() { - this.click("#CiviContribute"); - }, function fail() { - test.assertExists("#CiviContribute", "Assert 'Contributions' exist."); - }); - - casper.wait(2000); - - casper.waitForSelector("#contribution_source", function success() { - this.sendKeys("#contribution_source", makeid(5)); - }, function fail() { - test.assertExists("#contribution_source", "Assert 'Contribution Source' field exist."); - }); - - casper.then(function() { - casper.echo("Step 1-5: Fill up 'Memberships'."); - }); - - casper.waitForSelector("#CiviMember", function success() { - this.click("#CiviMember"); - }, function fail() { - test.assertExists("#CiviMember", "Assert 'Memberships' exist."); - }); - - casper.wait(2000); - - casper.waitForSelector("#member_source", function success() { - this.sendKeys("#member_source", makeid(5)); - }, function fail() { - test.assertExists("#member_source", "Assert 'Source' field exist."); - }); - - casper.then(function() { - casper.echo("Step 1-6: Fill up 'Events'."); - }); - - casper.waitForSelector("#CiviEvent", function success() { - this.click("#CiviEvent"); - }, function fail() { - test.assertExists("#CiviEvent", "Assert 'Events' exist."); - }); - - casper.wait(2000); - - casper.waitForSelector("#event_id", function success() { - this.sendKeys("#event_id", 1); - }, function fail() { - test.assertExists("#event_id", "Assert 'Event Name' field exist."); - }); - - casper.then(function() { - // this.capture("filled_up_all.png"); - }); - - casper.then(function() { - casper.echo("Step 1-7: Apply search."); - }); - - casper.waitForSelector("input[name='_qf_Advanced_refresh']", function success() { - this.click("input[name='_qf_Advanced_refresh']"); - }, function fail() { - test.assertExists("input[name='_qf_Advanced_refresh']", "Assert 'Search' button exist."); - }); - - casper.wait(2000); - - casper.then(function() { - test.assertDoesntExist('.error-ci', "Assert no error."); - }); - - casper.then(function() { - // this.capture("search_result.png"); - }); - - casper.run(function() { - test.done(); - }); -}); \ No newline at end of file diff --git a/tests/casperjs/batch_action.test.js b/tests/casperjs/batch_action.test.js deleted file mode 100644 index 75f371b71..000000000 --- a/tests/casperjs/batch_action.test.js +++ /dev/null @@ -1,886 +0,0 @@ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var vars = { - baseURL : port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - organization_name: makeid(5) -}; - -function list_contacts_and_select_three(test) { - /* find contacts */ - casper.thenOpen(vars.baseURL + "civicrm/contact/search?reset=1", function() { - // his.capture('find_contacts.png'); - }); - casper.waitForSelector('#contact_type', function success() { - test.assertExists('#contact_type'); - this.evaluate(function () { - document.querySelector("#contact_type").selectedIndex = 1; - }); - }, function fail() { - test.assertExists('#contact_type'); - }); - casper.then(function() { - // this.capture('click_individual.png'); - }); - casper.waitForSelector('#_qf_Basic_refresh', function success() { - test.assertExists('#_qf_Basic_refresh'); - this.click('#_qf_Basic_refresh'); - }, function fail() { - test.assertExists('#_qf_Basic_refresh"]'); - }); - - /* all contacts */ - casper.wait(2000); - casper.then(function() { - // this.capture('all_contacts.png'); - }); - - /* check top 3 checkbox */ - casper.waitForSelector('table.selector tr:nth-child(1) td:nth-child(1) input', function success() { - test.assertExists('table.selector tr:nth-child(1) td:nth-child(1) input'); - this.click('table.selector tr:nth-child(1) td:nth-child(1) input'); - }, function fail() { - test.assertExists('table.selector tr:nth-child(1) td:nth-child(1) input'); - }); - casper.waitForSelector('table.selector tr:nth-child(2) td:nth-child(1) input', function success() { - test.assertExists('table.selector tr:nth-child(2) td:nth-child(1) input'); - this.click('table.selector tr:nth-child(2) td:nth-child(1) input'); - }, function fail() { - test.assertExists('table.selector tr:nth-child(2) td:nth-child(1) input'); - }); - casper.waitForSelector('table.selector tr:nth-child(3) td:nth-child(1) input', function success() { - test.assertExists('table.selector tr:nth-child(3) td:nth-child(1) input'); - this.click('table.selector tr:nth-child(3) td:nth-child(1) input'); - }, function fail() { - test.assertExists('table.selector tr:nth-child(3) td:nth-child(1) input'); - }); - casper.then(function() { - // this.capture('check_3.png'); - }); -} - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); - - - /* - * Add to organization - */ -casper.test.begin('Start testing...', function(test){ - /* add organization */ - casper.thenOpen(vars.baseURL + "civicrm/contact/add?reset=1&ct=Organization", function() { - casper.echo('====================================='); - casper.echo('** Step 1: Add to Organization. **'); - casper.echo('====================================='); - // this.capture('add_organization.png'); - }); - casper.waitForSelector("form[name=Contact] input[name='organization_name']", function success() { - test.assertExists("form[name=Contact] input[name='organization_name']"); - this.click("form[name=Contact] input[name='organization_name']"); - }, function fail() { - test.assertExists("form[name=Contact] input[name='organization_name']"); - }); - casper.waitForSelector("input[name='organization_name']", function success() { - this.sendKeys("input[name='organization_name']", vars.organization_name); - }, function fail() { - test.assertExists("input[name='organization_name']"); - }); - casper.then(function() { - // this.capture('form_write_done.png'); - }); - casper.waitForSelector("form[name=Contact] input[type=submit][value='Save']", function success() { - test.assertExists("form[name=Contact] input[type=submit][value='Save']"); - this.click("form[name=Contact] input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form[name=Contact] input[type=submit][value='Save']"); - }); /* submit form */ - - /* organization page */ - casper.wait(2000); - casper.then(function() { - // this.capture('organization_info.png'); - }) - casper.then(function() { - test.assertTitle(vars.organization_name + ' | netiCRM'); - }); - - list_contacts_and_select_three(test); - - /* select contact to 組織 */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 6; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.then(function() { - // this.capture('select_add_to_organization.png'); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('add_to_organization.png'); - }); - - /* filled up add to organization form */ - casper.waitForSelector("#relationship_type_id", function success() { - test.assertExists("#relationship_type_id"); - this.evaluate(function () { - document.querySelector("#relationship_type_id").selectedIndex = 2; - }); - }, function fail() { - test.assertExists("#relationship_type_id"); - }); - casper.waitForSelector("#name", function() { - test.assertExists("#name"); - this.sendKeys("#name", vars.organization_name); - }, function fail() { - test.assertExists("#name"); - }); - casper.waitForSelector("form[name=AddToOrganization] input[type=submit][value='Search']", function success() { - test.assertExists("form[name=AddToOrganization] input[type=submit][value='Search']"); - this.click("form[name=AddToOrganization] input[type=submit][value='Search']"); - }, function fail() { - test.assertExists("form[name=AddToOrganization] input[type=submit][value='Search']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture("found_org.png"); - }); - - /* click add to organization */ - casper.waitForSelector("form[name=AddToOrganization] input[type=submit][value='Add to Organization']", function success() { - test.assertExists("form[name=AddToOrganization] input[type=submit][value='Add to Organization']"); - this.click("form[name=AddToOrganization] input[type=submit][value='Add to Organization']"); - }, function fail() { - test.assertExists("form[name=AddToOrganization] input[type=submit][value='Add to Organization']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture("add_to_org_success.png"); - }); - - /* - * Record Activity - */ - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 2: Record Activity. **'); - casper.echo('====================================='); - }); - - list_contacts_and_select_three(test); - - /* select Record Activity for Contacts */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 7; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.then(function() { - // this.capture('select_record_activity.png'); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('record_activity_form.png'); - }); - - /* select Activity Type */ - casper.waitForSelector("#activity_type_id", function success() { - test.assertExists("#activity_type_id"); - this.evaluate(function () { - document.querySelector("#activity_type_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#activity_type_id"); - }); - - /* click save */ - casper.waitForSelector("form[name=Activity] input[type=submit][value='Save']", function success() { - test.assertExists("form[name=Activity] input[type=submit][value='Save']"); - this.click("form[name=Activity] input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form[name=Activity] input[type=submit][value='Save']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture("record_activity_success.png"); - }); - - /* - * Batch Profile Update for Contact - */ - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 3: Batch Profile Update for Contact. **'); - casper.echo('====================================='); - }); - - list_contacts_and_select_three(test); - - /* select Batch Profile Update for Contact */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 8; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - - /* Select Profile */ - casper.waitForSelector("#uf_group_id", function success() { - test.assertExists("#uf_group_id"); - this.evaluate(function () { - document.querySelector("#uf_group_id").selectedIndex = 3; - }); - }, function fail() { - test.assertExists("#uf_group_id"); - }); - casper.waitForSelector("form[name=PickProfile] input[type=submit][value='Continue >>']", function success() { - test.assertExists("form[name=PickProfile] input[type=submit][value='Continue >>']"); - this.click("form[name=PickProfile] input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form[name=PickProfile] input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('batch_update.png'); - }); - - /* user1 */ - casper.waitForSelector("tr:nth-child(1) td:nth-child(2) input", function success() { - test.assertExists("tr:nth-child(1) td:nth-child(2) input"); - this.sendKeys("tr:nth-child(1) td:nth-child(2) input", makeid(3)); - }, function fail() { - test.assertExists("tr:nth-child(1) td:nth-child(2) input"); - }); - casper.waitForSelector("tr:nth-child(1) td:nth-child(3) input", function success() { - test.assertExists("tr:nth-child(1) td:nth-child(3) input"); - this.sendKeys("tr:nth-child(1) td:nth-child(3) input", makeid(3)); - }, function fail() { - test.assertExists("tr:nth-child(1) td:nth-child(3) input"); - }); - - /* user2 */ - casper.waitForSelector("tr:nth-child(2) td:nth-child(2) input", function success() { - test.assertExists("tr:nth-child(2) td:nth-child(2) input"); - this.sendKeys("tr:nth-child(2) td:nth-child(2) input", makeid(3)); - }, function fail() { - test.assertExists("tr:nth-child(2) td:nth-child(2) input"); - }); - casper.waitForSelector("tr:nth-child(2) td:nth-child(3) input", function success() { - test.assertExists("tr:nth-child(2) td:nth-child(3) input"); - this.sendKeys("tr:nth-child(2) td:nth-child(3) input", makeid(3)); - }, function fail() { - test.assertExists("tr:nth-child(2) td:nth-child(3) input"); - }); - - /* user3 */ - casper.waitForSelector("tr:nth-child(3) td:nth-child(2) input", function success() { - test.assertExists("tr:nth-child(3) td:nth-child(2) input"); - this.sendKeys("tr:nth-child(3) td:nth-child(2) input", makeid(3)); - }, function fail() { - test.assertExists("tr:nth-child(3) td:nth-child(2) input"); - }); - casper.waitForSelector("tr:nth-child(3) td:nth-child(3) input", function success() { - test.assertExists("tr:nth-child(3) td:nth-child(3) input"); - this.sendKeys("tr:nth-child(3) td:nth-child(3) input", makeid(3)); - }, function fail() { - test.assertExists("tr:nth-child(3) td:nth-child(3) input"); - }); - - casper.then(function() { - // this.capture('batch_form_done.png'); - }); - casper.waitForSelector("form[name=Batch] input[type=submit][value='Update Contacts']", function success() { - test.assertExists("form[name=Batch] input[type=submit][value='Update Contacts']"); - this.click("form[name=Batch] input[type=submit][value='Update Contacts']"); - }, function fail() { - test.assertExists("form[name=Batch] input[type=submit][value='Update Contacts']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('batch_update_success.png'); - }); - - /* - * Export Contacts - */ - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 4: Export Contacts. **'); - casper.echo('====================================='); - }); - - list_contacts_and_select_three(test); - - /* select Export Contacts */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 9; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - - /* click continue >> */ - casper.waitForSelector("form[name=Select] input[type=submit][value='Continue >>']", function success() { - test.assertExists("form[name=Select] input[type=submit][value='Continue >>']"); - this.click("form[name=Select] input[type=submit][value='Continue >>']"); - }, function fail() { - test.assertExists("form[name=Select] input[type=submit][value='Continue >>']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('continue.png'); - }); - /* select record type */ - casper.waitForSelector("form[name=Map] tr:nth-child(2) select", function success() { - test.assertExists("form[name=Map] tr:nth-child(2) select"); - this.evaluate(function () { - document.querySelector("form[name=Map] tr:nth-child(2) select").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("form[name=Map] tr:nth-child(2) select"); - }); - - /* click Export >> */ - casper.waitForSelector("form[name=Map] input[type=submit][value='Done']", function success() { - test.assertExists("form[name=Map] input[type=submit][value='Done']"); - this.click("form[name=Map] input[type=submit][value='Done']"); - }, function fail() { - test.assertExists("form[name=Map] input[type=submit][value='Done']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('export_done.png'); - }); - - /* - * Merge Contacts - 1 Merge - */ - - /* find contacts */ - casper.thenOpen(vars.baseURL + "civicrm/contact/search?reset=1", function() { - casper.echo('====================================='); - casper.echo('** Step 5-1: Merge Contacts - Merge. **'); - casper.echo('====================================='); - // this.capture('find_contacts.png'); - }); - casper.waitForSelector('#contact_type', function success() { - test.assertExists('#contact_type'); - this.evaluate(function () { - document.querySelector("#contact_type").selectedIndex = 1; - }); - }, function fail() { - test.assertExists('#contact_type'); - }); - casper.then(function() { - // this.capture('click_individual.png'); - }); - casper.waitForSelector('#_qf_Basic_refresh', function success() { - test.assertExists('#_qf_Basic_refresh'); - this.click('#_qf_Basic_refresh'); - }, function fail() { - test.assertExists('#_qf_Basic_refresh"]'); - }); - - /* all contacts */ - casper.wait(2000); - casper.then(function() { - // this.capture('all_contacts.png'); - }); - - /* check top 2 checkbox */ - casper.waitForSelector('table.selector tr:nth-child(1) td:nth-child(1) input', function success() { - test.assertExists('table.selector tr:nth-child(1) td:nth-child(1) input'); - this.click('table.selector tr:nth-child(1) td:nth-child(1) input'); - }, function fail() { - test.assertExists('table.selector tr:nth-child(1) td:nth-child(1) input'); - }); - casper.waitForSelector('table.selector tr:nth-child(2) td:nth-child(1) input', function success() { - test.assertExists('table.selector tr:nth-child(2) td:nth-child(1) input'); - this.click('table.selector tr:nth-child(2) td:nth-child(1) input'); - }, function fail() { - test.assertExists('table.selector tr:nth-child(2) td:nth-child(1) input'); - }); - - /* select Merge Contacts */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 10; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('merge_contacts.png'); - }); - - /* click Merge */ - casper.waitForSelector("form[name=Merge] input[type=submit][value='Merge']", function success() { - test.assertExists("form[name=Merge] input[type=submit][value='Merge']"); - this.click("form[name=Merge] input[type=submit][value='Merge']"); - }, function fail() { - test.assertExists("form[name=Merge] input[type=submit][value='Merge']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - - /* - * Merge Contacts - 2 Mark this pair as not a duplicate - */ - - /* find contacts */ - casper.thenOpen(vars.baseURL + "civicrm/contact/search?reset=1", function() { - casper.echo('====================================='); - casper.echo('** Step 5-2: Merge Contacts - Mark this pair as not a duplicate. **'); - casper.echo('====================================='); - // this.capture('find_contacts.png'); - }); - casper.waitForSelector('#contact_type', function success() { - test.assertExists('#contact_type'); - this.evaluate(function () { - document.querySelector("#contact_type").selectedIndex = 1; - }); - }, function fail() { - test.assertExists('#contact_type'); - }); - casper.then(function() { - // this.capture('click_individual.png'); - }); - casper.waitForSelector('#_qf_Basic_refresh', function success() { - test.assertExists('#_qf_Basic_refresh'); - this.click('#_qf_Basic_refresh'); - }, function fail() { - test.assertExists('#_qf_Basic_refresh"]'); - }); - - /* all contacts */ - casper.wait(2000); - casper.then(function() { - // this.capture('all_contacts.png'); - }); - - /* check top 2 checkbox */ - casper.waitForSelector('table.selector tr:nth-child(1) td:nth-child(1) input', function success() { - test.assertExists('table.selector tr:nth-child(1) td:nth-child(1) input'); - this.click('table.selector tr:nth-child(1) td:nth-child(1) input'); - }, function fail() { - test.assertExists('table.selector tr:nth-child(1) td:nth-child(1) input'); - }); - casper.waitForSelector('table.selector tr:nth-child(2) td:nth-child(1) input', function success() { - test.assertExists('table.selector tr:nth-child(2) td:nth-child(1) input'); - this.click('table.selector tr:nth-child(2) td:nth-child(1) input'); - }, function fail() { - test.assertExists('table.selector tr:nth-child(2) td:nth-child(1) input'); - }); - - /* select Merge Contacts */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 10; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - - /* click Mark this pair as not a duplicate. */ - casper.waitForSelector('#notDuplicate', function success() { - test.assertExists('#notDuplicate'); - this.click('#notDuplicate'); - }, function fail() { - test.assertExists('#notDuplicate'); - }); - - /* click something */ - casper.waitForSelector('div.ui-dialog-buttonset button:nth-child(2)', function success() { - test.assertExists('div.ui-dialog-buttonset button:nth-child(2)'); - this.click('div.ui-dialog-buttonset button:nth-child(2)'); - }, function fail() { - test.assertExists('div.ui-dialog-buttonset button:nth-child(2)'); - }); - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* - * Tag Contacts - */ - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 6: Tag Contacts. **'); - casper.echo('====================================='); - }); - - list_contacts_and_select_three(test); - - /* select Tag Contacts */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 11; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - - /* click something */ - casper.waitForSelector('tr.crm-contact-task-addtotag-form-block-tag div.listing-box div:first-child input', function success() { - test.assertExists('tr.crm-contact-task-addtotag-form-block-tag div.listing-box div:first-child input'); - this.click('tr.crm-contact-task-addtotag-form-block-tag div.listing-box div:first-child input'); - }, function fail() { - test.assertExists('tr.crm-contact-task-addtotag-form-block-tag div.listing-box div:first-child input'); - }); - casper.then(function() { - // this.capture('tag_contacts.png'); - }); - - /* click submit */ - casper.waitForSelector("form#AddToTag input[type=submit][value='Tag Contacts']", function success() { - test.assertExists("form#AddToTag input[type=submit][value='Tag Contacts']"); - this.click("form#AddToTag input[type=submit][value='Tag Contacts']"); - }, function fail() { - test.assertExists("form#AddToTag input[type=submit][value='Tag Contacts']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - casper.then(function() { - // this.capture('tag_success.png'); - }); - - /* - * Add Contacts to Group - 1 Add Contact To Existing Group - */ - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 7-1: Add Contacts to Group - Add Contact To Existing Group. **'); - casper.echo('====================================='); - }); - - list_contacts_and_select_three(test); - - /* select Add Contacts to Group */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 2; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - - /* select dropdown */ - casper.waitForSelector("#group_id", function success() { - test.assertExists("#group_id"); - this.evaluate(function () { - document.querySelector("#group_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#group_id"); - }); - casper.then(function() { - // this.capture('select_group.png'); - }); - - /* click submit */ - casper.waitForSelector("form#AddToGroup input[type=submit][value='Confirm']", function success() { - test.assertExists("form#AddToGroup input[type=submit][value='Confirm']"); - this.click("form#AddToGroup input[type=submit][value='Confirm']"); - }, function fail() { - test.assertExists("form#AddToGroup input[type=submit][value='Confirm']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - casper.then(function() { - // this.capture('add_to_group_success.png'); - }); - - /* - * Add Contacts to Group - 2 Create New Group - */ - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 7-2: Add Contacts to Group - Create New Group. **'); - casper.echo('====================================='); - }); - - list_contacts_and_select_three(test); - - /* select Add Contacts to Group */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 2; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - - /* click Create New Group */ - casper.waitForSelector('#CIVICRM_QFID_1_4', function success() { - test.assertExists('#CIVICRM_QFID_1_4'); - this.click('#CIVICRM_QFID_1_4'); - }, function fail() { - test.assertExists('#CIVICRM_QFID_1_4'); - }); - - /* sendKeys to Group Name */ - casper.waitForSelector("#title", function success() { - test.assertExists("#title"); - this.sendKeys("#title", makeid(5)); - }, function fail() { - test.assertExists("#title"); - }); - casper.then(function() { - // this.capture('create_new_group.png'); - }); - - /* click Confirm */ - casper.waitForSelector("form#AddToGroup input[type=submit][value='Confirm']", function success() { - test.assertExists("form#AddToGroup input[type=submit][value='Confirm']"); - this.click("form#AddToGroup input[type=submit][value='Confirm']"); - }, function fail() { - test.assertExists("form#AddToGroup input[type=submit][value='Confirm']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - casper.then(function() { - // this.capture('create_new_group_success.png'); - }); - - /* - * New Smart Group - */ - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 8: New Smart Group. **'); - casper.echo('====================================='); - }); - - list_contacts_and_select_three(test); - - /* click All records */ - casper.waitForSelector('#CIVICRM_QFID_ts_all_4', function success() { - test.assertExists('#CIVICRM_QFID_ts_all_4'); - this.click('#CIVICRM_QFID_ts_all_4'); - }, function fail() { - test.assertExists('#CIVICRM_QFID_ts_all_4'); - }); - - /* select Add Contacts to Group */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 4; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - - /* sendKeys */ - casper.waitForSelector("#title", function success() { - test.assertExists("#title"); - this.sendKeys("#title", makeid(5)); - }, function fail() { - test.assertExists("#title"); - }); - casper.then(function() { - // this.capture('add_to_smart_group.png'); - }); - - /* click submit */ - casper.waitForSelector("form#SaveSearch input[type=submit][value='Save Smart Group']", function success() { - test.assertExists("form#SaveSearch input[type=submit][value='Save Smart Group']"); - this.click("form#SaveSearch input[type=submit][value='Save Smart Group']"); - }, function fail() { - test.assertExists("form#SaveSearch input[type=submit][value='Save Smart Group']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - casper.then(function() { - // this.capture('smart_group_success.png'); - }); - - /* click Done */ - casper.waitForSelector("form#Result input[type=submit][value='Done']", function success() { - test.assertExists("form#Result input[type=submit][value='Done']"); - this.click("form#Result input[type=submit][value='Done']"); - }, function fail() { - test.assertExists("form#Result input[type=submit][value='Done']"); - }); /* submit form */ - casper.wait(2000); - - /* - * Delete Contacts - */ - - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 9: Delete Contacts. **'); - casper.echo('====================================='); - }); - - list_contacts_and_select_three(test); - - /* select Add Contacts to Group */ - casper.waitForSelector("#task", function success() { - test.assertExists("#task"); - this.evaluate(function () { - document.querySelector("#task").selectedIndex = 17; - }); - }, function fail() { - test.assertExists("#task"); - }); - casper.waitForSelector("form[name=Basic] input[type=submit][value='Go']", function success() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - this.click("form[name=Basic] input[type=submit][value='Go']"); - }, function fail() { - test.assertExists("form[name=Basic] input[type=submit][value='Go']"); - }); /* submit form */ - casper.wait(2000); - - /* click submit */ - casper.waitForSelector("form#Delete input[type=submit][value='Delete Contact(s)']", function success() { - test.assertExists("form#Delete input[type=submit][value='Delete Contact(s)']"); - this.click("form#Delete input[type=submit][value='Delete Contact(s)']"); - }, function fail() { - test.assertExists("form#Delete input[type=submit][value='Delete Contact(s)']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - casper.then(function() { - // this.capture('delete_contacts_success.png'); - }); - - casper.run(function() { - test.done(); - }); -}); \ No newline at end of file diff --git a/tests/casperjs/contribution_allpay.js b/tests/casperjs/contribution_allpay.js deleted file mode 100644 index b4e9cbbc1..000000000 --- a/tests/casperjs/contribution_allpay.js +++ /dev/null @@ -1,72 +0,0 @@ -casper.options.waitTimeout = 30000; - -var system = require('system'); -var port = system.env.RUNPORT; - -var vars = { - testNum: 11, - baseURL: port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - path: 'civicrm/contribute/transact', - query: 'reset=1&action=preview&id=1', - siteName: 'netiCRM', - -// you should add your own testing variables below - pageTitle: '捐款贊助', - userEmail: 'youremail@test.tw', - amountValue: '101', - amountLabel: '101', - allpayCpage: '信用卡資料填寫-歐付寶allPay第三方支付', - allpayVpage: 'OTP刷卡簡訊驗證-歐付寶allPay第三方支付' -}; - -// Step 1: Contribution page -casper.test.begin('Contribution page test (payment processors: allpay)...', vars.testNum, function suite(test) { - casper.start(vars.baseURL+vars.path+'?'+vars.query, function() { - var pageTitle = vars.pageTitle + ' | ' + vars.siteName; - test.assertTitle(pageTitle, 'Contribution page: page title is ' + this.getTitle()); - test.assertExists('div.crm-contribution-main-form-block', 'Contribution page: main form block is exist.'); - test.assertExists('form#Main', 'Contribution page: main form is exist.'); - this.waitForSelector('input[name="payment_processor"]', function(){ - this.fill('form[action="/civicrm/contribute/transact"]', { - 'email-5': vars.userEmail, - 'amount_other': vars.amountValue, - 'payment_processor': "2", - }, - true); - }); - }); - - // Step 2: Contribution Confirm - casper.waitForUrl(/_qf_Confirm_display/, function(){ - test.assertUrlMatch(/_qf_Confirm_display=true/, 'Contribution Confirm'); - test.assertExists('.amount_display-group .display-block strong', 'Contribution Confirm: amount field is exist.'); - test.assertSelectorHasText('.amount_display-group .display-block strong', vars.amountLabel, 'Contribution Confirm: amount label is OK. (' + vars.amountLabel + ')'); - test.assertExists('.contributor_email-section .content', 'Contribution Confirm: email field is exist.'); - test.assertSelectorHasText('.contributor_email-section .content', vars.userEmail, 'Contribution Confirm: email value is OK. (' + vars.userEmail + ')'); - this.click('input[name="_qf_Confirm_next"]'); - }); - - // Step 3: Allpay CreditCard Info - casper.waitForUrl('http://pay-stage.allpay.com.tw/CreditPayment/CreateCreditCardInfo', function(){ - test.assertUrlMatch(/CreateCreditCardInfo/, "Allpay CreditCard Info"); - test.assertTitle(vars.allpayCpage, 'Allpay CreditCard Info: page title is OK. (' + vars.allpayCpage + ')'); - test.assertExists('form[action="/CreditPayment/CreateCreditCardInfo"]', 'Allpay CreditCard Info: form is exist.'); - this.fill('form[action="/CreditPayment/CreateCreditCardInfo"]', { - 'Cellphone': '123456789', - 'CardType': 'VISA', - 'CardNoPart1': '4311', - 'CardNoPart2': '9522', - 'CardNoPart3': '2222', - 'CardLastFourDigit': '2222', - 'CardValidMM': '09', - 'CardValidYY': '31', - 'CardAuthCode': '222', - 'Agree': '1', - }, - true); - }); - - casper.run(function() { - test.done(); - }); -}); diff --git a/tests/casperjs/contribution_allpay_atm.js b/tests/casperjs/contribution_allpay_atm.js deleted file mode 100644 index 283138acc..000000000 --- a/tests/casperjs/contribution_allpay_atm.js +++ /dev/null @@ -1,108 +0,0 @@ -casper.options.waitTimeout = 30000; - -var system = require('system'); -var port = system.env.RUNPORT; -var vars = { - testNum: 22, - baseURL: port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - path: 'civicrm/contribute/transact', - query: 'reset=1&action=preview&id=1', - siteName: 'netiCRM', - - // You should add your own testing variables below - pageTitle: 'CasperJS測試金流', - userEmail: 'youremail@test.tw', - amountValue: '100', - amountLabel: '100', - allpayCpage: '付款選擇支付方式-歐付寶allPay第三方支付', - paymentType: 'AtmPay', - paymentName: 'ATM 櫃員機', - allpayFpage: '訂單成立-歐付寶allPay第三方支付', - backtoBtn: '返回商店', - thxPageTitle: 'THX', -}; - -// Start testing -casper.test.begin('Contribution page test (payment processors: allpay, payment type: ' + vars.paymentType + ')...', vars.testNum, function suite(test) { - // Step 1: Contribution page - casper.start(vars.baseURL + vars.path + '?' + vars.query, function() { - var pageTitle = vars.pageTitle + ' | ' + vars.siteName; - test.assertTitle(pageTitle, 'Contribution page: page title is OK. (' + pageTitle + ')'); - test.assertExists('div.crm-contribution-main-form-block', 'Contribution page: main form block is exist.'); - test.assertExists('form#Main', 'Contribution page: main form is exist.'); - this.waitForSelector('input[name="payment_processor"][value="4"]', function() { // Wait for non-credit card option - this.echo('Event: Click non-credit card option.'); - this.click('input[name="payment_processor"][value="4"]'); - }); - this.waitForSelector('input[name="civicrm_instrument_id_dummy"][value="14"]', function() { // Wait for ATM option - this.echo('Event: Click ATM option.'); - this.click('input[name="civicrm_instrument_id_dummy"][value="14"]'); - this.echo('Event: Fill in the form and submit.'); - this.fill('form[action="/civicrm/contribute/transact"]', { - 'email-5': vars.userEmail, - 'amount_other': vars.amountValue, - }, - true); - }); - }); - - // Step 2: Contribution Confirm - casper.waitForUrl(/_qf_Confirm_display/, function() { - test.assertUrlMatch(/_qf_Confirm_display=true/, 'Contribution Confirm'); - test.assertExists('.amount_display-group .display-block strong', 'Contribution Confirm: amount field is exist.'); - test.assertSelectorHasText('.amount_display-group .display-block strong', vars.amountLabel, 'Contribution Confirm: amount label is OK. (' + vars.amountLabel + ')'); - test.assertExists('.contributor_email-section .content', 'Contribution Confirm: email field is exist.'); - test.assertSelectorHasText('.contributor_email-section .content', vars.userEmail, 'Contribution Confirm: email value is OK. (' + vars.userEmail + ')'); - this.echo('Event: Click button to the allpay page.'); - this.click('input[name="_qf_Confirm_next"]'); - }); - - // Step 3: Allpay AioTransaction - casper.waitForUrl('http://payment-stage.allpay.com.tw/AioTransaction/AioPaymentTransaction', function() { - test.assertUrlMatch(/AioPaymentTransaction/, "Allpay AioPaymentTransaction"); - test.assertTitle(vars.allpayCpage, 'Allpay AioPaymentTransaction: page title is OK. (' + vars.allpayCpage + ')'); - this.waitForSelector('div.AtmPay', function() { - test.assertExists('div.AtmPay', 'Allpay AioPaymentTransaction: payment type is ' + vars.paymentType + '.'); - test.assertSelectorHasText('div.AtmPay', vars.paymentName, 'Allpay AioPaymentTransaction: payment name is ' + vars.paymentName + '.'); - }); - this.waitForSelector('input[name="atmPayType"]', function() { - test.assertExists('input[name="atmPayType"]', 'Allpay AioPaymentTransaction: atmPayType is exist.'); - this.echo('Event: Choose atmPayType\'s first option.'); - this.click('input[name="atmPayType"]:first-child'); - }); - this.waitForSelector('#AtmPaySubmit', function() { - test.assertExists('#AtmPaySubmit', 'Allpay AioPaymentTransaction: AtmPaySubmit is exist.'); - this.echo('Event: Click AtmPaySubmit button to trigger the alert message.'); - this.click('#AtmPaySubmit'); // First click to trigger the alert message - this.echo('Event: Click AtmPaySubmit button again to submit form.'); - this.click('#AtmPaySubmit'); // Second click to submit form - }); - }); - - // Step 4: Allpay ATMPaymentInfo - casper.waitForUrl('http://payment-stage.allpay.com.tw/PaymentRule/ATMPaymentInfo', function() { - test.assertUrlMatch(/ATMPaymentInfo/, "Allpay ATMPaymentInfo"); - test.assertTitle(vars.allpayFpage, 'Allpay ATMPaymentInfo: page title is OK. (' + vars.allpayFpage + ')'); - test.assertExists('div.sumbit > a[href*="' + vars.path + '"]', 'Allpay ATMPaymentInfo: "back to contribution page" button is exist.'); - test.assertSelectorHasText('div.sumbit > a[href*="' + vars.path + '"]', vars.backtoBtn, 'Allpay ATMPaymentInfo: "back to contribution page" button label is ' + vars.backtoBtn + '.'); - this.echo('Event: Click submit button to return to the netiCRM contribution page.'); - this.click('div.sumbit > a[href*="' + vars.path + '"]'); - }); - - // Step 5: Contribution Thankyou - casper.waitForUrl(vars.baseURL + vars.path + '?_qf_ThankYou_display', function() { - var pageTitle = vars.thxPageTitle + ' | ' + vars.siteName; - test.assertUrlMatch(/_qf_ThankYou_display=1&qfKey=/, "Contribution Thankyou"); - test.assertTitle(pageTitle, 'Contribution Thankyou: page title is OK. (' + pageTitle + ')'); - test.assertExists('div.crm-contribution-thankyou-form-block', 'Contribution Thankyou: thankyou form block is exist.'); - test.assertExists('form#ThankYou', 'Contribution Thankyou: thankyou form is exist.'); - }); - - casper.on('remote.alert', function(message) { - this.echo('Alert message: ' + message); // Shows each alert message - }); - - casper.run(function() { - test.done(); - }); -}); diff --git a/tests/casperjs/contribution_allpay_barcode.js b/tests/casperjs/contribution_allpay_barcode.js deleted file mode 100644 index 87153dbdd..000000000 --- a/tests/casperjs/contribution_allpay_barcode.js +++ /dev/null @@ -1,103 +0,0 @@ -casper.options.waitTimeout = 30000; - -var system = require('system'); -var port = system.env.RUNPORT; -var vars = { - testNum: 21, - baseURL: port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - path: 'civicrm/contribute/transact', - query: 'reset=1&action=preview&id=1', - siteName: 'netiCRM', - - // You should add your own testing variables below - pageTitle: 'CasperJS測試金流', - userEmail: 'youremail@test.tw', - amountValue: '100', - amountLabel: '100', - allpayCpage: '付款選擇支付方式-歐付寶allPay第三方支付', - paymentType: 'barcodePay', - paymentName: '超商條碼', - allpayFpage: '訂單成立-歐付寶allPay第三方支付', - backtoBtn: '返回商店', - thxPageTitle: 'THX', -}; - -// Start testing -casper.test.begin('Contribution page test (payment processors: allpay, payment type: ' + vars.paymentType + ')...', vars.testNum, function suite(test) { - // Step 1: Contribution page - casper.start(vars.baseURL + vars.path + '?' + vars.query, function() { - var pageTitle = vars.pageTitle + ' | ' + vars.siteName; - test.assertTitle(pageTitle, 'Contribution page: page title is OK. (' + pageTitle + ')'); - test.assertExists('div.crm-contribution-main-form-block', 'Contribution page: main form block is exist.'); - test.assertExists('form#Main', 'Contribution page: main form is exist.'); - this.waitForSelector('input[name="payment_processor"][value="4"]', function() { // Wait for non credit card option - this.echo('Event: Click non-credit card option.'); - this.click('input[name="payment_processor"][value="4"]'); - }); - this.waitForSelector('input[name="civicrm_instrument_id_dummy"][value="11"]', function() { // Wait for barcode option - this.echo('Event: Click barcode option.'); - this.click('input[name="civicrm_instrument_id_dummy"][value="11"]'); - this.echo('Event: Fill in the form and submit.'); - this.fill('form[action="/civicrm/contribute/transact"]', { - 'email-5': vars.userEmail, - 'amount_other': vars.amountValue, - }, - true); - }); - }); - - // Step 2: Contribution Confirm - casper.waitForUrl(/_qf_Confirm_display/, function() { - test.assertUrlMatch(/_qf_Confirm_display=true/, 'Contribution Confirm'); - test.assertExists('.amount_display-group .display-block strong', 'Contribution Confirm: amount field is exist.'); - test.assertSelectorHasText('.amount_display-group .display-block strong', vars.amountLabel, 'Contribution Confirm: amount label is OK. (' + vars.amountLabel + ')'); - test.assertExists('.contributor_email-section .content', 'Contribution Confirm: email field is exist.'); - test.assertSelectorHasText('.contributor_email-section .content', vars.userEmail, 'Contribution Confirm: email value is OK. (' + vars.userEmail + ')'); - this.echo('Event: Click button to the allpay page.'); - this.click('input[name="_qf_Confirm_next"]'); - }); - - // Step 3: Allpay AioTransaction - casper.waitForUrl('http://payment-stage.allpay.com.tw/AioTransaction/AioPaymentTransaction', function(){ - test.assertUrlMatch(/AioPaymentTransaction/, "Allpay AioPaymentTransaction"); - test.assertTitle(vars.allpayCpage, 'Allpay AioPaymentTransaction: page title is OK. (' + vars.allpayCpage + ')'); - this.waitForSelector('div.BarcodePay', function() { - test.assertExists('div.BarcodePay', 'Allpay AioPaymentTransaction: payment type is ' + vars.paymentType + '.'); - test.assertSelectorHasText('div.BarcodePay', vars.paymentName, 'Allpay AioPaymentTransaction: payment name is ' + vars.paymentName + '.'); - }); - this.waitForSelector('#BarcodePaySubmit', function() { - test.assertExists('#BarcodePaySubmit', 'Allpay AioPaymentTransaction: BarcodePaySubmit is exist.'); - this.echo('Event: Click BarcodePaySubmit button to trigger the alert message.'); - this.click('#BarcodePaySubmit'); // First click to trigger the alert message - this.echo('Event: Click BarcodePaySubmit button again to submit form.'); - this.click('#BarcodePaySubmit'); // Second click to submit form - }); - }); - - // Step 4: Allpay BarcodePaymentInfo - casper.waitForUrl('http://payment-stage.allpay.com.tw/PaymentRule/BarcodePaymentInfo', function() { - test.assertUrlMatch(/BarcodePaymentInfo/, "Allpay BarcodePaymentInfo"); - test.assertTitle(vars.allpayFpage, 'Allpay BarcodePaymentInfo: page title is OK. (' + vars.allpayFpage + ')'); - test.assertExists('div.print > a[href*="' + vars.path + '"]', 'Allpay BarcodePaymentInfo: "back to contribution page" button is exist.'); - test.assertSelectorHasText('div.print > a[href*="' + vars.path + '"]', vars.backtoBtn, 'Allpay BarcodePaymentInfo: "back to contribution page" button label is ' + vars.backtoBtn + '.'); - this.echo('Event: Click submit button to return to the netiCRM contribution page.'); - this.click('div.print > a[href*="' + vars.path + '"]'); - }); - - casper.on('remote.alert', function(message) { - this.echo('Alert message: ' + message); // Shows each alert message - }); - - // Step 5: Contribution Thankyou - casper.waitForUrl(vars.baseURL + vars.path + '?_qf_ThankYou_display', function() { - var pageTitle = vars.thxPageTitle + ' | ' + vars.siteName; - test.assertUrlMatch(/_qf_ThankYou_display=1&qfKey=/, "Contribution Thankyou"); - test.assertTitle(pageTitle, 'Contribution Thankyou: page title is OK. (' + pageTitle + ')'); - test.assertExists('div.crm-contribution-thankyou-form-block', 'Contribution Thankyou: thankyou form block is exist.'); - test.assertExists('form#ThankYou', 'Contribution Thankyou: thankyou form is exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); diff --git a/tests/casperjs/custom_data.test.js b/tests/casperjs/custom_data.test.js deleted file mode 100644 index 6e649a6ed..000000000 --- a/tests/casperjs/custom_data.test.js +++ /dev/null @@ -1,1787 +0,0 @@ -/* basic setting */ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var vars = { - baseURL : port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - id: makeid(5), - ids: [], - ids_for_check: [], - custom_id: 0, - text_id_for_input: [], - radio_id_for_input: [] -}; - -casper.on('remote.message', function (msg) { - this.echo('remote message caught: ' + msg); -}); - -function fill_options(test) { - /* sendKeys to Multiple Choice Options*/ - casper.waitForSelector("input[name='option_label[1]']", function success() { - test.assertExists("input[name='option_label[1]']"); - this.sendKeys("input[name='option_label[1]']", "op1"); - }, function fail() { - test.assertExists("input[name='option_label[1]']"); - }); - casper.waitForSelector("input[name='option_value[1]']", function success() { - test.assertExists("input[name='option_value[1]']"); - this.sendKeys("input[name='option_value[1]']", "op1"); - }, function fail() { - test.assertExists("input[name='option_value[1]']"); - }); - casper.waitForSelector("input[name='option_label[2]']", function success() { - test.assertExists("input[name='option_label[2]']"); - this.sendKeys("input[name='option_label[2]']", "op2"); - }, function fail() { - test.assertExists("input[name='option_label[2]']"); - }); - casper.waitForSelector("input[name='option_value[2]']", function success() { - test.assertExists("input[name='option_value[2]']"); - this.sendKeys("input[name='option_value[2]']", "op2"); - }, function fail() { - test.assertExists("input[name='option_value[2]']"); - }); -} - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Start testing...', function(test) { - - /* - * Add Set of Custom Fields - */ - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 1: Add Set of Custom Fields. **'); - casper.echo('====================================='); - }); - - // open New Custom Field Set page - casper.thenOpen(vars.baseURL + "civicrm/admin/custom/group?action=add&reset=1"); - casper.wait(2000); - - /* sendKeys to Set Name */ - casper.waitForSelector("#title", function success() { - test.assertExists("#title"); - this.sendKeys("#title", 'testset' + vars.id); - }, function fail() { - test.assertExists("#title"); - }); - - /* select 'Used For' to 'Contact' */ - casper.waitForSelector("select[name='extends[0]']", function success() { - test.assertExists("select[name='extends[0]']"); - this.evaluate(function () { - document.querySelector("select[name='extends[0]']").value = 'Contact'; - }); - }, function fail() { - test.assertExists("select[name='extends[0]']"); - }); - casper.then(function() { - // this.capture('add_set_of_custom.png'); - }); - - /* click Save */ - casper.waitForSelector('input[type=submit][value="Save"]', function success() { - test.assertExists('input[type="submit"][value="Save"]'); - this.click('input[type="submit"][value="Save"]'); - }, function fail() { - test.assertExists('input[type="submit"][value="Save"]'); - }); - - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - - /* - * Add 7 alphanumeric fields - */ - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 2: Add Alphanumeric field, including Text, Select, Radio, CheckBox, Multi-Select, Advanced Multi-Select, Autocomplete Select. **'); - casper.echo('====================================='); - }); - - - /* 1. Text */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 2-1: Add Text field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'text' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - casper.then(function() { - // this.capture('Text.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - - /* 2. Select */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 2-2: Add Select field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'select' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type */ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - /* click dropdown to invoke onclick function */ - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.click("select[name='data_type[1]']"); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - fill_options(test); - - casper.then(function() { - // this.capture('Select.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - - /* 3. Radio */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 2-3: Add Radio field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'radio' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 2; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - /* click dropdown to invoke onclick function */ - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.click("select[name='data_type[1]']"); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - fill_options(test); - - casper.then(function() { - // this.capture('Radio.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - - /* 4. Checkbox */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 2-4: Add Checkbox field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'checkbox' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 3; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - /* click dropdown to invoke onclick function */ - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.click("select[name='data_type[1]']"); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - fill_options(test); - - casper.then(function() { - // this.capture('Checkbox.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - - /* 5. Multi-Select */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 2-5: Add Multi-Select field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'multi_select' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 4; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - /* click dropdown to invoke onclick function */ - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.click("select[name='data_type[1]']"); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - fill_options(test); - - casper.then(function() { - // this.capture('Multi-Select.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 6. Advanced Multi-Select */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 2-6: Add Advanced Multi-Select field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'advanced_multi_select' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 5; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - /* click dropdown to invoke onclick function */ - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.click("select[name='data_type[1]']"); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - fill_options(test); - - casper.then(function() { - // this.capture('Advanced_Multi-Select.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - - /* 7. Autocomplete Select */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 2-7: Add Autocomplete Select field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'autocomplete_select' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 6; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - /* click dropdown to invoke onclick function */ - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.click("select[name='data_type[1]']"); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - fill_options(test); - - casper.then(function() { - // this.capture('Autocomplete_Select.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* - * Add 14 different types of field - */ - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 3: Add Integer, Number, Money, Note, Date, Yes or No, State/Province, Country, File, Link, Contact Reference fields. **'); - casper.echo('====================================='); - }); - - /* 1. Integer */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-1: Add Integer field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Integer' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 1; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - - casper.then(function() { - // this.capture('Integer.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 2. Number */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-2: Add Number field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Number' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 2; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - - casper.then(function() { - // this.capture('Number.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 3. Money */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-3: Add Money field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Money' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 3; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - - casper.then(function() { - // this.capture('Money.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 4-1. Note TextArea */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-4-1: Add Note TextArea field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Note_TextArea' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 4; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - casper.then(function() { - // this.capture('Note_TextArea.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 4-2. Note WYSIWYG Editor */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-4-2: Add Note WYSIWYG Editor field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Note_WYSIWYG_Editor' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 4; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - casper.then(function() { - // this.capture('Note_WYSIWYG_Editor.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 5. Date */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-5: Add Date field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Date' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 5; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - - /* click Data and Input Field Type to invoke onclick event */ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.click("select[name='data_type[0]']"); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - - /* select Date Format */ - casper.waitForSelector("select[name='date_format']", function success() { - test.assertExists("select[name='date_format']"); - this.evaluate(function () { - document.querySelector("select[name='date_format']").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("select[name='date_format']"); - }); - - casper.then(function() { - // this.capture('Date.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 6. Yes or No */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-6: Add Yes or No field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Yes_or_No' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 6; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - - casper.then(function() { - // this.capture('Yes_or_No.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }) - - /* 7-1. State/Province Select */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-7-1: Add State/Province Select field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'State_Province_Select' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 7; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - casper.then(function() { - // this.capture('State_Province_Select.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 7-2. State/Province Multi-Select */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-7-2: Add State/Province Multi Select field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'State_Province_Multi_Select' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 7; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - casper.then(function() { - // this.capture('State_Province_Multi_Select.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 8-1. Country Select */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-8-1: Add Country Select field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Country_Select' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 8; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 0; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - casper.then(function() { - // this.capture('Country_Select.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 8-2. Country Multi Select */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-8-2: Add Country Multi Select field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Country_Multi_Select' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 8; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - casper.waitForSelector("select[name='data_type[1]']", function success() { - test.assertExists("select[name='data_type[1]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[1]']").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("select[name='data_type[1]']"); - }); - - casper.then(function() { - // this.capture('Country_Multi_Select.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 9. File */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-9: Add File field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'File' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 9; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - - casper.then(function() { - // this.capture('File.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 10. Link */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-10: Add Link field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Link' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 10; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - - casper.then(function() { - // this.capture('Link.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* 11. Contact Reference */ - /* sendKeys to Field Label */ - casper.waitForSelector("input[name='label']", function success() { - casper.echo('** Step 3-11: Add Contact Reference field. **'); - test.assertExists("input[name='label']"); - this.sendKeys("input[name='label']", 'Contact_Reference' + vars.id); - }, function fail() { - test.assertExists("input[name='label']"); - }); - - /* select Data and Input Field Type*/ - casper.waitForSelector("select[name='data_type[0]']", function success() { - test.assertExists("select[name='data_type[0]']"); - this.evaluate(function () { - document.querySelector("select[name='data_type[0]']").selectedIndex = 11; - document.querySelector("select[name='data_type[0]']").onchange(); - }); - }, function fail() { - test.assertExists("select[name='data_type[0]']"); - }); - - casper.then(function() { - // this.capture('Contact_Reference.png'); - }); - - /* click submit */ - casper.waitForSelector("input[type=submit][value='Save and New']", function success() { - test.assertExists("input[type=submit][value='Save and New']"); - this.click("input[type=submit][value='Save and New']"); - }, function fail() { - test.assertExists("input[type=submit][value='Save and New']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - - /* - * Add Set of Custom Fields - */ - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 4: Check Preview. **'); - casper.echo('====================================='); - }); - - /* open custom data page */ - casper.thenOpen(vars.baseURL + "civicrm/admin/custom/group?reset=1", function() { - // this.capture('back_to_custom_data_page.png'); - }); - - casper.wait(2000); - - /* go to Custom Fields page */ - casper.waitForSelector("#custom_group table", function success() { - casper.echo('** Step 4-1: Get all expacted id. **'); - test.assertExists("#custom_group table"); - var id = this.evaluate(function () { - return document.querySelector('#custom_group table').rows.length - 1; - }); - this.open(vars.baseURL + "civicrm/admin/custom/group/field?reset=1&action=browse&gid=" + id); - }, function fail() { - test.assertExists("#custom_group table", "Custom data list exist."); - }); - casper.wait(2000); - casper.then(function() { - // this.capture('Custom_Fields.png'); - }); - - /* get all fields id */ - casper.then(function() { - var urls = this.evaluate(function() { - var all_links = document.querySelectorAll("a[title='Preview Custom Field']"); - var all_urls = []; - for(var i = 0; i < all_links.length; i++) { - all_urls.push(all_links[i].href); - } - return all_urls; - }); - vars.ids = urls.map(function(url) { - var splits = url.split('='); - return splits[splits.length - 1]; - }); - }); - - /* open custom data page */ - casper.thenOpen(vars.baseURL + "civicrm/admin/custom/group?reset=1", function() { - // this.capture('back_to_custom_data_page.png'); - }); - - casper.wait(2000); - /* go to Custom Fields page */ - casper.waitForSelector("#custom_group table", function success() { - test.assertExists("#custom_group table"); - var id = this.evaluate(function () { - return document.querySelector('#custom_group table').rows.length - 1; - }); - this.open(vars.baseURL + "civicrm/admin/custom/group?action=preview&reset=1&id=" + id); - }, function fail() { - test.assertExists("#custom_group table", "Custom data list exist."); - }); - casper.wait(2000); - casper.then(function() { - // this.capture('Preview.png'); - }); - - /* get all text input id */ - casper.then(function() { - casper.echo('** Step 4-2: Get all text input id. **'); - var text_ids = this.evaluate(function() { - var all_text = document.getElementById('Preview').querySelectorAll('input[type="text"]:not(.hiddenElement), input[type="file"]'); - var text_ids = []; - for(var i = 0; i < all_text.length; i++){ - var sp = all_text[i].id.split('_'); - text_ids.push(sp[1]); - } - return text_ids; - }); - text_ids.forEach(function(text_id) { - vars.ids_for_check.push(text_id); - }); - }); - - /* get all select id */ - casper.then(function() { - casper.echo('** Step 4-3: Get all select id. **'); - var select_ids = this.evaluate(function() { - var all_select = document.getElementById('Preview').querySelectorAll('select'); - var select_ids = []; - for(var i = 0; i < all_select.length; i++){ - var sp = all_select[i].id.split('_'); - select_ids.push(sp[1]); - } - return select_ids; - }); - select_ids.forEach(function(select_id) { - vars.ids_for_check.push(select_id); - }); - }); - - /* get all radio input id */ - casper.then(function() { - casper.echo('** Step 4-4: Get all radio input id. **'); - var radio_ids = this.evaluate(function() { - var all_radio = document.getElementById('Preview').querySelectorAll('input[type="radio"]'); - var radio_ids = []; - for(var i = 0; i < all_radio.length; i++){ - var sp = all_radio[i].name.split('_'); - radio_ids.push(sp[1]); - } - return radio_ids; - }); - radio_ids.forEach(function(radio_id) { - vars.ids_for_check.push(radio_id); - }); - }); - - /* get all checkbox input id */ - casper.then(function() { - casper.echo('** Step 4-5: Get all checkbox input id. **'); - var checkbox_ids = this.evaluate(function() { - var all_checkbox = document.getElementById('Preview').querySelectorAll('input[type="checkbox"]'); - var checkbox_ids = []; - for(var i = 0; i < all_checkbox.length; i++){ - var sp = all_checkbox[i].id.split('_'); - checkbox_ids.push(sp[1]); - } - return checkbox_ids; - }); - checkbox_ids.forEach(function(checkbox_id) { - vars.ids_for_check.push(checkbox_id); - }); - }); - - /* get all textarea id */ - casper.then(function() { - casper.echo('** Step 4-6: Get all textarea id. **'); - var textarea_ids = this.evaluate(function() { - var all_textarea = document.getElementById('Preview').querySelectorAll('textarea'); - var textarea_ids = []; - for(var i = 0; i < all_textarea.length; i++){ - var sp = all_textarea[i].id.split('_'); - textarea_ids.push(sp[1]); - } - return textarea_ids; - }); - textarea_ids.forEach(function(textarea_id) { - vars.ids_for_check.push(textarea_id); - }); - }); - - /* check all id exist */ - casper.then(function() { - casper.echo('** Step 4-7: Check all id exist. **'); - var id_no_duplicate = []; - for(var i = 0; i < vars.ids_for_check.length; i++) { - var exist_flag = false; - for(var j = 0; j < id_no_duplicate.length; j++) { - if(vars.ids_for_check[i] == id_no_duplicate[j]) { - exist_flag = true; - break - } - } - if(!exist_flag) { - id_no_duplicate.push(vars.ids_for_check[i]); - } - } - id_no_duplicate.sort(function(a, b) { - return a - b; - }); - test.assertEquals(vars.ids, id_no_duplicate); - }); - - /* - * Check Add Contact - */ - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 5: Check Add Contact. **'); - casper.echo('====================================='); - }); - - /* open custom data page */ - casper.thenOpen(vars.baseURL + "civicrm/admin/custom/group?reset=1", function() { - // this.capture('back_to_custom_data_page.png'); - }); - casper.wait(2000); - - /* get custom data id */ - casper.waitForSelector("#custom_group table", function success() { - casper.echo('** Step 5-1: Get custom data id. **'); - test.assertExists("#custom_group table"); - vars.custom_id = this.evaluate(function () { - return document.querySelector('#custom_group table').rows.length - 1; - }); - }, function fail() { - test.assertExists("#custom_group table", "Custom data list exist."); - }); - - /* open new individual page */ - casper.thenOpen(vars.baseURL + "civicrm/contact/add?reset=1&ct=Individual", function() { - // this.capture('add_individual.png'); - }); - casper.wait(2000); - - /* get all text input id */ - casper.then(function() { - casper.echo('** Step 5-2: Get all text input id. **'); - var text_ids = this.evaluate(function(custom_id) { - var all_text = document.getElementById('customData' + custom_id).querySelectorAll('input[type="text"]:not(.hiddenElement), input[type="file"]'); - var text_ids = []; - for(var i = 0; i < all_text.length; i++){ - var sp = all_text[i].id.split('_'); - text_ids.push(sp[1]); - } - return text_ids; - }, vars.custom_id); - vars.ids_for_check = []; - text_ids.forEach(function(text_id) { - vars.ids_for_check.push(text_id); - }); - }); - - /* get all select id */ - casper.then(function() { - casper.echo('** Step 5-3: Get all select id. **'); - var select_ids = this.evaluate(function(custom_id) { - var all_select = document.getElementById('customData' + custom_id).querySelectorAll('select'); - var select_ids = []; - for(var i = 0; i < all_select.length; i++){ - var sp = all_select[i].id.split('_'); - select_ids.push(sp[1]); - } - return select_ids; - }, vars.custom_id); - select_ids.forEach(function(select_id) { - vars.ids_for_check.push(select_id); - }); - }); - - /* get all radio input id */ - casper.then(function() { - casper.echo('** Step 5-4: Get all radio input id. **'); - var radio_ids = this.evaluate(function(custom_id) { - var all_radio = document.getElementById('customData' + custom_id).querySelectorAll('input[type="radio"]'); - var radio_ids = []; - for(var i = 0; i < all_radio.length; i++){ - var sp = all_radio[i].name.split('_'); - radio_ids.push(sp[1]); - } - return radio_ids; - }, vars.custom_id); - radio_ids.forEach(function(radio_id) { - vars.ids_for_check.push(radio_id); - }); - }); - - /* get all checkbox input id */ - casper.then(function() { - casper.echo('** Step 5-5: Get all checkbox input id. **'); - var checkbox_ids = this.evaluate(function(custom_id) { - var all_checkbox = document.getElementById('customData' + custom_id).querySelectorAll('input[type="checkbox"]'); - var checkbox_ids = []; - for(var i = 0; i < all_checkbox.length; i++){ - var sp = all_checkbox[i].id.split('_'); - checkbox_ids.push(sp[1]); - } - return checkbox_ids; - }, vars.custom_id); - checkbox_ids.forEach(function(checkbox_id) { - vars.ids_for_check.push(checkbox_id); - }); - }); - - /* get all textarea id */ - casper.then(function() { - casper.echo('** Step 5-6: Get all textarea id. **'); - var textarea_ids = this.evaluate(function(custom_id) { - var all_textarea = document.getElementById('customData' + custom_id).querySelectorAll('textarea'); - var textarea_ids = []; - for(var i = 0; i < all_textarea.length; i++){ - var sp = all_textarea[i].id.split('_'); - textarea_ids.push(sp[1]); - } - return textarea_ids; - }, vars.custom_id); - textarea_ids.forEach(function(textarea_id) { - vars.ids_for_check.push(textarea_id); - }); - }); - - /* check all id exist */ - casper.then(function() { - casper.echo('** Step 5-7: Check all id exist. **'); - var id_no_duplicate = []; - for(var i = 0; i < vars.ids_for_check.length; i++) { - var exist_flag = false; - for(var j = 0; j < id_no_duplicate.length; j++) { - if(vars.ids_for_check[i] == id_no_duplicate[j]) { - exist_flag = true; - break - } - } - if(!exist_flag) { - id_no_duplicate.push(vars.ids_for_check[i]); - } - } - id_no_duplicate.sort(function(a, b) { - return a - b; - }); - test.assertEquals(vars.ids, id_no_duplicate); - }); - - /* - * Input All Fields - */ - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 6: Input All Fields. **'); - casper.echo('====================================='); - }); - - /* filled up last name and first name */ - casper.waitForSelector("input[name='last_name']", function success() { - casper.echo('** Step 6-1: Filled up last name and first name. **'); - this.sendKeys("input[name='last_name']", makeid(5)); - }, function fail() { - test.assertExists("input[name='last_name']"); - }); - casper.waitForSelector("input[name='first_name']", function success() { - this.sendKeys("input[name='first_name']", makeid(5)); - }, function fail() { - test.assertExists("input[name='first_name']"); - }); - - /* get all pure text input id */ - casper.then(function() { - casper.echo('** Step 6-2: Get all pure text id. **'); - var text_ids = this.evaluate(function(custom_id) { - var all_text = document.getElementById('customData' + custom_id).querySelectorAll('input[type="text"]:not(.hiddenElement):not(.dateplugin):not(.ac_input)'); - var text_ids = []; - for(var i = 0; i < all_text.length; i++){ - var sp = all_text[i].id.split('_'); - text_ids.push(sp[1]); - } - return text_ids; - }, vars.custom_id); - text_ids.forEach(function(text_id) { - vars.text_id_for_input.push(text_id); - }); - }); - - /* input all pure text */ - casper.then(function() { - casper.echo('** Step 6-3: Input all pure text. **'); - vars.text_id_for_input.forEach(function(text_id) { - casper.waitForSelector('input[name="custom_' + text_id + '_-1"]', function success() { - var rand_int = Math.floor(Math.random() * 10000); - this.sendKeys('input[name="custom_' + text_id + '_-1"]', rand_int.toString()); - }, function fail() { - test.assertExists('input[name="custom_' + text_id + '_-1"]'); - }); - }); - }); - - casper.then(function() { - // this.capture('Filled_up_text.png'); - }); - - - /* get all select(not multi) id */ - var select_id_for_input = []; - casper.then(function() { - casper.echo('** Step 6-4: Get all select(not multi) id. **'); - var select_ids = this.evaluate(function(custom_id) { - var all_select = document.getElementById('customData' + custom_id).querySelectorAll('select'); - var select_ids = []; - for(var i = 0; i < all_select.length; i++){ - var sp = all_select[i].id.split('_'); - select_ids.push(sp[1]); - } - return select_ids; - }, vars.custom_id); - select_ids.forEach(function(select_id) { - select_id_for_input.push(select_id); - }); - }); - - /* input all select(not multi) */ - casper.then(function() { - casper.echo('** Step 6-5: Input all select(not multi). **'); - select_id_for_input.forEach(function(select_id) { - casper.waitForSelector('#custom_' + select_id + '_-1', function success() { - this.evaluate(function (select_id) { - if(document.getElementById('custom_' + select_id + '_-1').options.length >= 2){ - document.getElementById('custom_' + select_id + '_-1').selectedIndex = 1; - } else { - document.getElementById('custom_' + select_id + '_-1').selectedIndex = 0; - } - }, select_id); - }, function fail() { - test.assertExists('custom_' + select_id + '_-1'); - }); - }); - }); - - casper.then(function() { - // this.capture('Filled_up_select.png'); - }); - - /* get all radio input id */ - casper.then(function() { - casper.echo('** Step 6-6: Get all radio input id. **'); - var radio_ids = this.evaluate(function(custom_id) { - var all_radio = document.getElementById('customData' + custom_id).querySelectorAll('input[type="radio"]'); - var radio_ids = []; - for(var i = 0; i < all_radio.length; i++){ - var sp = all_radio[i].name.split('_'); - radio_ids.push(sp[1]); - } - return radio_ids; - }, vars.custom_id); - radio_ids.forEach(function(radio_id) { - vars.radio_id_for_input.push(radio_id); - }); - }); - - /* input all radio */ - casper.then(function() { - casper.echo('** Step 6-7: Input all radio. **'); - vars.radio_id_for_input.forEach(function(radio_id) { - casper.waitForSelector('input[name="custom_' + radio_id + '_-1"]', function success() { - this.evaluate(function (radio_id) { - document.querySelector('input[name="custom_' + radio_id + '_-1"]').checked = true; - }, radio_id); - }, function fail() { - test.assertExists('input[name="custom_' + radio_id + '_-1"]'); - }); - }); - }); - - /* input all checkbox */ - casper.then(function() { - casper.echo('** Step 6-8: Input all checkbox. **'); - var checkbox_id = this.evaluate(function (custom_id) { - return document.getElementById('customData' + custom_id).querySelectorAll('input[type="checkbox"]')[0].id; - }, vars.custom_id); - casper.waitForSelector('input[name="' + checkbox_id + '"]', function success() { - this.evaluate(function (checkbox_id) { - document.getElementById(checkbox_id).checked = true; - }, checkbox_id); - }, function fail() { - test.assertExists('input[name="' + checkbox_id + '"]'); - }); - }); - - casper.then(function() { - // this.capture('Filled_up_checkbox.png'); - }); - - /* input advanced multi select */ - casper.then(function () { - casper.echo('** Step 6-9: Input advanced multi select. **'); - var adv_selector = '#customData' + vars.custom_id + ' table.advmultiselect select'; - casper.waitForSelector(adv_selector, function success() { - this.evaluate(function(adv_selector) { - document.querySelector(adv_selector).selectedIndex = 0; - }, adv_selector); - }, function fail() { - test.assertExists(adv_selector); - }); - - var add_selector = '#customData' + vars.custom_id + ' table.advmultiselect input[value="Add >>"]'; - casper.waitForSelector(add_selector, function success() { - this.click(add_selector); - }, function fail() { - test.assertExists(add_selector); - }); - }); - - casper.then(function() { - // this.capture('Filled_up_adv_multi_select.png'); - }); - - /* input textarea */ - casper.then(function() { - casper.echo('** Step 6-10: Input textarea. **'); - var textarea_selector = '#customData' + vars.custom_id + ' textarea.form-textarea'; - casper.waitForSelector(textarea_selector, function success() { - this.sendKeys(textarea_selector, makeid(5)); - }, function fail() { - this.assertExists(textarea_selector); - }); - }); - - casper.then(function() { - // this.capture('Filled_up_textarea.png'); - }); - - /* input ckeditor */ - // refs #34197, ckeditor not support old phantomjs - /* - casper.then(function() { - var cke_selector = '#customData' + vars.custom_id + ' iframe.cke_wysiwyg_frame'; - casper.waitForSelector(cke_selector, function success() { - this.evaluate(function(cke_selector) { - document.querySelector(cke_selector).contentWindow.document.querySelector("p").textContent = 'abc'; - }, cke_selector); - }, function fail() { - test.assertExists(cke_selector); - }); - }); - - casper.then(function() { - // this.capture('Filled_up_ckeditor.png'); - }); - */ - - casper.waitForSelector("#_qf_Contact_upload_view", function success() { - casper.echo('** Step 6-11: Save data. **'); - test.assertExists("#_qf_Contact_upload_view"); - this.click("#_qf_Contact_upload_view"); - }, function fail() { - test.assertExists("#_qf_Contact_upload_view"); - }); - - casper.wait(2000); - casper.then(function() { - // this.capture('save_data.png'); - }); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - /* - * Check All Fields Exists in Edit Page - */ - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 7: Check All Fields Exists in Edit Page. **'); - casper.echo('====================================='); - }); - - casper.waitForSelector("a.edit", function success() { - casper.echo('** Step 7-1: Go to edit page. **'); - test.assertExists("a.edit"); - this.click("a.edit"); - }, function fail() { - test.assertExists("a.edit"); - }); - - casper.wait(2000); - - /* get all text input id */ - casper.then(function() { - casper.echo('** Step 7-2: Get all text input id. **'); - var text_ids = this.evaluate(function(custom_id) { - var all_text = document.getElementById('customData' + custom_id).querySelectorAll('input[type="text"]:not(.hiddenElement), input[type="file"]'); - var text_ids = []; - for(var i = 0; i < all_text.length; i++){ - var sp = all_text[i].id.split('_'); - text_ids.push(sp[1]); - } - return text_ids; - }, vars.custom_id); - vars.ids_for_check = []; - text_ids.forEach(function(text_id) { - vars.ids_for_check.push(text_id); - }); - }); - - /* get all select id */ - casper.then(function() { - casper.echo('** Step 7-3: Get all select id. **'); - var select_ids = this.evaluate(function(custom_id) { - var all_select = document.getElementById('customData' + custom_id).querySelectorAll('select'); - var select_ids = []; - for(var i = 0; i < all_select.length; i++){ - var sp = all_select[i].id.split('_'); - select_ids.push(sp[1]); - } - return select_ids; - }, vars.custom_id); - select_ids.forEach(function(select_id) { - vars.ids_for_check.push(select_id); - }); - }); - - /* get all radio input id */ - casper.then(function() { - casper.echo('** Step 7-4: Get all radio input id. **'); - var radio_ids = this.evaluate(function(custom_id) { - var all_radio = document.getElementById('customData' + custom_id).querySelectorAll('input[type="radio"]'); - var radio_ids = []; - for(var i = 0; i < all_radio.length; i++){ - var sp = all_radio[i].name.split('_'); - radio_ids.push(sp[1]); - } - return radio_ids; - }, vars.custom_id); - radio_ids.forEach(function(radio_id) { - vars.ids_for_check.push(radio_id); - }); - }); - - /* get all checkbox input id */ - casper.then(function() { - casper.echo('** Step 7-5: Get all checkbox input id. **'); - var checkbox_ids = this.evaluate(function(custom_id) { - var all_checkbox = document.getElementById('customData' + custom_id).querySelectorAll('input[type="checkbox"]'); - var checkbox_ids = []; - for(var i = 0; i < all_checkbox.length; i++){ - var sp = all_checkbox[i].id.split('_'); - checkbox_ids.push(sp[1]); - } - return checkbox_ids; - }, vars.custom_id); - checkbox_ids.forEach(function(checkbox_id) { - vars.ids_for_check.push(checkbox_id); - }); - }); - - /* get all textarea id */ - casper.then(function() { - casper.echo('** Step 7-6: Get all textarea id. **'); - var textarea_ids = this.evaluate(function(custom_id) { - var all_textarea = document.getElementById('customData' + custom_id).querySelectorAll('textarea'); - var textarea_ids = []; - for(var i = 0; i < all_textarea.length; i++){ - var sp = all_textarea[i].id.split('_'); - textarea_ids.push(sp[1]); - } - return textarea_ids; - }, vars.custom_id); - textarea_ids.forEach(function(textarea_id) { - vars.ids_for_check.push(textarea_id); - }); - }); - - /* check all id exist */ - casper.then(function() { - casper.echo('** Step 7-7: Check all id exist. **'); - var id_no_duplicate = []; - for(var i = 0; i < vars.ids_for_check.length; i++) { - var exist_flag = false; - for(var j = 0; j < id_no_duplicate.length; j++) { - if(vars.ids_for_check[i] == id_no_duplicate[j]) { - exist_flag = true; - break - } - } - if(!exist_flag) { - id_no_duplicate.push(vars.ids_for_check[i]); - } - } - id_no_duplicate.sort(function(a, b) { - return a - b; - }); - test.assertEquals(vars.ids, id_no_duplicate); - }); - - casper.waitForSelector("#_qf_Contact_upload_view", function success() { - casper.echo('** Step 7-8: Save data. **'); - test.assertExists("#_qf_Contact_upload_view"); - this.click("#_qf_Contact_upload_view"); - }, function fail() { - test.assertExists("#_qf_Contact_upload_view"); - }); - - casper.wait(2000); - casper.then(function() { - test.assertDoesntExist('.crm-error'); - }); - - casper.run(function() { - test.done(); - }); -}); diff --git a/tests/casperjs/edit_contact.test.js b/tests/casperjs/edit_contact.test.js deleted file mode 100644 index eeedf044e..000000000 --- a/tests/casperjs/edit_contact.test.js +++ /dev/null @@ -1,181 +0,0 @@ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var first_name = makeid(5); -var last_name = makeid(5); - -var vars = { - baseURL : port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - first_name: first_name, - last_name: last_name, - user_email: first_name.toLowerCase() + last_name.toLowerCase() + '123@gmail.com', - user_phone: '09' + Math.floor(Math.random() * 100000000).toString() -}; - -casper.on('page.error', function(msg, trace) { - this.echo('Error: ' + msg, 'ERROR'); - for (var i = 0; i < trace.length; i++) { - var step = trace[i]; - this.echo(' ' + step.file + ' (line ' + step.line + ')', 'ERROR'); - } -}); - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Start testing...', function(test){ - // to drupal user page - casper.thenOpen(vars.baseURL + 'user', function() { - // this.capture('user_page.png'); - }); - // to crm contact page - casper.waitForSelector("#user-page-contact a", function success() { - var contact_url = this.evaluate(function() { - return document.querySelector("#user-page-contact a").href; - }); - this.thenOpen(vars.baseURL + contact_url.split('/').slice(3).join('/'), function() { - // this.capture('contact_page.png') - }); - }, function fail() { - test.assertExists("#user-page-contact a"); - }); - // to crm edit contact page - casper.waitForSelector("a.edit", function success() { - casper.echo('====================================='); - casper.echo('** Step 1: Edit Contact. **'); - casper.echo('====================================='); - var edit_url = this.evaluate(function() { - return document.querySelector("a.edit").href; - }); - this.thenOpen(vars.baseURL + edit_url.split('/').slice(3).join('/'), function() { - // this.capture('edit_page.png') - }); - }, function fail() { - test.assertExists("a.edit"); - }); - // last name - casper.waitForSelector("form[name=Contact] input[name='last_name']", function success() { - test.assertExists("form[name=Contact] input[name='last_name']"); - this.click("form[name=Contact] input[name='last_name']"); - }, function fail() { - test.assertExists("form[name=Contact] input[name='last_name']"); - }); - casper.waitForSelector("input[name='last_name']", function success() { - this.sendKeys("input[name='last_name']", vars.last_name); - }, function fail() { - test.assertExists("input[name='last_name']"); - }); - // first name - casper.waitForSelector("form[name=Contact] input[name='first_name']", function success() { - test.assertExists("form[name=Contact] input[name='first_name']"); - this.click("form[name=Contact] input[name='first_name']"); - }, function fail() { - test.assertExists("form[name=Contact] input[name='first_name']"); - }); - casper.waitForSelector("input[name='first_name']", function success() { - this.sendKeys("input[name='first_name']", vars.first_name); - }, function fail() { - test.assertExists("input[name='first_name']"); - }); - // email - casper.waitForSelector("form[name=Contact] input[name='email[1][email]']", function success() { - test.assertExists("form[name=Contact] input[name='email[1][email]']"); - this.click("form[name=Contact] input[name='email[1][email]']"); - }, function fail() { - test.assertExists("form[name=Contact] input[name='email[1][email]']"); - }); - casper.waitForSelector("input[name='email[1][email]']", function success() { - this.sendKeys("input[name='email[1][email]']", vars.user_email); - }, function fail() { - test.assertExists("input[name='email[1][email]']"); - }); - // change to cell phone - casper.waitForSelector("#phone_1_phone_type_id", function success() { - test.assertExists("#phone_1_phone_type_id"); - this.evaluate(function () { - document.querySelector("#phone_1_phone_type_id").selectedIndex = 1; - }) - }, function fail() { - test.assertExists("#phone_1_phone_type_id"); - }); - // phone - casper.waitForSelector("input[name='phone[1][phone]']", function success() { - this.sendKeys("input[name='phone[1][phone]']", vars.user_phone); - }, function fail() { - test.assertExists("input[name='phone[1][phone]']"); - }); - casper.then(function() { - // this.capture('edit_done.png'); - }); - casper.waitForSelector("form[name=Contact] input[type=submit][value='Save']", function success() { - test.assertExists("form[name=Contact] input[type=submit][value='Save']"); - this.click("form[name=Contact] input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form[name=Contact] input[type=submit][value='Save']"); - }); /* submit form */ - - // to personal information page - casper.wait(2000); - casper.then(function() { - casper.echo('====================================='); - casper.echo('** Step 2: Check If Contact Information Correct. **'); - casper.echo('====================================='); - // this.capture('personal_info.png'); - }) - // check name - casper.then(function() { - test.assertTitle(vars.first_name + ' ' + vars.last_name + ' | netiCRM'); - }); - // check email - casper.waitForSelector("#contact-summary > div.contact_details > div:nth-child(1) > div.contactCardLeft > table > tbody > tr:nth-child(1) > td:nth-child(2) > span > a", function success() { - test.assertExists("#contact-summary > div.contact_details > div:nth-child(1) > div.contactCardLeft > table > tbody > tr:nth-child(1) > td:nth-child(2) > span > a"); - var email = this.evaluate(function () { - return document.querySelector("#contact-summary > div.contact_details > div:nth-child(1) > div.contactCardLeft > table > tbody > tr:nth-child(1) > td:nth-child(2) > span > a").text; - }); - test.assertEquals(email, vars.user_email); - }, function fail() { - test.assertExists("#contact-summary > div.contact_details > div:nth-child(1) > div.contactCardLeft > table > tbody > tr:nth-child(1) > td:nth-child(2) > span > a"); - }); - // check phone - casper.waitForSelector("#contact-summary > div.contact_details > div:nth-child(1) > div.contactCardRight > table > tbody > tr > td.primary > span", function success() { - test.assertExists("#contact-summary > div.contact_details > div:nth-child(1) > div.contactCardRight > table > tbody > tr > td.primary > span"); - var phone = this.evaluate(function() { - return document.querySelector("#contact-summary > div.contact_details > div:nth-child(1) > div.contactCardRight > table > tbody > tr > td.primary > span").textContent; - }); - test.assertEquals(phone, vars.user_phone); - }, function fail() { - test.assertExists("#contact-summary > div.contact_details > div:nth-child(1) > div.contactCardRight > table > tbody > tr > td.primary > span"); - }); - casper.run(function() { - test.done(); - }); -}); \ No newline at end of file diff --git a/tests/casperjs/event_participant.test.js b/tests/casperjs/event_participant.test.js deleted file mode 100644 index 298990334..000000000 --- a/tests/casperjs/event_participant.test.js +++ /dev/null @@ -1,196 +0,0 @@ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var vars = { - baseURL: port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/' -}; - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - /* open CiviEvent Dashboard */ - casper.thenOpen(vars.baseURL + "civicrm/event?reset=1", function() { - casper.echo('====================================='); - casper.echo('** Step 1: Pick an Event. **'); - casper.echo('====================================='); - }); - - /* click sort by id */ - casper.waitForSelector('#event_status_id table thead th:first-child', function success() { - test.assertExists('#event_status_id table thead th:first-child'); - this.click('#event_status_id table thead th:first-child'); - }, function fail() { - test.assertExists('#event_status_id table thead th:first-child'); - }); - - /* click latest event */ - casper.waitForSelector('#event_status_id table tbody tr:last-child td.crm-event-title a', function success() { - test.assertExists('#event_status_id table tbody tr:last-child td.crm-event-title a'); - this.click('#event_status_id table tbody tr:last-child td.crm-event-title a'); - }, function fail() { - test.assertExists('#event_status_id table tbody tr:last-child td.crm-event-title a'); - }); - - casper.wait(2000); - casper.then(function() { - // this.capture('1_event_page.png'); - }); - - /* click Register New Participant */ - casper.waitForSelector('ul#actions li:nth-child(2) a', function success() { - casper.echo('====================================='); - casper.echo('** Step 2: Register New Participant To It. **'); - casper.echo('====================================='); - test.assertExists('ul#actions li:nth-child(2) a'); - this.click('ul#actions li:nth-child(2) a'); - }, function fail() { - test.assertExists('ul#actions li:nth-child(2) a'); - }); - - /* switch to new tab */ - casper.waitForPopup(0, function() { - }); - casper.withPopup(0, function() { - casper.wait(2000); - casper.then(function() { - // this.capture('2_New_Event_Registration.png'); - }) - - /* select 新增個人 */ - casper.waitForSelector("#profiles_1", function success() { - test.assertExists("#profiles_1"); - this.evaluate(function () { - document.querySelector("#profiles_1").selectedIndex = 1; - document.querySelector("#profiles_1").onchange(); // workaround for test - }); - }, function fail() { - test.assertExists("#profiles_1"); - }); - - /* filled up new contact form */ - casper.waitForSelector('form#Edit', function success() { - test.assertExists('form#Edit'); - this.fill('form#Edit', { - 'first_name': makeid(3), - 'last_name': makeid(3) - }, true); - }, function fail() { - test.assertExists('form#Edit'); - }); - casper.then(function() { - // this.capture('3_filled_up_contact.png'); - }); - - /* select Participant Status */ - casper.waitForSelector("#status_id", function success() { - test.assertExists("#status_id"); - this.evaluate(function () { - document.querySelector("#status_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#status_id"); - }); - - /* click submit */ - casper.waitForSelector("form#Participant input[type=submit][value='Save']", function success() { - test.assertExists("form#Participant input[type=submit][value='Save']"); - this.click("form#Participant input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form#Participant input[type=submit][value='Save']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('4_new_participant_done.png'); - test.assertDoesntExist('.crm-error'); - }); - - /* click edit event */ - casper.waitForSelector('table.selector .row-action .action-item:nth-child(2)', function success() { - casper.echo('====================================='); - casper.echo('** Step 3: Edit Event Participant. **'); - casper.echo('====================================='); - test.assertExists('table.selector .row-action .action-item:nth-child(2)'); - this.click('table.selector .row-action .action-item:nth-child(2)'); - }, function fail() { - test.assertExists('table.selector .row-action .action-item:nth-child(2)'); - }); - casper.wait(2000); - - /* click checkbox志工 */ - casper.waitForSelector("input[name='role_id[2]']", function success() { - test.assertExists("input[name='role_id[2]']"); - this.click("input[name='role_id[2]']"); - }, function fail() { - test.assertExists("input[name='role_id[2]']"); - }); - - /* change Registration Date */ - casper.waitForSelector("#register_date", function success() { - test.assertExists("#register_date"); - this.evaluate(function () { - document.querySelector("#register_date").value = "01/01/2020"; - }); - }, function fail() { - test.assertExists("#register_date"); - }); - casper.waitForSelector("#register_date_time", function success() { - test.assertExists("#register_date_time"); - this.sendKeys("#register_date_time", "12:00PM"); - }, function fail() { - test.assertExists("#register_date_time"); - }); - - /* select Participant Status */ - casper.waitForSelector("#status_id", function success() { - test.assertExists("#status_id"); - this.evaluate(function () { - document.querySelector("#status_id").selectedIndex = 2; - }); - }, function fail() { - test.assertExists("#status_id"); - }); - - /* click submit */ - casper.waitForSelector("form#Participant input[type=submit][value='Save']", function success() { - test.assertExists("form#Participant input[type=submit][value='Save']"); - this.click("form#Participant input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form#Participant input[type=submit][value='Save']"); - }); /* submit form */ - casper.wait(2000); - casper.then(function() { - // this.capture('5_edit_participant_done.png'); - test.assertDoesntExist('.crm-error'); - }); - - }); - - casper.run(function() { - test.done(); - }); - -}); \ No newline at end of file diff --git a/tests/casperjs/event_register.js b/tests/casperjs/event_register.js deleted file mode 100644 index ec4cb13b2..000000000 --- a/tests/casperjs/event_register.js +++ /dev/null @@ -1,268 +0,0 @@ -// phantom.casperPath = '/usr/local/lib/node_modules/casperjs'; -// phantom.injectJs('/usr/local/lib/node_modules/casperjs/bin/bootstrap.js'); - -var system = require('system'); -var port = system.env.RUNPORT; - -var url = (port == '80') ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port; -var item = { - url_prefix: url, - event_name_1: '無名額限制,填表完成送出', - event_name_2: '有名額限制,不開放候補', - event_name_3: '有名額限制,開放候補', - event_name_4: '有名額限制,需事先審核', - event_name_5: '無名額限制,需事先審核', - site_name: 'netiCRM' -} - -function getPageTitle(title){ - return title + " | "+item.site_name; -} - -// 1. Normal registration - -casper.test.begin('Event register page test ...',4,function(test){ - casper.start(item.url_prefix + '/civicrm/event/register?reset=1&action=preview&id=1', function() { - var page_title = getPageTitle(item.event_name_1); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - casper.capture("picture/event_register_1_0.png"); - }); - - casper.then(function(){ - test.assertExists('form#Register', 'Event register page: main form is exist.'); - var email = 'test@aipvo.com'; - this.fill('#Register',{ - 'email-5': email - },true); - this.capture("picture/event_register_1_1.png"); - test.assertField('email-5', email); - }); - - casper.waitForUrl('_qf_ThankYou_display',function(){ - this.capture("picture/event_register_1_2.png"); - test.assertExists('#help .msg-register-success'); - }); - - casper.run(function() { - test.done(); - }); - -}); - - -// 2. limit participants. Not fot waiting. - -casper.test.begin('Event register page test ...',6,function(test){ - casper.start(item.url_prefix + '/civicrm/event/register?reset=1&id=2', function() { - var page_title = getPageTitle(item.event_name_2); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_2_0.png"); - }); - - casper.then(function(){ - test.assertExists('form#Register', 'Event register page: main form is exist.'); - var email = 'test@kvien.com'; - this.fill('#Register',{ - 'email-5': email - },true); - this.capture("picture/event_register_2_1.png"); - test.assertField('email-5', email); - }); - - casper.waitForUrl('_qf_ThankYou_display', function(){ - test.assertExists('#help .msg-register-success'); - this.capture("picture/event_register_2_2.png"); - this.thenOpen(item.url_prefix + '/civicrm/event/register?reset=1&id=2'); - }); - - casper.then(function(){ - this.capture("picture/event_register_2_3.png"); - // test.assertExists('#help .msg-event-full'); - test.assertExists('.messages.status'); - text = this.evaluate( function(){ return __utils__.findOne('.messages.status').textContent; } ); - console.log('Messages : '+text); - test.assertMatch(text,/額滿|full/i,'Message contains "full" words.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -// limit participants. Not fot waiting. - -casper.test.begin('Event register page test ...',9,function(test){ - casper.start(item.url_prefix + '/civicrm/event/register?reset=1&id=3', function() { - var page_title = getPageTitle(item.event_name_3); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_3_0.png"); - }); - - - casper.then(function(){ - test.assertExists('form#Register', 'Event register page: main form is exist.'); - var email = 'test@ovoqnj.com'; - this.fill('#Register',{ - 'email-5': email - },true); - this.capture("picture/event_register_3_1.png"); - test.assertField('email-5', email); - }); - - casper.waitForUrl('_qf_ThankYou_display',function(){ - var page_title = getPageTitle(item.event_name_3); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_3_2.png"); - this.thenOpen(item.url_prefix + '/civicrm/event/register?reset=1&id=3'); - }); - - - casper.then(function(){ - var page_title = getPageTitle(item.event_name_3); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_3_3.png"); - var email = 'test2@soossovk.com'; - this.fill('#Register',{ - 'email-5': email - },true); - this.capture("picture/event_register_3_4.png"); - test.assertField('email-5', email); - }); - - casper.waitForUrl('_qf_ThankYou_display',function(){ - var page_title = getPageTitle(item.event_name_3); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_3_5.png"); - test.assertExists('#help p'); - text = this.evaluate( function(){ return __utils__.findOne('#help').textContent; } ); - console.log('Messages : '+text); - test.assertMatch(text,/候補|wait list/i,'Message contains "wait list" words.'); - }); - - casper.run(function() { - test.done(); - }); - -}); - -// event 4 : limit participants. Need approval. -// Checked-1 register success -// Checked-2 participant have get verify message. -// Checked-3 second participant message is correct. - -casper.test.begin('Event register page test ...',9,function(test){ - casper.start(item.url_prefix + '/civicrm/event/register?reset=1&id=4', function() { - var page_title = getPageTitle(item.event_name_4); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_4_0.png"); - }); - - // First register. - casper.then(function(){ - test.assertExists('form#Register', 'Event register page: main form is exist.'); - var email = 'test@vkioob.com'; - this.fill('#Register',{ - 'email-5': email - },true); - this.capture("picture/event_register_4_1.png"); - test.assertField('email-5', email); - }); - - casper.waitForUrl('_qf_ThankYou_display',function(){ - var page_title = getPageTitle(item.event_name_4); - // Checked-1 - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_4_2.png"); - // Checked-2 - test.assertExists('#help p'); - text = this.evaluate( function(){ return __utils__.findOne('#help').textContent; } ); - console.log('Messages : '+text); - test.assertMatch(text,/審核|reviewed/i,'Message contains "reviewed" words.'); - this.thenOpen(item.url_prefix + '/civicrm/event/register?reset=1&id=4'); - }); - - // Second register. - casper.then(function(){ - var page_title = getPageTitle(item.event_name_4); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_4_3.png"); - test.assertExists('.messages.status'); - // Checked-3 - text = this.evaluate( function(){ return __utils__.findOne('.messages.status').textContent; } ); - console.log('Messages : '+text); - test.assertMatch(text,/額滿|full/i,'Message contains "full" words.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -// event 5 : unlimit participants. Need approval. -// Checked-1 register success -// Checked-2 participant have get verify message. -// Checked-3 Second register success -// Checked-4 participant have get verify message. - -casper.test.begin('Event register page test ...',12,function(test){ - casper.start(item.url_prefix + '/civicrm/event/register?reset=1&id=5', function() { - var page_title = getPageTitle(item.event_name_5); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_5_0.png"); - }); - - // First register. - casper.then(function(){ - test.assertExists('form#Register', 'Event register page: main form is exist.'); - var email = 'test@vkioob.com'; - this.fill('#Register',{ - 'email-5': email - },true); - this.capture("picture/event_register_5_1.png"); - test.assertField('email-5', email); - }); - - casper.waitForUrl('_qf_ThankYou_display',function(){ - var page_title = getPageTitle(item.event_name_5); - // Checked-1 - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_5_2.png"); - // Checked-2 - test.assertExists('#help p'); - text = this.evaluate( function(){ return __utils__.findOne('#help').textContent; } ); - console.log('Messages : '+text); - test.assertMatch(text,/審核|reviewed/i,'Message contains "reviewed" words.'); - this.thenOpen(item.url_prefix + '/civicrm/event/register?reset=1&id=5'); - }); - - // Second register. - casper.then(function(){ - var page_title = getPageTitle(item.event_name_5); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_5_3.png"); - test.assertExists('.messages'); - // Checked-3 - var email = 'test2@xoooke.com'; - this.fill('#Register',{ - 'email-5': email - },true); - this.capture("picture/event_register_5_4.png"); - test.assertField('email-5', email); - - }); - - casper.waitForUrl('_qf_ThankYou_display',function(){ - var page_title = getPageTitle(item.event_name_5); - test.assertTitle(page_title,'Event register page (' + page_title + ')'); - this.capture("picture/event_register_5_5.png"); - test.assertExists('#help p'); - text = this.evaluate( function(){ return __utils__.findOne('#help').textContent; } ); - console.log('Messages : '+text); - test.assertMatch(text,/審核|reviewed/i,'Message contains "reviewed" words.'); - }); - - casper.run(function() { - test.done(); - }); -}); - diff --git a/tests/casperjs/files/import.csv b/tests/casperjs/files/import.csv deleted file mode 100644 index a5710fb27..000000000 --- a/tests/casperjs/files/import.csv +++ /dev/null @@ -1,3 +0,0 @@ -李,小明,xxx@allaove.coo,0912345678,健康路一段123號,100,一般捐款,1,2018-01-01 01:01:01 -王,小華,yyy@blloblo.poo,0923-456-789,康樂街999號,200,一般捐款,2,2018-02-02 02:02:02 -Floria,Bob,zzz@fllalivi.xoo,04-12345678,no.144 Happiness st. Santiaco,300,一般捐款,2018-03-03 03:03:03 \ No newline at end of file diff --git a/tests/casperjs/googletest.js b/tests/casperjs/googletest.js deleted file mode 100644 index b3bdcd2d5..000000000 --- a/tests/casperjs/googletest.js +++ /dev/null @@ -1,22 +0,0 @@ -// googletesting.js -casper.test.begin('Google search retrieves 10 or more results', 5, function suite(test) { - casper.start("http://www.google.fr/", function() { - test.assertTitle("Google", "google homepage title is the one expected"); - test.assertExists('form[action="/search"]', "main form is found"); - this.fill('form[action="/search"]', { - q: "casperjs" - }, true); - }); - - casper.then(function() { - test.assertTitle("casperjs - Google 搜尋", "google title is ok"); - test.assertUrlMatch(/q=casperjs/, "search term has been submitted"); - test.assertEval(function() { - return __utils__.findAll("h3.r").length >= 10; - }, "google search for \"casperjs\" retrieves 10 or more results"); - }); - - casper.run(function() { - test.done(); - }); -}); diff --git a/tests/casperjs/import.js b/tests/casperjs/import.js deleted file mode 100644 index 3f16e6465..000000000 --- a/tests/casperjs/import.js +++ /dev/null @@ -1,193 +0,0 @@ -// phantom.casperPath = '/usr/local/lib/node_modules/casperjs'; -// phantom.injectJs('/usr/local/lib/node_modules/casperjs/bin/bootstrap.js'); - -var system = require('system'); -var fs = require('fs'); -var port = system.env.RUNPORT; - -var pathParts = fs.absolute(casper.test.currentTestFile).split('/'); -pathParts.pop(); -var currentTestFolder = pathParts.join('/') + "/"; - -var url = (port == '80') ? 'https://127.0.0.1/' : 'http://127.0.0.1:' + port + '/'; -var item = { - url_prefix: url, - task: [ - { - type: 'contact', - url: 'civicrm/import/contact?reset=1', - fields: { - 'mapper[0][0]': 'last_name', - 'mapper[1][0]': 'first_name', - 'mapper[2][0]': 'email', - 'mapper[2][1]': '1', - }, - form_name: 'DataSource', - /* - preview_fields: { - 'newGroupName': 'Test from Casper', - }, - */ - }, - { - type: 'contribute', - url: 'civicrm/contribute/import?reset=1', - fields: { - 'mapper[0][0]': 'last_name', - 'mapper[1][0]': 'first_name', - 'mapper[2][0]': 'email', - 'mapper[2][1]': '1', - 'mapper[5][0]': 'contribution_type', - 'mapper[6][0]': 'total_amount', - } - }, - { - type: 'activity', - url: 'civicrm/import/activity?reset=1', - fields: { - 'mapper[0][0]': 'last_name', - 'mapper[1][0]': 'first_name', - 'mapper[2][0]': 'email', - 'mapper[5][0]': 'activity_subject', - 'mapper[7][0]': 'activity_type_id', - 'mapper[8][0]': 'activity_date_time', - } - }, - { - type: 'participant', - url: 'civicrm/event/import?reset=1', - fields: { - 'mapper[0][0]': 'last_name', - 'mapper[1][0]': 'first_name', - 'mapper[2][0]': 'email', - 'mapper[7][0]': 'event_id', - } - }, - { - type: 'member', - url: 'civicrm/member/import?reset=1', - fields: { - 'mapper[0][0]': 'last_name', - 'mapper[1][0]': 'first_name', - 'mapper[2][0]': 'email', - 'mapper[7][0]': 'membership_type_id', - 'mapper[8][0]': 'membership_start_date', - } - }, - ], - // site_name: 'netiCRM' -} - -// 0. Login -casper.test.begin('Page output correct test', 1, function suite(test) { - casper.start(item.url_prefix, function() { - casper.capture(currentTestFolder+"picture/import_task_login_0.png"); - test.assertExists('#user-login-form', "Found login form"); - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }); - - casper.waitForSelector('body.logged-in', function(test){ - casper.capture(currentTestFolder+"picture/import_task_login_1.png"); - }); - - casper.run(function() { - test.done(); - }); -}); - -// 1. Import Tasks - -item.task.forEach(function(task, i){ - - casper.test.begin('Import task '+i+' : '+task.type, 3, function(test){ - casper.start(item.url_prefix + task.url, function() { - casper.echo('====================================='); - casper.echo('** Step 1: Enter Upload File Page. **'); - casper.echo('====================================='); - casper.waitForSelector('#skipColumnHeader', function(){ - test.assertExists('#skipColumnHeader', 'Skip Column Header Field is Exist.'); - }); - casper.capture(currentTestFolder+"picture/import_task_"+i+"_1.png"); - }); - - casper.then(function(){ - casper.echo(' - Upload File.'); - casper.page.uploadFile('#uploadFile', currentTestFolder+'files/import.csv'); - casper.capture(currentTestFolder+"picture/import_task_"+i+"_2.png"); - }); - - if (task.type == 'contribute') { - casper.then(function(){ - casper.echo(' - Select import mode.'); - var form_name = (task.form_name ? task.form_name : 'UploadFile'); - casper.click('input[name="onDuplicate"][value="1"]'); - }); - } - - casper.then(function(){ - casper.echo(' - Click next button.'); - var form_name = (task.form_name ? task.form_name : 'UploadFile'); - casper.click('input[name="_qf_'+form_name+'_upload"]'); - casper.capture(currentTestFolder+"picture/import_task_"+i+"_3.png"); - }); - - // casper.waitForSelector('.crm-error', function(){ - // text = this.evaluate( function(){ return __utils__.findOne('.crm-error li').textContent; } ); - // console.log('Messages : '+text); - // }); - - casper.waitForUrl(/_qf_MapField_display/, function(){ - casper.echo('=================================='); - casper.echo('** Step 2: Enter MapField page. **'); - casper.echo('=================================='); - test.assertExists('#_qf_MapField_next-top', 'Success enter MapField Page!!!'); - casper.capture(currentTestFolder+"picture/import_task_"+i+"_4.png"); - }); - - casper.then(function(){ - if(task.fields){ - casper.echo(' - Select the mapping field.'); - this.fill('form#MapField', task.fields, false); - } - casper.capture(currentTestFolder+"picture/import_task_"+i+"_5.png"); - casper.echo(' - Click next button.'); - this.click('input[name="_qf_MapField_next"]'); - }) - - casper.waitForUrl(/_qf_Preview_display/, function(){ - casper.echo('================================='); - casper.echo('** Step 3: Enter Preview page. **'); - casper.echo('================================='); - casper.capture(currentTestFolder+"picture/import_task_"+i+"_6.png"); - test.assertExists('input[name="_qf_Preview_next"]', 'Success enter Preview Page!!!'); - }); -/* - casper.then(function(){ - // Click confirm Botton - casper.page.onConfirm = function(msg) { - casper.echo('CONFIRM: ' + msg); - casper.echo('Click Confirm Botton;'); - return true; - }; - casper.click('input[name="_qf_Preview_next"]'); - casper.capture(currentTestFolder+"picture/import_task_"+i+"_5.png"); - }); - - casper.waitForUrl(/_qf_Summary_display/, function(){ - casper.capture(currentTestFolder+"picture/import_task_0_6.png"); - test.assertExists('#_qf_Summary_next-top', 'Success enter Summary Page!!!'); - }, function timeout(){ - casper.capture(currentTestFolder+"picture/import_task_"+i+"_6_.png"); - casper.echo('Fail to import.'); - }, 10000); -*/ - casper.run(function() { - test.done(); - }); - - }); - -}) diff --git a/tests/casperjs/new_contribution.test.js b/tests/casperjs/new_contribution.test.js deleted file mode 100644 index 38bc3b27e..000000000 --- a/tests/casperjs/new_contribution.test.js +++ /dev/null @@ -1,352 +0,0 @@ -/* basic setting */ -var system = require('system'); -var port = system.env.RUNPORT; - -function makeid(length) { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var charactersLength = characters.length; - for ( var i = 0; i < length; i++ ) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -var vars = { - baseURL: port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/' -}; - -casper.test.begin('Resurrectio test', function(test) { - casper.start(vars.baseURL, function() { - casper.echo('====================================='); - casper.echo('** Step 0: Login. **'); - casper.echo('====================================='); - // this.capture('login.png'); - }); - - casper.waitForSelector("#user-login-form", function success() { - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }, function fail() { - test.assertExists("#user-login-form", 'Login form exist.'); - }); - - casper.run(function() { - test.done(); - }); -}); - -casper.test.begin('Start testing...', function(test) { - - /* open new contribution page */ - casper.thenOpen(vars.baseURL + "civicrm/contribute/add?reset=1&action=add&context=standalone", function() { - casper.echo('====================================='); - casper.echo('** Step 1: New Contribution. **'); - casper.echo('====================================='); - }); - - /* select 新增個人 */ - casper.waitForSelector("#profiles_1", function success() { - test.assertExists("#profiles_1"); - this.evaluate(function () { - document.querySelector("#profiles_1").selectedIndex = 1; - document.querySelector("#profiles_1").onchange(); // workaround for test - }); - }, function fail() { - test.assertExists("#profiles_1"); - }); - - /* filled up new contact form */ - casper.waitForSelector('form#Edit', function success() { - test.assertExists('form#Edit'); - this.fill('form#Edit', { - 'first_name': makeid(3), - 'last_name': makeid(3) - }, true); - }, function fail() { - test.assertExists('form#Edit'); - }); - - /* select Contribution Type */ - casper.waitForSelector("#contribution_type_id", function success() { - test.assertExists("#contribution_type_id"); - this.evaluate(function () { - document.querySelector("#contribution_type_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#contribution_type_id"); - }); - - /* sendKeys to Total Amount */ - casper.waitForSelector("#total_amount", function success() { - test.assertExists("#total_amount"); - this.sendKeys("#total_amount", '100'); - }, function fail() { - test.assertExists("#total_amount"); - }); - - /* sendKeys to Source */ - casper.waitForSelector("#source", function success() { - test.assertExists("#source"); - this.sendKeys("#source", 'hand to hand'); - }, function fail() { - test.assertExists("#source"); - }); - - /* select received date */ - casper.waitForSelector("#receive_date", function success() { - test.assertExists("#receive_date"); - this.evaluate(function () { - document.querySelector("#receive_date").value = "01/01/2020"; - }); - }, function fail() { - test.assertExists("#receive_date"); - }); - casper.waitForSelector("#receive_date_time", function success() { - test.assertExists("#receive_date_time"); - this.sendKeys("#receive_date_time", "12:00PM"); - }, function fail() { - test.assertExists("#receive_date_time"); - }); - - /* select Paid By */ - casper.waitForSelector('#payment_instrument_id', function success() { - test.assertExists('#payment_instrument_id'); - this.evaluate(function () { - document.querySelector("#payment_instrument_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists('#payment_instrument_id'); - }); - - /* sendKeys to Transaction ID */ - casper.waitForSelector("#trxn_id", function success() { - test.assertExists("#trxn_id"); - this.sendKeys("#trxn_id", makeid(8)); - }, function fail() { - test.assertExists("#trxn_id"); - }); - - /* click Receipt */ - casper.waitForSelector('#have_receipt', function success() { - test.assertExists('#have_receipt'); - this.click('#have_receipt'); - }, function fail() { - test.assertExists('#have_receipt'); - }); - - /* select receipt date */ - casper.waitForSelector("#receipt_date", function success() { - test.assertExists("#receipt_date"); - this.evaluate(function () { - document.querySelector("#receipt_date").value = "01/01/2020"; - }); - }, function fail() { - test.assertExists("#receipt_date"); - }); - casper.waitForSelector("#receipt_date_time", function success() { - test.assertExists("#receipt_date_time"); - this.sendKeys("#receipt_date_time", "12:00PM"); - }, function fail() { - test.assertExists("#receipt_date_time"); - }); - - /* 收據資訊 */ - - /* click 需要(請寄給我紙本收據) */ - casper.waitForSelector('#CIVICRM_QFID_1_4', function success() { - test.assertExists('#CIVICRM_QFID_1_4'); - this.click('#CIVICRM_QFID_1_4'); - }, function fail() { - test.assertExists('#CIVICRM_QFID_1_4'); - }); - - /* sendKeys to 收據抬頭 */ - casper.waitForSelector("#custom_2_-1", function success() { - test.assertExists("#custom_2_-1"); - this.sendKeys("#custom_2_-1", makeid(5)); - }, function fail() { - test.assertExists("#custom_2_-1"); - }); - - /* sendKeys to 報稅憑證 */ - casper.waitForSelector("#custom_3_-1", function success() { - test.assertExists("#custom_3_-1"); - this.sendKeys("#custom_3_-1", makeid(5)); - }, function fail() { - test.assertExists("#custom_3_-1"); - }); - - /* sendKeys 捐款徵信名稱 */ - casper.waitForSelector("#custom_4_-1", function success() { - test.assertExists("#custom_4_-1"); - this.sendKeys("#custom_4_-1", makeid(5)); - }, function fail() { - test.assertExists("#custom_4_-1"); - }); - - /* click Additional Details */ - casper.waitForSelector('#AdditionalDetail', function success() { - test.assertExists('#AdditionalDetail'); - this.click('#AdditionalDetail'); - }, function fail() { - test.assertExists('#AdditionalDetail'); - }); - - /* select Contribution Page */ - casper.waitForSelector("#contribution_page_id", function success() { - test.assertExists("#contribution_page_id"); - this.evaluate(function () { - var num = document.querySelector("#contribution_page_id").options.length; - document.querySelector("#contribution_page_id").selectedIndex = num - 1; // choose last one - }); - }, function fail() { - test.assertExists("#contribution_page_id"); - }); - - /* click Honoree Information */ - casper.waitForSelector('#Honoree', function success() { - test.assertExists('#Honoree'); - this.click('#Honoree'); - }, function fail() { - test.assertExists('#Honoree'); - }); - - /* click 致敬 */ - casper.waitForSelector('#CIVICRM_QFID_1_2', function success() { - test.assertExists('#CIVICRM_QFID_1_2'); - this.click('#CIVICRM_QFID_1_2'); - }, function fail() { - test.assertExists('#CIVICRM_QFID_1_2'); - }); - - /* select Prefix */ - casper.waitForSelector("#honor_prefix_id", function success() { - test.assertExists("#honor_prefix_id"); - this.evaluate(function () { - document.querySelector("#honor_prefix_id").selectedIndex = 1; - }); - }, function fail() { - test.assertExists("#honor_prefix_id"); - }); - - /* sendKeys to First Name */ - casper.waitForSelector("#honor_first_name", function success() { - test.assertExists("#honor_first_name"); - this.sendKeys("#honor_first_name", makeid(3)); - }, function fail() { - test.assertExists("#honor_first_name"); - }); - - /* sendKeys to Last Name */ - casper.waitForSelector("#honor_last_name", function success() { - test.assertExists("#honor_last_name"); - this.sendKeys("#honor_last_name", makeid(3)); - }, function fail() { - test.assertExists("#honor_last_name"); - }); - - casper.then(function() { - // this.capture('1_form_done.png'); - }); - - /* click Save */ - casper.waitForSelector("form#Contribution input[type=submit][value='Save']", function success() { - test.assertExists("form#Contribution input[type=submit][value='Save']"); - this.click("form#Contribution input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form#Contribution input[type=submit][value='Save']"); - }); /* submit form */ - casper.wait(2000); - - casper.then(function() { - // this.capture('2_new_contribution_done.png'); - }); - - /* check success message */ - casper.waitForSelector(".messages", function success() { - casper.echo('====================================='); - casper.echo('** Step 2: Check If New Contribution Success. **'); - casper.echo('====================================='); - test.assertExists(".messages"); - var message = this.evaluate(function () { - return document.querySelector(".messages").textContent; - }); - test.assertEquals(message.trim(), "The contribution record has been saved."); - }, function fail() { - test.assertExists(".messages"); - }); - - /* click edit contribution */ - casper.waitForSelector('table.selector .row-action .action-item:nth-child(2)', function success() { - casper.echo('====================================='); - casper.echo('** Step 3: Edit Contribution. **'); - casper.echo('====================================='); - test.assertExists('table.selector .row-action .action-item:nth-child(2)'); - this.click('table.selector .row-action .action-item:nth-child(2)'); - }, function fail() { - test.assertExists('table.selector .row-action .action-item:nth-child(2)'); - }); - casper.wait(2000); - - /* select received date */ - casper.waitForSelector("#receive_date", function success() { - test.assertExists("#receive_date"); - this.evaluate(function () { - document.querySelector("#receive_date").value = "01/01/2020"; - }); - }, function fail() { - test.assertExists("#receive_date"); - }); - casper.waitForSelector("#receive_date_time", function success() { - test.assertExists("#receive_date_time"); - this.sendKeys("#receive_date_time", "12:00PM"); - }, function fail() { - test.assertExists("#receive_date_time"); - }); - - /* clear receipt date */ - casper.waitForSelector('.crm-clear-link a', function success() { - test.assertExists('.crm-clear-link a'); - this.click('.crm-clear-link a'); - }, function fail() { - test.assertExists('.crm-clear-link a'); - }); - - casper.then(function() { - // this.capture('3_edit_form_done.png'); - }); - - /* click submit */ - casper.waitForSelector("form#Contribution input[type=submit][value='Save']", function success() { - test.assertExists("form#Contribution input[type=submit][value='Save']"); - this.click("form#Contribution input[type=submit][value='Save']"); - }, function fail() { - test.assertExists("form#Contribution input[type=submit][value='Save']"); - }); /* submit form */ - casper.wait(2000); - - /* check success message */ - casper.waitForSelector(".messages", function success() { - casper.echo('====================================='); - casper.echo('** Step 4: Check If Edit Contribution Success. **'); - casper.echo('====================================='); - test.assertExists(".messages"); - var message = this.evaluate(function () { - return document.querySelector(".messages").textContent; - }); - test.assertEquals(message.trim(), "The contribution record has been saved."); - }, function fail() { - test.assertExists(".messages"); - }); - - casper.then(function() { - // this.capture('4_edit_done.png'); - }); - - casper.run(function() { - test.done(); - }); -}); diff --git a/tests/casperjs/pages.js b/tests/casperjs/pages.js deleted file mode 100644 index 1e01bcf5f..000000000 --- a/tests/casperjs/pages.js +++ /dev/null @@ -1,124 +0,0 @@ -casper.options.waitTimeout = 10000; - -var system = require('system'); -var port = system.env.RUNPORT; - -var vars = { - testNum: 0, // later calc - baseURL : port == '80' ? 'http://127.0.0.1/' : 'http://127.0.0.1:' + port + '/', - siteName: 'netiCRM', - -// you should add your own testing variables below - url: [ - {title:'New Individual', url:'civicrm/contact/add?reset=1&ct=Individual'}, - {title:'Custom Data', url:'civicrm/admin/custom/group?reset=1'}, - {title:'New Activity', url:'civicrm/activity?reset=1&action=add&context=standalone'}, - {title:'Administer CiviCRM', url:'civicrm/admin?reset=1'}, - {title:'CiviCRM Home', url:'civicrm/dashboard'}, - {title:'Custom Data', url:'civicrm/admin/custom/group?reset=1'}, - {title:'CiviCRM Profile', url:'civicrm/admin/uf/group?reset=1'}, - {title:'CiviCRM Home', url:'civicrm/civicrm/admin/configtask?reset=1'}, - {title:'Synchronize Users to Contacts', url:'civicrm/admin/synchUser?reset=1'}, - {title:'Find Contacts', url:'civicrm/contact/search?reset=1'}, - {title:'New Individual', url:'civicrm/contact/add?reset=1&ct=Individual'}, - {title:'New Organization', url:'civicrm/contact/add?reset=1&ct=Organization'}, - {title:'New Household', url:'civicrm/contact/add?reset=1&ct=Household'}, - {title:'Activities', url:'civicrm/activity/add?atype=3&action=add&reset=1&context=standalone'}, - {title:'Import Contacts', url:'civicrm/import/contact?reset=1'}, - {title:'Manage Groups', url:'civicrm/group?reset=1'}, - {title:'Manage Tags (Categories)', url:'civicrm/admin/tag?reset=1'}, - {title:'New Activity', url:'civicrm/activity?reset=1&action=add&context=standalone'}, - {title:'Find Activities', url:'civicrm/activity/search?reset=1'}, - {title:'Import Activities', url:'civicrm/import/activity?reset=1'}, - {title:'Find and Merge Duplicate Contacts', url:'civicrm/contact/deduperules?reset=1'}, - {title:'Relationship Types', url:'civicrm/admin/reltype?reset=1'}, - {title:'CiviCRM Profile', url:'civicrm/admin/uf/group?reset=1'}, - {title:'Custom Data', url:'civicrm/admin/custom/group?reset=1'}, - {title:'CiviContribute Dashboard', url:'civicrm/contribute?reset=1'}, - {title:'Payment Instrument Options', url:'civicrm/admin/options/payment_instrument?group=payment_instrument&reset=1'}, - {title:'New Contribution', url:'civicrm/contribute/add?reset=1&action=add&context=standalone'}, - {title:'Find Contributions', url:'civicrm/contribute/search?reset=1'}, - {title:'Import Contributions', url:'civicrm/contribute/import?reset=1'}, - {title:'CiviPledge', url:'civicrm/pledge?reset=1'}, - {title:'New Pledge', url:'civicrm/pledge/add?reset=1&action=add&context=standalone'}, - {title:'Find Pledges', url:'civicrm/pledge/search?reset=1'}, - {title:'Title and Settings', url:'civicrm/admin/contribute/add?reset=1&action=add'}, - {title:'Manage Contribution Pages', url:'civicrm/admin/contribute?reset=1'}, - {title:'Personal Campaign Pages', url:'civicrm/admin/pcp?reset=1'}, - {title:'Manage Premiums', url:'civicrm/admin/contribute/managePremiums?reset=1'}, - {title:'New Price Set', url:'civicrm/admin/price?reset=1&action=add'}, - {title:'Price Sets', url:'civicrm/admin/price?reset=1'}, - {title:'Contribution Types', url:'civicrm/admin/contribute/contributionType?reset=1'}, - {title:'CiviEvent Dashboard', url:'civicrm/event?reset=1'}, - {title:'Event Type Options', url:'civicrm/admin/options/event_type?group=event_type&reset=1'}, - {title:'Participant Status', url:'civicrm/admin/participant_status?reset=1'}, - {title:'Participant Role Options', url:'civicrm/admin/options/participant_role?group=participant_role&reset=1'}, - {title:'Register New Participant', url:'civicrm/participant/add?reset=1&action=add&context=standalone'}, - {title:'Find Participants', url:'civicrm/event/search?reset=1'}, - {title:'Import Participants', url:'civicrm/event/import?reset=1'}, - {title:'New Event', url:'civicrm/event/add?reset=1&action=add'}, - {title:'CiviEvent Dashboard', url:'civicrm/event/manage?reset=1'}, - {title:'Event Templates', url:'civicrm/admin/eventTemplate?reset=1'}, - {title:'New Price Set', url:'civicrm/admin/price?reset=1&action=add'}, - {title:'Price Sets', url:'civicrm/admin/price?reset=1'}, - {title:'Find Mailings', url:'civicrm/mailing/browse?reset=1&scheduled=true'}, - {title:'New Mailing', url:'civicrm/mailing/send?reset=1'}, - {title:'Draft and Unscheduled Mailings', url:'civicrm/mailing/browse/unscheduled?reset=1&scheduled=false'}, - {title:'Scheduled and Sent Mailings', url:'civicrm/mailing/browse/scheduled?reset=1&scheduled=true'}, - {title:'Archived Mailings', url:'civicrm/mailing/browse/archived?reset=1'}, - {title:'Headers, Footers, and Automated Messages', url:'civicrm/admin/component?reset=1'}, - {title:'Message Templates', url:'civicrm/admin/messageTemplates?reset=1'}, - {title:'FROM Email Addresses', url:'civicrm/admin/from_email_address?&reset=1&action=browse'}, - {title:'Email Greeting Options', url:'civicrm/admin/options/email_greeting?group=email_greeting&reset=1'}, - {title:'CiviMember', url:'civicrm/member?reset=1'}, - {title:'New Member', url:'civicrm/member/add?reset=1&action=add&context=standalone'}, - {title:'Find Members', url:'civicrm/member/search?reset=1'}, - {title:'Import Memberships', url:'civicrm/member/import?reset=1'}, - {title:'Membership Types', url:'civicrm/admin/member/membershipType?reset=1'}, - {title:'Membership Status Rules', url:'civicrm/admin/member/membershipStatus?reset=1'}, - {title:'CiviCRM Reports', url:'civicrm/report/list?reset=1'}, - {title:'Create Reports from Templates', url:'civicrm/admin/report/template/list?reset=1'}, - {title:'Registered Templates', url:'civicrm/admin/report/options/report_template?reset=1'}, - {title:'Search Builder', url:'civicrm/contact/search/builder?reset=1'}, - {title:'全文搜尋', url:'civicrm/contact/search/custom?csid=15&reset=1'}, - {title:'Advanced Search', url:'civicrm/contact/search/advanced?reset=1'} - ], -}; -vars.testNum = vars.url.length*2+1; - - -var lookup_title = function(u){ - for(var i in vars.url){ - if(vars.url[i].url == u){ - return vars.url[i].title; - } - } -}; - -casper.test.begin('Page output correct test', vars.testNum, function suite(test) { - casper.start(vars.baseURL, function() { - test.assertExists('#user-login-form', "Found login form"); - this.fill('#user-login-form', { - 'name':'admin', - 'pass':'123456' - }, true); - }); - - casper.waitForSelector('body.logged-in', function(){ - for(var i in vars.url){ - casper.thenOpen(vars.baseURL + vars.url[i].url, function(obj){ - if(obj.url){ - var url = obj.url.replace(vars.baseURL, ''); - var title = lookup_title(url); - var full_title = title + ' | ' + vars.siteName; - test.assertTitle(full_title, title + ' should match page title'); - test.assertDoesntExist('.error-ci', title + ' page have no error'); - } - }); - } - }); - - casper.run(function(){ - test.done(); - }); -}); From 3704147dfc060e2210a6bf00ac2834576c2951e0 Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Mon, 15 Apr 2024 12:46:23 +0800 Subject: [PATCH 2/8] refs #40367, fixes country dependent ajax compatible php 8.x, json parse --- CRM/Core/Page/AJAX/Location.php | 2 +- packages/jquery/plugins/jquery.chainedSelects.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Core/Page/AJAX/Location.php b/CRM/Core/Page/AJAX/Location.php index 104657758..43c768615 100644 --- a/CRM/Core/Page/AJAX/Location.php +++ b/CRM/Core/Page/AJAX/Location.php @@ -94,7 +94,7 @@ function getPermissionedLocation() { CRM_Utils_System::civiExit(); } - function jqState($config) { + public static function jqState($config) { $elements = array(); if (!isset($_GET['_value']) || empty($_GET['_value']) || !CRM_Utils_Type::validate($_GET['_value'], 'Positive', FALSE)) { echo json_encode($elements); diff --git a/packages/jquery/plugins/jquery.chainedSelects.js b/packages/jquery/plugins/jquery.chainedSelects.js index 309217f36..9e5f0f49e 100644 --- a/packages/jquery/plugins/jquery.chainedSelects.js +++ b/packages/jquery/plugins/jquery.chainedSelects.js @@ -49,8 +49,8 @@ jQuery.fn.chainSelect = function( target, url, settings ) ajaxCallback = function(data, textStatus) { - $(target).html("");//clear old options - data = eval(data);//get json array + $(target).html(""); //clear old options + data = JSON.parse(data); //get json array if ( data != null ) { for (i = 0; i < data.length; i++) { $(target).get(0).add(new Option(data[i].name, data[i].value), document.all ? i : null); From b1356549fb90c3e2a264977d1058e39d2eb36c52 Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Mon, 15 Apr 2024 12:59:54 +0800 Subject: [PATCH 3/8] refs #39638, remove php5 ci testing --- .drone.yml | 88 ++---------------------------------------------------- 1 file changed, 3 insertions(+), 85 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7ed57731a..60d227fd9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,86 +1,3 @@ ---- -kind: pipeline -type: docker -name: php5 - -steps: -- name: submodules - image: alpine/git - pull: if-not-exists - commands: - - git submodule update --init --recursive -- name: neticrm ci php 5 - image: rg.netivism.com.tw/netivism/docker-neticrm-ci:drone-php5 - pull: always - environment: - DRUPAL: "7" - TZ: Asia/Taipei - RUNPORT: 8080 - DRUPAL_ROOT: /var/www/html - CIVICRM_TEST_DSN: "mysqli://root@localhost/neticrmci" - commands: - - /usr/bin/supervisord & - - /init.sh - - cd $DRUPAL_ROOT && drush status | grep version - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit CRM/Utils/TypeTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit CRM/Core/Payment/ALLPAYTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit CRM/Core/Payment/SPGATEWAYTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit CRM/Core/Payment/LinePayTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit CRM/Core/Payment/TapPayTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit api/v3/ContributionRecurTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit api/v3/GetOptionsTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit --group CItesting api/v3/PhoneTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit --group CItesting api/v3/ParticipantTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit --group CItesting api/v3/ActivityTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/phpunit && phpunit --group CItesting api/v3/MembershipTest.php - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/batch_action.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/page.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/add_contact.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/add_contribution_page.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/add_event.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/edit_contact.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/custom_data.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/contribution_allpay.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/contribution_allpay_atm.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/contribution_allpay_barcode.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/new_contribution.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/advanced_search.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/add_group.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/add_membership_type.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/import.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/event_normal_register.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/event_limit_nowait_register.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/event_limit_wait_register.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/event_limit_approval_register.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/event_unlimit_approval_register.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/event_participant.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/edit_mailing.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/contribution_spgateway.spec.js - - cd $DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/contribution_booster.spec.js -- name: notify - image: drillster/drone-email - settings: - from.address: - from_secret: email_from_addr - from.name: - from_secret: email_from_name - host: - from_secret: email_host - port: - from_secret: email_port - username: - from_secret: email_username - password: - from_secret: email_password - recipients: - from_secret: email_recipients - recipients_only: true - skip_verify: true - when: - status: - - failure - - --- kind: pipeline type: docker @@ -164,8 +81,6 @@ steps: when: status: - failure -depends_on: -- php5 --- kind: pipeline @@ -250,6 +165,8 @@ steps: when: status: - failure +depends_on: +- php7 --- kind: pipeline @@ -362,4 +279,5 @@ steps: skip_verify: true depends_on: - php7 +- php8 - php8-d10 \ No newline at end of file From 414459810c3ede37dd9defa0ace7cae2bd11c856 Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Mon, 15 Apr 2024 13:32:00 +0800 Subject: [PATCH 4/8] refs #40248, change readme about support version --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 3c8abb577..350376c5a 100644 --- a/README.md +++ b/README.md @@ -55,10 +55,7 @@ We take the security of this project very seriously. If you believe you have fou ## Supported Versions -| Version | Supported | -| ------- | ------------------ | -| 5.0 | :white_check_mark: | -| < 5 | :x: | +Only support latest release version. ### License From 20f1ce56795bfeeebb55a8680cc02a623cc6385d Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Mon, 15 Apr 2024 13:32:40 +0800 Subject: [PATCH 5/8] refs #40339, add MItake response body when error --- CRM/SMS/Provider/Mitake.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CRM/SMS/Provider/Mitake.php b/CRM/SMS/Provider/Mitake.php index c8a315fcf..18cab002f 100644 --- a/CRM/SMS/Provider/Mitake.php +++ b/CRM/SMS/Provider/Mitake.php @@ -208,6 +208,9 @@ protected function doRequest($requestUri, $request = array()) { $response['raw'] = $responseBody; $response['body'] = $this->formatResponse($responseBody); $response['success'] = $response['body']['success']; + if (empty($response['body']['success'])) { + CRM_Core_Error::debug_var('mitake_send_error', $responseBody); + } } curl_close($ch); From 0143c03b141e8386436e6ad8162bb44e62489dbc Mon Sep 17 00:00:00 2001 From: poliphilochu Date: Tue, 16 Apr 2024 11:27:54 +0800 Subject: [PATCH 6/8] refs #37300. Set attachment image height to auto for consistency --- css/civicrm.css | 1 + 1 file changed, 1 insertion(+) diff --git a/css/civicrm.css b/css/civicrm.css index 3d230c183..987683231 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -1750,6 +1750,7 @@ div.block-civicrm li, .crm-container ul li, .crm-container ul.treeview li { /* Attachment */ .crm-container .attachments table .current-attachments img { max-width: 18%; + height: auto; } .crm-container .attachments-upload-your-own-image-row ~ .attachments-form-file-row, .crm-container .crm-contribution-campaign-form-block .attachments-upload-your-own-image-row ~ .attachments-form-file-row { From 81b0ea0e867266f220139e24037077875556a618 Mon Sep 17 00:00:00 2001 From: poliphilochu Date: Tue, 16 Apr 2024 12:54:53 +0800 Subject: [PATCH 7/8] refs #40372. Replace align center with CSS for HTML5 compliance --- css/civicrm.css | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/css/civicrm.css b/css/civicrm.css index 987683231..5c41431dc 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -5505,8 +5505,10 @@ ul.ui-sortable { .crm-container table.criteria-group { margin-bottom: .1em; } - - +.crm-container table[align="center"] { + margin-right: auto; + margin-left: auto; +} .crm-container th, .crm-container table.display thead th, .crm-container table thead.sticky th, From 523ffb513bf14df97b66fd4d2cae0ab6aa4f7cdf Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Tue, 16 Apr 2024 16:04:25 +0800 Subject: [PATCH 8/8] refs #40378, add path support for setCookie in front end --- js/Common.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/Common.js b/js/Common.js index 0be80c7c1..3142513bd 100644 --- a/js/Common.js +++ b/js/Common.js @@ -797,12 +797,17 @@ function activityStatus( message ) } } -function setCookie(cname, cvalue, extsec) { +function setCookie(cname, cvalue, extsec, path) { extsec = typeof extsec !== 'undefined' ? extsec : 86400; var d = new Date(); d.setTime(d.getTime() + (extsec*1000)); var expires = "expires=" + d.toGMTString(); - document.cookie = cname+"="+cvalue+"; "+expires; + if (path) { + document.cookie = cname+"="+cvalue+"; "+expires+'; path='+path; + } + else { + document.cookie = cname+"="+cvalue+"; "+expires; + } } function getCookie(cname) {