Bug 1461886 - Pass appropriate properties to the FTU onboarding address page. r=MattN
authorprathiksha <prathikshaprasadsuman@gmail.com>
Thu, 17 May 2018 17:41:25 -0700
changeset 419604 a04c1686e5ab1a1031858306f884df78632cc2a2
parent 419603 db3a97478cbfd90dbba53dc8c6026b5b14707454
child 419605 d67b21a431e5e495802527018434e83f43bdbe1c
push id34040
push userebalazs@mozilla.com
push dateThu, 24 May 2018 09:37:05 +0000
treeherdermozilla-central@c411ccb6bb4a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1461886
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1461886 - Pass appropriate properties to the FTU onboarding address page. r=MattN MozReview-Commit-ID: Fn8beZELyFG
browser/components/payments/res/paymentRequest.js
browser/components/payments/test/browser/browser_payments_onboarding_wizard.js
--- a/browser/components/payments/res/paymentRequest.js
+++ b/browser/components/payments/res/paymentRequest.js
@@ -110,39 +110,48 @@ var paymentRequest = {
   async onShowPaymentRequest(detail) {
     // Handle getting called before the DOM is ready.
     log.debug("onShowPaymentRequest:", detail);
     await this.domReadyPromise;
 
     log.debug("onShowPaymentRequest: domReadyPromise resolved");
     log.debug("onShowPaymentRequest, isPrivate?", detail.isPrivate);
 
+    let paymentDialog = document.querySelector("payment-dialog");
     let state = {
       request: detail.request,
       savedAddresses: detail.savedAddresses,
       savedBasicCards: detail.savedBasicCards,
       isPrivate: detail.isPrivate,
       page: {
         id: "payment-summary",
       },
     };
 
+    // Onboarding wizard flow.
     if (Object.keys(detail.savedAddresses).length == 0) {
       state.page = {
         id: "address-page",
         onboardingWizard: true,
       };
+
+      state["address-page"] = {
+        selectedStateKey: "selectedShippingAddress",
+        addressFields: null,
+        guid: null,
+        title: paymentDialog.dataset.shippingAddressTitleAdd,
+      };
     } else if (Object.keys(detail.savedBasicCards).length == 0) {
       state.page = {
         id: "basic-card-page",
         onboardingWizard: true,
       };
     }
 
-    document.querySelector("payment-dialog").setStateFromParent(state);
+    paymentDialog.setStateFromParent(state);
   },
 
   cancel() {
     this.sendMessageToChrome("paymentCancel");
   },
 
   pay(data) {
     this.sendMessageToChrome("pay", data);
--- a/browser/components/payments/test/browser/browser_payments_onboarding_wizard.js
+++ b/browser/components/payments/test/browser/browser_payments_onboarding_wizard.js
@@ -30,28 +30,39 @@ add_task(async function test_onboarding_
     ok(isAddressPageSaveButtonVisible, "Address page is rendered");
 
     await spawnPaymentDialogTask(frame, async function() {
       let {
         PaymentTestUtils: PTU,
       } = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
 
       await PTU.DialogContentUtils.waitForState(content, (state) => {
-        return state.page.id == "address-page";
+        return state.page.id == "address-page" &&
+               state["address-page"].selectedStateKey == "selectedShippingAddress";
       }, "Address page is shown first during on-boarding if there are no saved addresses");
     });
 
     info("Check if the total header is visible on the address page during on-boarding");
     let isHeaderVisible =
       spawnPaymentDialogTask(frame, PTU.DialogContentTasks.isElementVisible, "header");
     ok(isHeaderVisible, "Total Header is visible on the address page during on-boarding");
     let headerTextContent =
       spawnPaymentDialogTask(frame, PTU.DialogContentTasks.getElementTextContent, "header");
     ok(headerTextContent, "Total Header contains text");
 
+    info("Check if the page title is visible on the address page");
+    let isAddressPageTitleVisible = spawnPaymentDialogTask(frame,
+                                                           PTU.DialogContentTasks.isElementVisible,
+                                                           "address-form h1");
+    ok(isAddressPageTitleVisible, "Address page title is visible");
+    let titleTextContent =
+      spawnPaymentDialogTask(frame, PTU.DialogContentTasks.getElementTextContent,
+                             "address-form h1");
+    ok(titleTextContent, "Address page title contains text");
+
     let isAddressPageCancelButtonVisible =
       await spawnPaymentDialogTask(frame, PTU.DialogContentTasks.isElementVisible,
                                    "address-form .cancel-button");
     ok(isAddressPageCancelButtonVisible, "The cancel button on the address page is visible");
 
     await spawnPaymentDialogTask(frame, async function() {
       let {
         PaymentTestUtils: PTU,
@@ -68,16 +79,27 @@ add_task(async function test_onboarding_
       content.document.querySelector("address-form .save-button").click();
     });
 
     let isBasicCardPageSaveButtonVisible =
       await spawnPaymentDialogTask(frame, PTU.DialogContentTasks.isElementVisible,
                                    "basic-card-form .save-button");
     ok(isBasicCardPageSaveButtonVisible, "Basic card page is rendered");
 
+    let isBasicCardPageTitleVisible = spawnPaymentDialogTask(frame,
+                                                             // eslint-disable-next-line max-len
+                                                             PTU.DialogContentTasks.isElementVisible,
+                                                             "basic-card-form h1");
+    ok(isBasicCardPageTitleVisible, "Basic card page title is visible");
+    titleTextContent =
+      spawnPaymentDialogTask(frame,
+                             PTU.DialogContentTasks.getElementTextContent,
+                             "basic-card-form h1");
+    ok(titleTextContent, "Basic card page title contains text");
+
     await spawnPaymentDialogTask(frame, async function() {
       let {
         PaymentTestUtils: PTU,
       } = ChromeUtils.import("resource://testing-common/PaymentTestUtils.jsm", {});
 
       await PTU.DialogContentUtils.waitForState(content, (state) => {
         return state.page.id == "basic-card-page";
       }, "Basic card page is shown after the address page during on boarding");