Commit 1c218c56 authored by Tanisha Mandre's avatar Tanisha Mandre Committed by Commit Bot

Test Adding a card with invalid expiry date.

- Test that if a card with an invalid expiry date is added, an alert is shown.
- Test that the 'Cancel' button dismisses the screen.
Bug:1000669

Change-Id: Ie5f22fbcb4e8aecb9955c21d35a0bffbb55522e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786646
Commit-Queue: Tanisha Mandre <tanishamandre@google.com>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696728}
parent 71d06de6
...@@ -77,6 +77,12 @@ id<GREYMatcher> InvalidCardNumberAlert() { ...@@ -77,6 +77,12 @@ id<GREYMatcher> InvalidCardNumberAlert() {
IDS_IOS_ADD_CREDIT_CARD_INVALID_CARD_NUMBER_ALERT); IDS_IOS_ADD_CREDIT_CARD_INVALID_CARD_NUMBER_ALERT);
} }
// Matcher for the Invalid Card Expiry Date Alert.
id<GREYMatcher> InvalidCardExpiryDateAlert() {
return StaticTextWithAccessibilityLabelId(
IDS_IOS_ADD_CREDIT_CARD_INVALID_EXPIRATION_DATE_ALERT);
}
} // namespace } // namespace
// Tests for Settings Autofill add credit cards section. // Tests for Settings Autofill add credit cards section.
...@@ -164,6 +170,19 @@ id<GREYMatcher> InvalidCardNumberAlert() { ...@@ -164,6 +170,19 @@ id<GREYMatcher> InvalidCardNumberAlert() {
grey_not(grey_enabled()), nil)]; grey_not(grey_enabled()), nil)];
} }
// Tests that the 'Cancel' button dismisses the screen.
- (void)testCancelButtonDismissesScreen {
[[EarlGrey selectElementWithMatcher:chrome_test_util::AddCreditCardView()]
assertWithMatcher:grey_notNil()];
[[EarlGrey
selectElementWithMatcher:chrome_test_util::AddCreditCardCancelButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::AddCreditCardView()]
assertWithMatcher:grey_nil()];
}
#pragma mark - Test adding Valid/Inavlid card details
// Tests when a user tries to add an invalid card number, an alert is shown. On // Tests when a user tries to add an invalid card number, an alert is shown. On
// clicking 'OK' the alert is dismissed. // clicking 'OK' the alert is dismissed.
- (void)testAddButtonAlertOnInvalidNumber { - (void)testAddButtonAlertOnInvalidNumber {
...@@ -183,6 +202,28 @@ id<GREYMatcher> InvalidCardNumberAlert() { ...@@ -183,6 +202,28 @@ id<GREYMatcher> InvalidCardNumberAlert() {
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
} }
// Tests when a user tries to add an invalid card number, an alert is shown. On
// clicking 'OK' the alert is dismissed.
- (void)testAddButtonAlertOnInvalidExpiryDate {
[[EarlGrey selectElementWithMatcher:CardNumberTextField()]
performAction:grey_typeText(@"4111111111111111")];
[[EarlGrey selectElementWithMatcher:MonthOfExpiryTextField()]
performAction:grey_typeText(@"00")];
[[EarlGrey selectElementWithMatcher:YearOfExpiryTextField()]
performAction:grey_typeText(@"0000")];
[[EarlGrey selectElementWithMatcher:chrome_test_util::AddCreditCardButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:InvalidCardExpiryDateAlert()]
assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::OKButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:InvalidCardExpiryDateAlert()]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::OKButton()]
assertWithMatcher:grey_nil()];
}
// Tests when a user tries to add a valid card number, the screen is dismissed // Tests when a user tries to add a valid card number, the screen is dismissed
// and the new card number appears on the Autofill Credit Card 'Payment Methods' // and the new card number appears on the Autofill Credit Card 'Payment Methods'
// screen. // screen.
...@@ -209,16 +250,7 @@ id<GREYMatcher> InvalidCardNumberAlert() { ...@@ -209,16 +250,7 @@ id<GREYMatcher> InvalidCardNumberAlert() {
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
} }
// Tests that the 'Cancel' button dismisses the screen. #pragma mark - Test Use Camera button
- (void)testCancelButtonDismissesScreen {
[[EarlGrey selectElementWithMatcher:chrome_test_util::AddCreditCardView()]
assertWithMatcher:grey_notNil()];
[[EarlGrey
selectElementWithMatcher:chrome_test_util::AddCreditCardCancelButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::AddCreditCardView()]
assertWithMatcher:grey_nil()];
}
// Tests that the 'Use Camera' button opens the credit card scanner. // Tests that the 'Use Camera' button opens the credit card scanner.
- (void)testUseCameraButtonOpensCreditCardScanner { - (void)testUseCameraButtonOpensCreditCardScanner {
......
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