Commit 266f07cf authored by Tanisha Mandre's avatar Tanisha Mandre Committed by Commit Bot

Tests 'Add Payment Method...' button from manual fallback.

- Test that the button directs the user to the 'Add Payment Methods' screen.

Bug:1002183

Change-Id: Ibac78b433dba35c9b36fb5b5b96787edbc60d477
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1798667
Commit-Queue: Tanisha Mandre <tanishamandre@google.com>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697147}
parent 10a57054
......@@ -215,6 +215,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/passwords",
"//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/settings/autofill",
"//ios/chrome/browser/ui/settings/autofill:feature_flags",
"//ios/chrome/browser/ui/settings/password",
"//ios/chrome/browser/ui/util",
"//ios/chrome/test:eg_test_support",
......
......@@ -21,6 +21,7 @@ class CreditCard;
namespace manual_fill {
extern NSString* const ManageCardsAccessibilityIdentifier;
extern NSString* const kAddCreditCardsAccessibilityIdentifier;
} // namespace manual_fill
// Object in charge of getting the cards relevant for the manual fill
......
......@@ -40,6 +40,8 @@ namespace manual_fill {
NSString* const ManageCardsAccessibilityIdentifier =
@"kManualFillManageCardsAccessibilityIdentifier";
NSString* const kAddCreditCardsAccessibilityIdentifier =
@"kAddCreditCardsAccessibilityIdentifier";
} // namespace manual_fill
......@@ -144,6 +146,8 @@ NSString* const ManageCardsAccessibilityIdentifier =
"ManualFallback_CreditCard_OpenAddCreditCard"));
[weakSelf.dispatcher showAddCreditCard];
}];
addCreditCardsItem.accessibilityIdentifier =
manual_fill::kAddCreditCardsAccessibilityIdentifier;
[self.consumer
presentActions:@[ addCreditCardsItem, manageCreditCardsItem ]];
} else {
......
......@@ -9,6 +9,7 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#import "base/test/ios/wait_util.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/personal_data_manager.h"
......@@ -20,6 +21,7 @@
#import "ios/chrome/browser/ui/autofill/manual_fill/card_view_controller.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_accessory_view_controller.h"
#import "ios/chrome/browser/ui/settings/autofill/autofill_credit_card_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/autofill/features.h"
#import "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_actions.h"
......@@ -89,6 +91,13 @@ id<GREYMatcher> ManageCreditCardsMatcher() {
return grey_accessibilityID(manual_fill::ManageCardsAccessibilityIdentifier);
}
// Returns a matcher for the button to add credit cards settings in manual
// fallback.
id<GREYMatcher> AddCreditCardsMatcher() {
return grey_accessibilityID(
manual_fill::kAddCreditCardsAccessibilityIdentifier);
}
// Returns a matcher for the credit card settings collection view.
id<GREYMatcher> CreditCardSettingsMatcher() {
return grey_accessibilityID(kAutofillCreditCardTableViewId);
......@@ -243,7 +252,7 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
assertWithMatcher:grey_interactable()];
}
// Tests that the "Manage Credt Cards..." action works.
// Tests that the "Manage Credit Cards..." action works.
- (void)testManageCreditCardsActionOpensCreditCardSettings {
[self saveLocalCreditCard];
......@@ -268,6 +277,33 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
assertWithMatcher:grey_sufficientlyVisible()];
}
// Tests that the "Add Credit Cards..." action works.
- (void)testAddCreditCardsActionOpensAddCreditCardSettings {
base::test::ScopedFeatureList featureList;
featureList.InitAndEnableFeature(kSettingsAddPaymentMethod);
[self saveLocalCreditCard];
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
performAction:chrome_test_util::TapWebElement(kFormElementUsername)];
// Tap on the credit card icon.
[[EarlGrey selectElementWithMatcher:CreditCardIconMatcher()]
performAction:grey_tap()];
// Try to scroll.
[[EarlGrey selectElementWithMatcher:CreditCardTableViewMatcher()]
performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];
// Tap the "Add Credit Cards..." action.
[[EarlGrey selectElementWithMatcher:AddCreditCardsMatcher()]
performAction:grey_tap()];
// Verify the credit cards settings opened.
[[EarlGrey selectElementWithMatcher:chrome_test_util::AddCreditCardView()]
assertWithMatcher:grey_sufficientlyVisible()];
}
// Tests that the credit card View Controller is dismissed when tapping the
// keyboard icon.
- (void)testKeyboardIconDismissCreditCardController {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment