зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1492399 - honor preserveFieldValues when generating billing address options. r=MattN
Differential Revision: https://phabricator.services.mozilla.com/D11129 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e10ccdacff
Коммит
8401d41400
|
@ -402,7 +402,7 @@ add_task(async function test_opt_out_persist_prefd_on_add_link() {
|
||||||
|
|
||||||
add_task(async function test_edit_link() {
|
add_task(async function test_edit_link() {
|
||||||
// add an address and card linked to this address
|
// add an address and card linked to this address
|
||||||
let prefilledGuids = await setup([PTU.Addresses.TimBL]);
|
let prefilledGuids = await setup([PTU.Addresses.TimBL, PTU.Addresses.TimBL2]);
|
||||||
{
|
{
|
||||||
let card = Object.assign({}, PTU.BasicCards.JohnDoe,
|
let card = Object.assign({}, PTU.BasicCards.JohnDoe,
|
||||||
{ billingAddressGUID: prefilledGuids.address1GUID });
|
{ billingAddressGUID: prefilledGuids.address1GUID });
|
||||||
|
@ -432,7 +432,7 @@ add_task(async function test_edit_link() {
|
||||||
|
|
||||||
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
||||||
return Object.keys(state.savedBasicCards).length == 1 &&
|
return Object.keys(state.savedBasicCards).length == 1 &&
|
||||||
Object.keys(state.savedAddresses).length == 1;
|
Object.keys(state.savedAddresses).length == 2;
|
||||||
}, "Check card and address present at beginning of test");
|
}, "Check card and address present at beginning of test");
|
||||||
|
|
||||||
let title = content.document.querySelector("basic-card-form h2");
|
let title = content.document.querySelector("basic-card-form h2");
|
||||||
|
@ -460,12 +460,12 @@ add_task(async function test_edit_link() {
|
||||||
content.document.querySelector("basic-card-form billing-address-picker"));
|
content.document.querySelector("basic-card-form billing-address-picker"));
|
||||||
|
|
||||||
let initialSelectedAddressGuid = billingAddressPicker.dropdown.value;
|
let initialSelectedAddressGuid = billingAddressPicker.dropdown.value;
|
||||||
is(billingAddressPicker.options.length, 2,
|
is(billingAddressPicker.options.length, 3,
|
||||||
"Two options should exist in the billingAddressPicker");
|
"Three options should exist in the billingAddressPicker");
|
||||||
is(initialSelectedAddressGuid, prefilledGuids.address1GUID,
|
is(initialSelectedAddressGuid, prefilledGuids.address1GUID,
|
||||||
"The prefilled billing address should be selected by default");
|
"The prefilled billing address should be selected by default");
|
||||||
|
|
||||||
info("Test clicking 'add' on the empty option first");
|
info("Test clicking 'add' with the empty option first");
|
||||||
billingAddressPicker.dropdown.popupBox.focus();
|
billingAddressPicker.dropdown.popupBox.focus();
|
||||||
content.fillField(billingAddressPicker.dropdown.popupBox, "");
|
content.fillField(billingAddressPicker.dropdown.popupBox, "");
|
||||||
|
|
||||||
|
@ -487,11 +487,31 @@ add_task(async function test_edit_link() {
|
||||||
addressBackButton.click();
|
addressBackButton.click();
|
||||||
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
||||||
return state.page.id == "basic-card-page" && state["basic-card-page"].guid &&
|
return state.page.id == "basic-card-page" && state["basic-card-page"].guid &&
|
||||||
Object.keys(state.savedAddresses).length == 1;
|
Object.keys(state.savedAddresses).length == 2;
|
||||||
}, "Check we're back at basic-card page with no state changed after adding");
|
}, "Check we're back at basic-card page with no state changed after adding");
|
||||||
|
|
||||||
|
info("Inspect a different address and ensure it remains selected when we go back");
|
||||||
|
content.fillField(billingAddressPicker.dropdown.popupBox, prefilledGuids.address2GUID);
|
||||||
|
|
||||||
|
addressEditLink.click();
|
||||||
|
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
||||||
|
return state.page.id == "address-page" && state["address-page"].guid;
|
||||||
|
}, "Clicking edit button with selected option will go to 'edit' page");
|
||||||
|
|
||||||
|
let countryPicker = content.document.querySelector("address-form #country");
|
||||||
|
is(countryPicker.value, PTU.Addresses.TimBL2.country, "The country value matches");
|
||||||
|
|
||||||
|
addressBackButton.click();
|
||||||
|
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
||||||
|
return state.page.id == "basic-card-page" && state["basic-card-page"].guid &&
|
||||||
|
Object.keys(state.savedAddresses).length == 2;
|
||||||
|
}, "Check we're back at basic-card page with no state changed after editing");
|
||||||
|
|
||||||
|
is(billingAddressPicker.dropdown.value, prefilledGuids.address2GUID,
|
||||||
|
"The selected billing address is correct");
|
||||||
|
|
||||||
info("Go back to previously selected option before clicking 'edit' now");
|
info("Go back to previously selected option before clicking 'edit' now");
|
||||||
billingAddressPicker.dropdown.value = initialSelectedAddressGuid;
|
content.fillField(billingAddressPicker.dropdown.popupBox, initialSelectedAddressGuid);
|
||||||
|
|
||||||
let selectedOption = billingAddressPicker.dropdown.selectedOption;
|
let selectedOption = billingAddressPicker.dropdown.selectedOption;
|
||||||
ok(selectedOption && selectedOption.value, "select should have a selected option value");
|
ok(selectedOption && selectedOption.value, "select should have a selected option value");
|
||||||
|
@ -511,7 +531,7 @@ add_task(async function test_edit_link() {
|
||||||
addressBackButton.click();
|
addressBackButton.click();
|
||||||
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
||||||
return state.page.id == "basic-card-page" && state["basic-card-page"].guid &&
|
return state.page.id == "basic-card-page" && state["basic-card-page"].guid &&
|
||||||
Object.keys(state.savedAddresses).length == 1;
|
Object.keys(state.savedAddresses).length == 2;
|
||||||
}, "Check we're back at basic-card page with no state changed after editing");
|
}, "Check we're back at basic-card page with no state changed after editing");
|
||||||
|
|
||||||
for (let [key, val] of Object.entries(card)) {
|
for (let [key, val] of Object.entries(card)) {
|
||||||
|
@ -542,8 +562,8 @@ add_task(async function test_edit_link() {
|
||||||
content.document.querySelector("address-form button.save-button").click();
|
content.document.querySelector("address-form button.save-button").click();
|
||||||
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
state = await PTU.DialogContentUtils.waitForState(content, (state) => {
|
||||||
return state.page.id == "basic-card-page" && state["basic-card-page"].guid &&
|
return state.page.id == "basic-card-page" && state["basic-card-page"].guid &&
|
||||||
Object.keys(state.savedAddresses).length == 1;
|
Object.keys(state.savedAddresses).length == 2;
|
||||||
}, "Check still only one address and we're back on basic-card page");
|
}, "Check still only 2 addresses and we're back on basic-card page");
|
||||||
|
|
||||||
is(Object.values(state.savedAddresses)[0].tel, PTU.Addresses.TimBL.tel.slice(0, -1) + "7",
|
is(Object.values(state.savedAddresses)[0].tel, PTU.Addresses.TimBL.tel.slice(0, -1) + "7",
|
||||||
"Check that address was edited and saved");
|
"Check that address was edited and saved");
|
||||||
|
|
|
@ -354,7 +354,7 @@ class EditCreditCard extends EditAutofillForm {
|
||||||
// _record must be updated before generateYears and generateBillingAddressOptions are called.
|
// _record must be updated before generateYears and generateBillingAddressOptions are called.
|
||||||
this._record = record;
|
this._record = record;
|
||||||
this._addresses = addresses;
|
this._addresses = addresses;
|
||||||
this.generateBillingAddressOptions();
|
this.generateBillingAddressOptions(preserveFieldValues);
|
||||||
if (!preserveFieldValues) {
|
if (!preserveFieldValues) {
|
||||||
// Re-populating the networks will reset the selected option.
|
// Re-populating the networks will reset the selected option.
|
||||||
this.populateNetworks();
|
this.populateNetworks();
|
||||||
|
@ -412,8 +412,13 @@ class EditCreditCard extends EditAutofillForm {
|
||||||
this._elements.ccType.appendChild(frag);
|
this._elements.ccType.appendChild(frag);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateBillingAddressOptions() {
|
generateBillingAddressOptions(preserveFieldValues) {
|
||||||
let billingAddressGUID = this._record && this._record.billingAddressGUID;
|
let billingAddressGUID;
|
||||||
|
if (preserveFieldValues && this._elements.billingAddress.value) {
|
||||||
|
billingAddressGUID = this._elements.billingAddress.value;
|
||||||
|
} else if (this._record) {
|
||||||
|
billingAddressGUID = this._record.billingAddressGUID;
|
||||||
|
}
|
||||||
|
|
||||||
this._elements.billingAddress.textContent = "";
|
this._elements.billingAddress.textContent = "";
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче