Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when errorFields don't match options #14246

Merged
merged 2 commits into from
Mar 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>