Bug 1464102 - Uncomment the shippingOptions portion of browser_request_serialization now that todo_is is supported. r=MattN
☠☠ backed out by 2d538ade0306 ☠ ☠
authorJared Wein <jwein@mozilla.com>
Thu, 24 May 2018 12:15:07 -0400
changeset 476484 460cd874757f800379e749392152dc0b35200416
parent 476483 3c227d911b2f1827120f00f7031f32d35b3a3b77
child 476485 278c5678daeecd13a07d1997ca5a3f95e4a2dfc5
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1464102
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 1464102 - Uncomment the shippingOptions portion of browser_request_serialization now that todo_is is supported. r=MattN MozReview-Commit-ID: GdOLGW2i4O1
browser/components/payments/test/browser/browser_request_serialization.js
--- a/browser/components/payments/test/browser/browser_request_serialization.js
+++ b/browser/components/payments/test/browser/browser_request_serialization.js
@@ -24,43 +24,55 @@ add_task(async function test_serializeRe
   const args = {
     methodData: [PTU.MethodData.basicCard],
     details: PTU.Details.twoDisplayItems,
   };
   await spawnInDialogForMerchantTask(PTU.ContentTasks.createAndShowRequest, testTask, args);
 });
 
 add_task(async function test_serializeRequest_shippingOptions() {
-  const testTask = ({methodData, details}) => {
+  const testTask = ({methodData, details, options}) => {
     let contentWin = Cu.waiveXrays(content);
     let store = contentWin.document.querySelector("payment-dialog").requestStore;
     let state = store && store.getState();
     ok(state, "got request store state");
 
-    // let expected = details;
-    // let actual = state.request.paymentDetails;
-    // if (expected.shippingOptions) {
-    //   is(actual.shippingOptions.length, expected.shippingOptions.length,
-    //      "shippingOptions have same length");
-    //   for (let i = 0; i < actual.shippingOptions.length; i++) {
-    //     let item = actual.shippingOptions[i], expectedItem = expected.shippingOptions[i];
-    //     is(item.label, expectedItem.label, "shippingOption label matches");
-    //     is(item.amount.value, expectedItem.amount.value, "shippingOption label matches");
-    //     is(item.amount.currency, expectedItem.amount.currency, "shippingOption label matches");
-    //   }
-    // } else {
-    //   is(actual.shippingOptions, null, "falsey input shippingOptions is serialized to null");
-    // }
+    // The following test cases are conditionally todo because
+    // the spec currently does not state the shippingOptions
+    // should be null when requestShipping is not set. A future
+    // spec change (bug 1436903 comments 7-12) will fix this.
+    let cond_is = options && options.requestShipping ? is : todo_is;
+
+    let expected = details;
+    let actual = state.request.paymentDetails;
+    if (expected.shippingOptions) {
+      cond_is(actual.shippingOptions.length, expected.shippingOptions.length,
+              "shippingOptions have same length");
+      for (let i = 0; i < actual.shippingOptions.length; i++) {
+        let item = actual.shippingOptions[i], expectedItem = expected.shippingOptions[i];
+        cond_is(item.label, expectedItem.label, "shippingOption label matches");
+        cond_is(item.amount.value, expectedItem.amount.value, "shippingOption label matches");
+        cond_is(item.amount.currency, expectedItem.amount.currency, "shippingOption label matches");
+      }
+    } else {
+      cond_is(actual.shippingOptions, null, "falsey input shippingOptions is serialized to null");
+    }
   };
 
-  const args = {
+  const argsTestCases = [{
+    methodData: [PTU.MethodData.basicCard],
+    details: PTU.Details.twoShippingOptions,
+  }, {
     methodData: [PTU.MethodData.basicCard],
     details: PTU.Details.twoShippingOptions,
-  };
-  await spawnInDialogForMerchantTask(PTU.ContentTasks.createAndShowRequest, testTask, args);
+    options: PTU.Options.requestShippingOption,
+  }];
+  for (let args of argsTestCases) {
+    await spawnInDialogForMerchantTask(PTU.ContentTasks.createAndShowRequest, testTask, args);
+  }
 });
 
 add_task(async function test_serializeRequest_paymentMethods() {
   const testTask = ({methodData, details}) => {
     let contentWin = Cu.waiveXrays(content);
     let store = contentWin.document.querySelector("payment-dialog").requestStore;
     let state = store && store.getState();
     ok(state, "got request store state");