Skip to content

Commit

Permalink
Fix PaymentRequestNoUpdateWithTest by migrating from basic-card.
Browse files Browse the repository at this point in the history
Pair: nburris, kavitasoni
Bug: 1182234, 1339009, 1331481, 1331491
Test: https://chromium-swarm.appspot.com/task?id=63d0f6107a800f10
Test: https://chromium-swarm.appspot.com/task?id=63d0ea6f29d49a10
Change-Id: I222118897853fd0b603b75261a8bbedaa9bcfacf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4742561
Reviewed-by: Nick Burris <nburris@chromium.org>
Auto-Submit: Slobodan Pejic <slobodan@chromium.org>
Commit-Queue: Slobodan Pejic <slobodan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1180913}
  • Loading branch information
Slobodan Pejic authored and Chromium LUCI CQ committed Aug 8, 2023
1 parent c60abba commit 122c5a9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
import org.junit.runner.RunWith;

import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.autofill.AutofillProfile;
import org.chromium.chrome.browser.autofill.AutofillTestHelper;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.AppPresence;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.FactorySpeed;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.R;
import org.chromium.ui.modaldialog.ModalDialogProperties;

import java.util.concurrent.TimeoutException;

Expand Down Expand Up @@ -51,20 +50,18 @@ public void setUp() throws TimeoutException {
.setPhoneNumber("555 123-4567")
.setEmailAddress("lisa@simpson.com")
.build());
String billingAddressId = helper.setProfile(AutofillProfile.builder()
.setFullName("Maggie Simpson")
.setCompanyName("Acme Inc.")
.setStreetAddress("123 Main")
.setRegion("California")
.setLocality("Los Angeles")
.setPostalCode("90210")
.setCountryCode("Uzbekistan")
.setPhoneNumber("555 123-4567")
.setEmailAddress("maggie@simpson.com")
.build());
helper.setCreditCard(new CreditCard("", "https://example.test", true, true, "Jon Doe",
"4111111111111111", "1111", "12", "2050", "visa", R.drawable.visa_card,
billingAddressId, "" /* serverId */));
helper.setProfile(AutofillProfile.builder()
.setFullName("Maggie Simpson")
.setCompanyName("Acme Inc.")
.setStreetAddress("123 Main")
.setRegion("California")
.setLocality("Los Angeles")
.setPostalCode("90210")
.setCountryCode("Uzbekistan")
.setPhoneNumber("555 123-4567")
.setEmailAddress("maggie@simpson.com")
.build());
mRule.addPaymentAppFactory(AppPresence.HAVE_APPS, FactorySpeed.FAST_FACTORY);
}

/**
Expand All @@ -73,17 +70,14 @@ public void setUp() throws TimeoutException {
*/
@Test
@MediumTest
@DisabledTest(message = "crbug.com/1182234")
@Feature({"Payments"})
public void testNoEventListener() throws Throwable {
mRule.triggerUIAndWait("buyWithoutListeners", mRule.getReadyForInput());
mRule.runJavaScriptAndWaitForUIEvent(
"buyWithoutListenersWithMethods([{supportedMethods: 'https://bobpay.test'}]);",
mRule.getReadyToPay());
mRule.clickInShippingAddressAndWait(R.id.payments_section, mRule.getReadyForInput());
mRule.clickOnShippingAddressSuggestionOptionAndWait(1, mRule.getReadyForInput());
mRule.clickAndWait(R.id.button_primary, mRule.getReadyForUnmaskInput());
mRule.setTextInCardUnmaskDialogAndWait(
R.id.card_unmask_input, "123", mRule.getReadyToUnmask());
mRule.clickCardUnmaskButtonAndWait(
ModalDialogProperties.ButtonType.POSITIVE, mRule.getDismissed());
mRule.clickAndWait(R.id.button_primary, mRule.getDismissed());
mRule.expectResultContains(new String[] {"freeShipping"});
}

Expand All @@ -93,36 +87,30 @@ public void testNoEventListener() throws Throwable {
*/
@Test
@MediumTest
@DisabledTest(message = "crbug.com/1182234")
@Feature({"Payments"})
public void testNoUpdateWith() throws Throwable {
mRule.triggerUIAndWait("buyWithoutCallingUpdateWith", mRule.getReadyForInput());
mRule.runJavaScriptAndWaitForUIEvent(
"buyWithoutCallingUpdateWithWithMethods([{supportedMethods: 'https://bobpay.test'}]);",
mRule.getReadyToPay());
mRule.clickInShippingAddressAndWait(R.id.payments_section, mRule.getReadyForInput());
mRule.clickOnShippingAddressSuggestionOptionAndWait(1, mRule.getReadyForInput());
mRule.clickAndWait(R.id.button_primary, mRule.getReadyForUnmaskInput());
mRule.setTextInCardUnmaskDialogAndWait(
R.id.card_unmask_input, "123", mRule.getReadyToUnmask());
mRule.clickCardUnmaskButtonAndWait(
ModalDialogProperties.ButtonType.POSITIVE, mRule.getDismissed());
mRule.clickAndWait(R.id.button_primary, mRule.getDismissed());
mRule.expectResultContains(new String[] {"freeShipping"});
}

/** A merchant that calls updateWith() without using promises will not cause timeouts in UI. */
@Test
@MediumTest
@DisabledTest(message = "crbug.com/1182234")
@Feature({"Payments"})
public void testNoPromises() throws Throwable {
mRule.triggerUIAndWait("buyWithoutPromises", mRule.getReadyForInput());
mRule.runJavaScriptAndWaitForUIEvent(
"buyWithoutPromisesWithMethods([{supportedMethods: 'https://bobpay.test'}]);",
mRule.getReadyToPay());
Assert.assertEquals("USD $5.00", mRule.getOrderSummaryTotal());
mRule.clickInShippingAddressAndWait(R.id.payments_section, mRule.getReadyForInput());
mRule.clickOnShippingAddressSuggestionOptionAndWait(1, mRule.getReadyForInput());
Assert.assertEquals("USD $10.00", mRule.getOrderSummaryTotal());
mRule.clickAndWait(R.id.button_primary, mRule.getReadyForUnmaskInput());
mRule.setTextInCardUnmaskDialogAndWait(
R.id.card_unmask_input, "123", mRule.getReadyToUnmask());
mRule.clickCardUnmaskButtonAndWait(
ModalDialogProperties.ButtonType.POSITIVE, mRule.getDismissed());
mRule.clickAndWait(R.id.button_primary, mRule.getDismissed());
mRule.expectResultContains(new String[] {"updatedShipping"});
}
}
24 changes: 0 additions & 24 deletions components/test/data/payments/no_update_with.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ function showPaymentRequest(pr) {
});
}

/**
* Show a basic-card PaymentRequest that requests a shipping address, but has no
* listeners.
*/
function buyWithoutListeners() {
buyWithoutListenersWithMethods([{supportedMethods: 'basic-card'}]);
}

/**
* Show a PaymentRequest using methodData that requests a shipping address, but
* has no listeners.
Expand All @@ -66,14 +58,6 @@ function buyWithoutListeners() {
showPaymentRequest(buildPaymentRequest(methodData));
}

/**
* Show a basic-card PaymentRequest that requests a shipping address, but
* listeners don't call updateWith().
*/
function buyWithoutCallingUpdateWith() {
buyWithoutCallingUpdateWithWithMethods([{supportedMethods: 'basic-card'}]);
}

/**
* Show a PaymentRequest using methodData that requests a shipping address, but
* listeners don't call updateWith().
Expand All @@ -91,14 +75,6 @@ function buyWithoutCallingUpdateWith() {
showPaymentRequest(pr);
}

/**
* Show a basic-card PaymentRequest that requests a shipping address, but
* listeners don't use promises to update the UI.
*/
function buyWithoutPromises() {
buyWithoutPromisesWithMethods([{supportedMethods: 'basic-card'}]);
}

/**
* Show a PaymentRequest using methodData that requests a shipping address, but
* listeners don't use promises to update the UI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<button onclick="buyWithoutListeners()" id="buyWithoutListeners">Buy without listeners</button>
<button onclick="buyWithoutCallingUpdateWith()" id="buyWithoutCallingUpdateWith">Buy without calling updateWith()</button>
<button onclick="buyWithoutPromises()" id="buyWithoutPromises">Buy without promises</button>
<pre id="result"></pre>
</body>
</html>

0 comments on commit 122c5a9

Please sign in to comment.