Skip to content

Commit

Permalink
Warn when errorFields don't match options (#14246)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored and Marcos Cáceres committed Jul 23, 2019
1 parent ad2ac85 commit f693073
Showing 1 changed file with 158 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<!DOCTYPE html> <meta charset="utf-8" />
<title>Warn when errorFields don't match request[[options]]</title>
<link rel="help" href="https://github.com/w3c/payment-request/pull/807" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="helpers.js"></script>
<script>
test(() => {
assert_true(
"retry" in PaymentResponse.prototype,
"retry must be in prototype"
);
assert_true(
PaymentResponse.prototype.retry instanceof Function,
"retry must be a function"
);
}, "PaymentResponse.prototype must have a retry() function (smoke test).");

const defaultOptions = {
requestPayerName: false,
requestPayerEmail: false,
requestPayerPhone: false,
requestShipping: false,
};
function testShowWarning(button, errorFields) {
button.disabled = true;
promise_test(async () => {
const { response } = await getPaymentRequestResponse(defaultOptions);
await response.retry(errorFields);
await response.complete();
});
}
</script>
<h2>Manual Tests - Please run in order!</h2>
<p>
Please open the developer console. Each of the tests below should generate a
warning in the developer console.
</p>
<p>When presented with the payment sheet, hit pay twice.</p>
<ol>
<li>
<button onclick="testShowWarning(this, {payer: {name: 'Dont show this'}});">
Show warning if `requestPayerName` if false, and `errorFields.payer.name` is
present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {payer: {email: 'Dont show this'}});"
>
Show warning if `requestPayerEmail` if false, and `errorFields.payer.email`
is present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {payer: {phone: 'Dont show this'}});"
>
Show warning if `requestPayerPhone` if false, and `errorFields.payer.phone`
is present.
</button>
</li>
<li>
<button onclick="testShowWarning(this, {shippingAddress: {}});">
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {addressLine: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.addressLine` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {city: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.city` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {country: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.country` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {dependentLocality: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.dependentLocality` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {organization: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.organization` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {phone: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.phone` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {postalCode: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.postalCode` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {recipient: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.recipient` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {region: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.region` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {regionCode: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.regionCode` member present.
</button>
</li>
<li>
<button
onclick="testShowWarning(this, {shippingAddress: {sortingCode: 'Dont show this'}});"
>
Show warning if `requestShipping` if false, and
`errorFields.shippingAddress.sortingCode` member present.
</button>
</li>
<li><button onclick="done()">Done!</button></li>
</ol>

0 comments on commit f693073

Please sign in to comment.