Bug 763494 - Allow different prices per provider. r=mconley,a=Standard8 SEAMONKEY_2_11b3_BUILD1 SEAMONKEY_2_11b3_RELEASE
authorBlake Winton <bwinton@latte.ca>
Tue, 19 Jun 2012 22:47:00 +0100
changeset 11899 cd7e03be21f62291f0418b79d458740dcd44f16c
parent 11898 38bbd4ce6ad5b004304934665c620fc8f134b34d
child 11900 e8b4f477e7a093d581368405d3c47da9249b8108
child 11902 47897e195a21e43d29b0142f55f7e64ded1fc78f
child 11903 9a7678674e21f54ac811574030a65c60339f42b6
push id562
push userbugzilla@standard8.plus.com
push dateTue, 19 Jun 2012 21:51:33 +0000
treeherdercomm-beta@cd7e03be21f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, Standard8
bugs763494
Bug 763494 - Allow different prices per provider. r=mconley,a=Standard8
mail/components/newmailaccount/content/accountProvisioner.js
mail/test/mozmill/newmailaccount/html/providerList
mail/test/mozmill/newmailaccount/html/suggestFromName
mail/test/mozmill/newmailaccount/test-newmailaccount.js
--- a/mail/components/newmailaccount/content/accountProvisioner.js
+++ b/mail/components/newmailaccount/content/accountProvisioner.js
@@ -406,17 +406,18 @@ var EmailAccountProvisioner = {
       return $(this).val();
     }).get().join(',');
 
     $.ajax({
       url: EmailAccountProvisioner.suggestFromName,
       dataType: 'json',
       data: {"first_name": firstname,
              "last_name": lastname,
-             "providers": providerList},
+             "providers": providerList,
+             "version": 2},
       timeout: CONNECTION_TIMEOUT,
       success: EmailAccountProvisioner.onSearchResults})
       .error(EmailAccountProvisioner.showSearchError)
       .complete(function() {
         $("#FirstAndLastName").html(String.trim(firstname + " " + lastname));
         EmailAccountProvisioner.searchEnabled(true);
         EmailAccountProvisioner.spinning(false);
       });
@@ -787,18 +788,30 @@ var EmailAccountProvisioner = {
       group.append(header);
 
       let renderedAddresses = 0;
 
       for each (let [j, address] in Iterator(provider.addresses)) {
         let tmplData = {
           address: address,
         };
+        if (address.address)
+          tmplData.address = address.address;
 
-        if (provider.price && provider.price != "0")
+        // Figure out the price to display on the address button, as so:
+        // If there is a per-address price of > 0, use that.
+        // Otherwise, if there is a per-address price of 0, use "Free",
+        // Otherwise, there's no per-address price,
+        //   so if the provider's price is > 0, use that.
+        //   Or if the provider's price is 0, use "Free".
+        if (address.price && address.price != "0")
+          tmplData.priceStr = stringBundle.get("price", [address.price])
+        else if (address.price && address.price == "0")
+          tmplData.priceStr = stringBundle.get("free");
+        else if (provider.price && provider.price != "0")
           tmplData.priceStr = stringBundle.get("price", [provider.price])
         else
           tmplData.priceStr = stringBundle.get("free");
 
         try {
           let result = $("#result_tmpl").render(tmplData).appendTo(group);
           // If we got here, then we were able to successfully render the
           // address - we'll keep a count of the rendered addresses for the
--- a/mail/test/mozmill/newmailaccount/html/providerList
+++ b/mail/test/mozmill/newmailaccount/html/providerList
@@ -28,23 +28,33 @@
  {"id": "German",
   "label": "German Provider",
   "paid": false,
   "languages" : ["de-DE"],
   "api": "http://localhost:43336/registration.html",
   "tos_url": "http://www.example.com/German-tos",
   "privacy_url": "http://www.example.com/German-privacy",
   "search_engine": "German"
-},{"id": "corrupt",
+ },
+ {"id": "corrupt",
   "label": "Corrupt Provider",
   "paid": false,
   "languages" : ["en-US"],
   "api": "http://localhost:43336/registrationCorrupt.html",
   "tos_url": "http://www.example.com/corrupt-tos",
   "privacy_url": "http://www.example.com/corrupt-privacy"
-},{"id": "err",
+ },
+ {"id": "err",
   "label": "Error Provider",
   "paid": false,
   "languages" : ["en-US"],
   "api": "http://localhost:43336/registrationError.html",
   "tos_url": "http://www.example.com/err-tos",
   "privacy_url": "http://www.example.com/err-privacy"
-}]
+ },
+ {"id": "multi",
+  "label": "multi",
+  "paid": true,
+  "languages" : ["en-US"],
+  "api": "http://localhost:43336/registration.html",
+  "tos_url": "http://www.example.com/bar-tos",
+  "privacy_url": "http://www.example.com/bar-privacy"
+ }]
--- a/mail/test/mozmill/newmailaccount/html/suggestFromName
+++ b/mail/test/mozmill/newmailaccount/html/suggestFromName
@@ -3,9 +3,11 @@
 "b28acb3c0a464d33af22", "price": 0, "provider": "bar"}, {"product":
 "personalized_email", "addresses": ["green-bar@example.com", "me-bar@example.com",
 "green-bar@madeup.nul", "green@bar.nul", "green@barexample.nul",
 "greenbar@greenllama.nul", "mebar@greenllama.nul"], "succeeded": true, "quote":
 "3f93e48679ab46a49475", "price": "20.00", "provider": "foo"},
 {"product": "personalized_email", "addresses": ["corrupt@corrupt.nul"],
 "succeeded": true, "quote": "abcdefg", "price": 0, "provider": "corrupt"},
 {"product": "personalized_email", "addresses": ["error@error.nul"],
-"succeeded": true, "quote": "abcdefg", "price": 0, "provider": "err"}]
+"succeeded": true, "quote": "abcdefg", "price": 0, "provider": "err"},
+{"addresses": ["default@example.com", {"address": "cheap@example.com", "price": "0"},
+{"address": "expensive@example.com", "price": "$20.00"}], "succeeded": true, "price": "$20-$0", "provider": "multi"}]
--- a/mail/test/mozmill/newmailaccount/test-newmailaccount.js
+++ b/mail/test/mozmill/newmailaccount/test-newmailaccount.js
@@ -1279,8 +1279,51 @@ function test_get_new_account_focuses_ex
   // Click on the "Get a new Account" button in the wizard.
   wizard.click(wizard.eid("provisioner_button"));
 
   // If we got here, that means that we weren't blocked by a dialog
   // being opened, which is what we wanted..
   assert_selected_tab(apTab);
   mc.tabmail.closeTab(apTab);
 }
+
+/**
+ * Test that some prices can be per-address, instead of per-provider.
+ */
+function test_per_address_prices() {
+  plan_for_modal_dialog("AccountCreation", subtest_per_address_prices);
+  open_provisioner_window();
+  wait_for_modal_dialog("AccountCreation");
+}
+
+/**
+ * Subtest used by test_html_characters_and_ampersands.  This function puts
+ * a name with HTML tags into the search input, does a search, and ensures
+ * that the rendered name has escaped the HTML tags properly.
+ */
+function subtest_per_address_prices(w) {
+  wait_for_provider_list_loaded(w);
+  wait_for_search_ready(w);
+  let $ = w.window.$;
+
+  // Type a name with some HTML tags and an ampersand in there
+  // to see if we can trip up account provisioner.
+  type_in_search_name(w, "Joanna Finkelstein");
+
+  // Do the search.
+  $("#searchSubmit").click();
+
+  wait_for_search_results(w);
+
+  let prices = ["$20-$0 a year", "Free", "$20.00 a year"];
+
+  // Check that the multi-provider has the default price.
+  assert_true($(".provider:contains('multi') ~ .price").text(), prices[0].slice(0, 6));
+
+  // Click on the multi provider. This reveals the buttons with the prices.
+  $(".provider:contains('multi')").click();
+  mc.waitFor(function () $("button.create:visible").length > 0);
+
+  // For each button, make sure it has the correct price.
+  $("button.create:visible").text(function(index, text){
+    assert_equals(text, prices[index]);
+  });
+}