From acf769a3c67115528addaeca01bb241d4422f500 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Fri, 11 Aug 2017 16:21:23 +1000 Subject: [PATCH 1/8] Add defaults and helpers for Payments Basic Card --- .../helpers_and_defaults.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 payment-method-basic-card/helpers_and_defaults.js diff --git a/payment-method-basic-card/helpers_and_defaults.js b/payment-method-basic-card/helpers_and_defaults.js new file mode 100644 index 00000000000000..c32e1d5fc5f8bd --- /dev/null +++ b/payment-method-basic-card/helpers_and_defaults.js @@ -0,0 +1,36 @@ +const defaultCurrency = Object.freeze({ value: "1.0", currency: "USD" }); +const defaultTotal = Object.freeze({ label: "Total", amount: defaultCurrency }); +const defaultDetails = Object.freeze({ total: defaultTotal }); +const methodCard = Object.freeze({ + supportedMethods: ["basic-card"], +}); + +const defaultBillingAddress = Object.freeze({ + addressLine: ["1 web st"], + city: "w3c", + country: "AF", + dependentLocality: "", + languageCode: "", + organization: "", + phone: "+9312345678910", + postalCode: "1234", + recipient: "web platform test", + region: "", + sortingCode: "", +}); + +const defaultVisa = { + billingAddress: defaultBillingAddress, + cardNumber: "4111111111111111", + cardSecurityCode: "123", + cardholderName: "web platform test", + expiryMonth: "01", + expiryYear: "2026", +}; + +async function getCardResponse(data) { + const method = Object.assign({ data }, methodCard); + const response = await new PaymentRequest([method], defaultDetails).show(); + await response.complete("success"); + return response.details; +} From a5a1cec7b214b717cbaa264cbc7cc482f6f09e06 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Fri, 11 Aug 2017 16:21:29 +1000 Subject: [PATCH 2/8] manual tests for when BasicCardRequest is empty Manual tests for various forms of BasicCardRequest. --- .../empty-data-manual.https.html | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 payment-method-basic-card/empty-data-manual.https.html diff --git a/payment-method-basic-card/empty-data-manual.https.html b/payment-method-basic-card/empty-data-manual.https.html new file mode 100644 index 00000000000000..10fb6eb40625ea --- /dev/null +++ b/payment-method-basic-card/empty-data-manual.https.html @@ -0,0 +1,115 @@ + + +Manual return any card type + + + + + +

Instructions

+

+ This test checks that the Basic Card payment handler can accept any card. +

+
    +
  1. Add credit card: +
    +
    Cardhold Name:
    +
    web platform test
    +
    Card number:
    +
    4111111111111111
    +
    Security code (CVV):
    +
    123
    +
    Expiry month:
    +
    01
    +
    Expiry year:
    +
    2026
    + +
  2. +
  3. Add billing address: +
    +
    Recipient:
    +
    web platform test
    +
    Address:
    +
    1 web st
    +
    Post code:
    +
    1234
    +
    Country:
    +
    Afghanistan
    +
    City:
    +
    w3c
    +
    Phone
    +
    +12345678910
    + +
  4. +
+
+

+ Manual Tests - run in order +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + +
  6. +
  7. + +
  8. +
From 6713eb4c28cbec515f0c55c63e7a3399d1ea5433 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Fri, 11 Aug 2017 16:28:30 +1000 Subject: [PATCH 3/8] Improve code comments --- .../empty-data-manual.https.html | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/payment-method-basic-card/empty-data-manual.https.html b/payment-method-basic-card/empty-data-manual.https.html index 10fb6eb40625ea..6d177cc1804255 100644 --- a/payment-method-basic-card/empty-data-manual.https.html +++ b/payment-method-basic-card/empty-data-manual.https.html @@ -7,6 +7,31 @@

Instructions

@@ -58,7 +67,7 @@

Instructions

  1. Add credit card:
    -
    Cardhold Name:
    +
    Cardhold name:
    web platform test
    Card number:
    4111111111111111
    From 7eae66d3ba68d1c08573f2aa715dce10f7337c9a Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Fri, 11 Aug 2017 17:45:17 +1000 Subject: [PATCH 4/8] check basic card support via pr.canMakePayment() --- ...t-request-canmakepayment-method.https.html | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 payment-method-basic-card/payment-request-canmakepayment-method.https.html diff --git a/payment-method-basic-card/payment-request-canmakepayment-method.https.html b/payment-method-basic-card/payment-request-canmakepayment-method.https.html new file mode 100644 index 00000000000000..56d553afaa8a6f --- /dev/null +++ b/payment-method-basic-card/payment-request-canmakepayment-method.https.html @@ -0,0 +1,89 @@ + + + +Payment Method Basic Card: Tests that basic card is a supported method + + + + From 049070b1bdc1742ba7e0a9c3585abd962a361e1d Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Wed, 16 Aug 2017 15:52:46 +1000 Subject: [PATCH 5/8] style: missing ; --- payment-method-basic-card/empty-data-manual.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/payment-method-basic-card/empty-data-manual.https.html b/payment-method-basic-card/empty-data-manual.https.html index 6d177cc1804255..7da690c8894209 100644 --- a/payment-method-basic-card/empty-data-manual.https.html +++ b/payment-method-basic-card/empty-data-manual.https.html @@ -5,7 +5,7 @@ +const visaCredit = { + cardNumber: "4111111111111111", + cardSecurityCode: "123", + cardholderName: "web platform test", + expiryMonth: "01", + expiryYear: "2026", +}; + +async function getCardResponse(data) { + const method = Object.assign({ data }, methodCard, { environment: "TEST" }); + const response = await new PaymentRequest([method], defaultDetails).show(); + await response.complete("success"); + return response.details; +} +/** + * All tests expect the same return data, so we can just check the + * same result over and over again. + */ +function runPromiseTest(button, data, expectedCard = visaCredit, expectedAddress = defaultBillingAddress ) { + button.disabled = true; + promise_test(async () => { + const card = await getCardResponse(data); + for (const [member, expectedValue] of Object.entries(expectedCard)) { + const msg = `Expected card.${member} to equal ${expectedValue}.`; + assert_equals(card[member], expectedValue, msg); + } + const { billingAddress } = card; + for (const [member, expectedValue] of Object.entries(expectedAddress)) { + const msg = `billingAddress.${member} to equal ${expectedValue}.`; + assert_equals(billingAddress[member], expectedValue); + } + }, button.textContent.trim()); +} +

    Instructions

    - This test checks that the Basic Card payment handler can accept any card. + This test checks that the Basic Card payment handler can accept any card.

      -
    1. Add credit card: -
      -
      Cardhold name:
      -
      web platform test
      -
      Card number:
      -
      4111111111111111
      -
      Security code (CVV):
      -
      123
      -
      Expiry month:
      -
      01
      -
      Expiry year:
      -
      2026
      - -
    2. -
    3. Add billing address: -
      -
      Recipient:
      -
      web platform test
      -
      Address:
      -
      1 web st
      -
      Post code:
      -
      1234
      -
      Country:
      -
      Afghanistan
      -
      City:
      -
      w3c
      -
      Phone
      -
      +12345678910
      - -
    4. +
    5. Add credit card: +
      +
      Cardhold name:
      +
      web platform test
      +
      Card number:
      +
      4111111111111111
      +
      Security code (CVV):
      +
      123
      +
      Expiry month:
      +
      01
      +
      Expiry year:
      +
      2026
      +
      +
    6. +
    7. Add billing address: +
      +
      Recipient:
      +
      web platform test
      +
      Address:
      +
      1 web st
      +
      Post code:
      +
      1234
      +
      Country:
      +
      Afghanistan
      +
      City:
      +
      w3c
      +
      Phone
      +
      +12345678910
      +
      +

    - Manual Tests - run in order + Manual Tests - run in order

      -
    1. - -
    2. -
    3. - -
    4. -
    5. - -
    6. -
    7. - -
    8. +
    9. + +
    10. +
    11. + +
    12. +
    13. + +
    14. +
    15. + +
    diff --git a/payment-method-basic-card/helpers_and_defaults.js b/payment-method-basic-card/helpers_and_defaults.js deleted file mode 100644 index c32e1d5fc5f8bd..00000000000000 --- a/payment-method-basic-card/helpers_and_defaults.js +++ /dev/null @@ -1,36 +0,0 @@ -const defaultCurrency = Object.freeze({ value: "1.0", currency: "USD" }); -const defaultTotal = Object.freeze({ label: "Total", amount: defaultCurrency }); -const defaultDetails = Object.freeze({ total: defaultTotal }); -const methodCard = Object.freeze({ - supportedMethods: ["basic-card"], -}); - -const defaultBillingAddress = Object.freeze({ - addressLine: ["1 web st"], - city: "w3c", - country: "AF", - dependentLocality: "", - languageCode: "", - organization: "", - phone: "+9312345678910", - postalCode: "1234", - recipient: "web platform test", - region: "", - sortingCode: "", -}); - -const defaultVisa = { - billingAddress: defaultBillingAddress, - cardNumber: "4111111111111111", - cardSecurityCode: "123", - cardholderName: "web platform test", - expiryMonth: "01", - expiryYear: "2026", -}; - -async function getCardResponse(data) { - const method = Object.assign({ data }, methodCard); - const response = await new PaymentRequest([method], defaultDetails).show(); - await response.complete("success"); - return response.details; -} diff --git a/payment-method-basic-card/payment-request-canmakepayment-method.https.html b/payment-method-basic-card/payment-request-canmakepayment-method.https.html index 56d553afaa8a6f..a89c63b1bbc8aa 100644 --- a/payment-method-basic-card/payment-request-canmakepayment-method.https.html +++ b/payment-method-basic-card/payment-request-canmakepayment-method.https.html @@ -49,7 +49,8 @@ await canMakePaymentPromise, "Expected canMakePaymentPromise smoke test to resolve with false" ); - // Actual test + // Actual test - Make a big array with random PMIs, + // put basic-card in the middle of it! const pmis = [] .concat(Array.from(pmiGenerator(250))) .concat(basicCard) @@ -85,5 +86,4 @@ ); } }, `If basic-card is supported, then return a promise that resolves to true.`); - From ded41486cf8db52f4a1259861d4f2c571659a843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Mon, 9 Oct 2017 20:44:06 +1100 Subject: [PATCH 7/8] fix some nits --- payment-method-basic-card/empty-data-manual.https.html | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/payment-method-basic-card/empty-data-manual.https.html b/payment-method-basic-card/empty-data-manual.https.html index 26672643bb91b6..4bbbf166f2ad9b 100644 --- a/payment-method-basic-card/empty-data-manual.https.html +++ b/payment-method-basic-card/empty-data-manual.https.html @@ -4,10 +4,7 @@ -

    Instructions

    +

    + Payment Method Basic Card - test passing empty BasicCardRequest values +

    This test checks that the Basic Card payment handler can accept any card.

    +

    + Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. + The test expects the following credit card. +

    1. Add credit card:
      @@ -103,9 +110,6 @@

      Instructions


    -

    - Manual Tests - run in order -

    + + + If you find a buggy test, please file a bug + and tag one of the owners. +