Bug 1490805 - Include temporary basic cards in validity check for supportedNetworks. r=sfoster

Depends on D6848

Differential Revision: https://phabricator.services.mozilla.com/D6882

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matthew Noorenberghe 2018-09-27 05:57:40 +00:00
Родитель e2db9b25d4
Коммит 697601c954
2 изменённых файлов: 60 добавлений и 1 удалений

Просмотреть файл

@ -89,7 +89,7 @@ export default class PaymentMethodPicker extends RichPicker {
}
let acceptedNetworks = paymentRequest.getAcceptedNetworks(state.request);
let selectedCard = state.savedBasicCards[selectedOption.value];
let selectedCard = paymentRequest.getBasicCards(state)[selectedOption.value];
let isSupported = selectedCard["cc-type"] &&
acceptedNetworks.includes(selectedCard["cc-type"]);
return isSupported;

Просмотреть файл

@ -210,6 +210,65 @@ add_task(async function test_delete() {
ok(options[0].textContent.includes("J Smith"), "Check remaining card #1");
ok(options[1].textContent.includes("Jane Fields"), "Check remaining card #2");
});
add_task(async function test_supportedNetworks_tempCards() {
await picker1.requestStore.reset();
let request = Object.assign({}, picker1.requestStore.getState().request);
request.paymentMethods = [
{
supportedMethods: "basic-card",
data: {
supportedNetworks: [
"mastercard",
"visa",
],
},
},
];
await picker1.requestStore.setState({
request,
selectedPaymentCard: "68gjdh354j",
tempBasicCards: {
"68gjdh354j": {
"cc-exp": "2017-08",
"cc-exp-month": 8,
"cc-exp-year": 2017,
"cc-name": "J Smith",
"cc-number": "***********1234",
"cc-type": "discover",
"guid": "68gjdh354j",
},
},
});
await asyncElementRendered();
let options = picker1.dropdown.popupBox.children;
is(options.length, 1, "Check dropdown has one card");
ok(options[0].textContent.includes("J Smith"), "Check remaining card #1");
ok(picker1.classList.contains("invalid-selected-option"),
"Check discover is recognized as not supported");
info("change the card to be a visa");
await picker1.requestStore.setState({
tempBasicCards: {
"68gjdh354j": {
"cc-exp": "2017-08",
"cc-exp-month": 8,
"cc-exp-year": 2017,
"cc-name": "J Smith",
"cc-number": "***********1234",
"cc-type": "visa",
"guid": "68gjdh354j",
},
},
});
await asyncElementRendered();
ok(!picker1.classList.contains("invalid-selected-option"),
"Check visa is recognized as supported");
});
</script>
</body>