Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void setup() {
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("authentication_token_response.json")).mock();
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("successful_tmc_fields_response.json")).mock();
.getResourceContent("bank_account_fields_response.json")).mock();
}

@After
Expand Down Expand Up @@ -141,8 +141,8 @@ public void testAddTransferMethod_displaysFeeElementsOnTmcResponse() {
matches(withText(R.string.add_transfer_method_fee_label)));
onView(withId(R.id.add_transfer_method_processing_label)).check(
matches(withText(R.string.add_transfer_method_processing_time_label)));
onView(withId(R.id.add_transfer_method_fee_value)).check(matches(withText("USD 2.00")));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the data the same please

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skoong returned, but I unable to to handle processing time. Where I should place it?

onView(withId(R.id.add_transfer_method_processing_time_value)).check(matches(withText("1-2 Business days")));
onView(withId(R.id.add_transfer_method_fee_value)).check(matches(withText("USD 2.00")));
}

@Test
Expand Down Expand Up @@ -217,11 +217,11 @@ public void testAddTransferMethod_returnsErrorOnInvalidPresence() {
onView(withId(R.id.add_transfer_method_button)).perform(nestedScrollTo(), click());

onView(withId(R.id.branchIdLabel))
.check(matches(hasErrorText("You must provide a value for this field.")));
.check(matches(hasErrorText("You must provide a value for this field")));
onView(withId(R.id.bankAccountIdLabel))
.check(matches(hasErrorText("You must provide a value for this field.")));
.check(matches(hasErrorText("You must provide a value for this field")));
onView(withId(R.id.bankAccountPurposeLabel))
.check(matches(hasErrorText("You must provide a value for this field.")));
.check(matches(hasErrorText("You must provide a value for this field")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withParent;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
Expand Down Expand Up @@ -35,6 +36,7 @@
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.espresso.IdlingRegistry;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;

Expand Down Expand Up @@ -98,7 +100,7 @@ public void setup() {
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("authentication_token_response.json")).mock();
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("successful_tmc_bank_card_fields_response.json")).mock();
.getResourceContent("bank_card_fields_response.json")).mock();
}

@After
Expand Down Expand Up @@ -143,7 +145,9 @@ public void testAddTransferMethod_displaysFeeElementsOnTmcResponse() {
matches(withText(R.string.add_transfer_method_fee_label)));
onView(withId(R.id.add_transfer_method_processing_label)).check(
matches(withText(R.string.add_transfer_method_processing_time_label)));
onView(withId(R.id.add_transfer_method_fee_value)).check(matches(withText("USD 1.75")));
onView(withId(R.id.add_transfer_method_processing_label)).check(
matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
onView(withId(R.id.add_transfer_method_fee_value)).check(matches(withText(" 1.75")));
}

@Test
Expand Down Expand Up @@ -211,11 +215,11 @@ public void testAddTransferMethod_returnsErrorOnInvalidPresence() {
onView(withId(R.id.add_transfer_method_button)).perform(nestedScrollTo(), click());

onView(withId(R.id.cardNumberLabel))
.check(matches(hasErrorText("You must provide a value for this field.")));
.check(matches(hasErrorText("You must provide a value for this field")));
onView(withId(R.id.dateOfExpiryLabel))
.check(matches(hasErrorText("You must provide a value for this field.")));
.check(matches(hasErrorText("You must provide a value for this field")));
onView(withId(R.id.cvvLabel))
.check(matches(hasErrorText("You must provide a value for this field.")));
.check(matches(hasErrorText("You must provide a value for this field")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void setup() {
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("authentication_token_response.json")).mock();
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("successful_tmc_paypal_fields_response.json")).mock();
.getResourceContent("paypal_account_fields_response.json")).mock();
}

@After
Expand Down Expand Up @@ -178,7 +178,7 @@ public void testAddTransferMethod_returnsErrorOnInvalidPattern() {
onView(withId(R.id.add_transfer_method_button)).perform(nestedScrollTo(), click());

onView(withId(R.id.emailLabel))
.check(matches(hasErrorText("accountNumber is invalid")));
.check(matches(hasErrorText("is invalid length or format.")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void testSelectTransferMethod_verifyTransferMethodsList() {

onView(withId(R.id.select_transfer_method_country_value)).check(matches(withText("United States")));
onView(withId(R.id.select_transfer_method_currency_value)).check(matches(withText("USD")));
onView(withId(R.id.select_transfer_method_types_list)).check(new RecyclerViewCountAssertion(2));
onView(withId(R.id.select_transfer_method_types_list)).check(new RecyclerViewCountAssertion(3));

onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(0, hasDescendant(withText(R.string.bank_account_font_icon)))));
Expand All @@ -222,6 +222,14 @@ public void testSelectTransferMethod_verifyTransferMethodsList() {
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(1, hasDescendant(withText("Transaction Fee: USD 1.75")))));

onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(2, hasDescendant(withText(R.string.paypal_account_font_icon)))));
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(2, hasDescendant(withText(R.string.paypal_account)))));
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(2, hasDescendant(withText("Transaction Fee: USD 0.25")))));
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(2, hasDescendant(withText("Processing Time: Immediately")))));
}

@Test
Expand Down Expand Up @@ -283,21 +291,27 @@ public void testSelectTransferMethod_verifyTransferMethodsListUpdatedOnSelection

onView(withId(R.id.select_transfer_method_country_value)).check(matches(withText("United States")));
onView(withId(R.id.select_transfer_method_currency_value)).check(matches(withText("USD")));
onView(withId(R.id.select_transfer_method_types_list)).check(new RecyclerViewCountAssertion(2));
onView(withId(R.id.select_transfer_method_types_list)).check(new RecyclerViewCountAssertion(3));

onView(withId(R.id.select_transfer_method_country_value)).perform(click());
onView(allOf(withId(R.id.country_name), withText("Canada"))).perform(click());

onView(withId(R.id.select_transfer_method_types_list)).check(new RecyclerViewCountAssertion(1));
onView(withId(R.id.select_transfer_method_types_list)).check(new RecyclerViewCountAssertion(2));
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(0, hasDescendant(withText(R.string.bank_account_font_icon)))));
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(0, hasDescendant(withText(R.string.bank_account)))));
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(0, hasDescendant(withText("Transaction Fee: USD 2.00")))));
matches(atPosition(0, hasDescendant(withText("Transaction Fee: CAD 2.20")))));
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(0, hasDescendant(withText("Processing Time: 1-3 Business days")))));
matches(atPosition(0, hasDescendant(withText("Processing Time: 2-3 Business days")))));

onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(1, hasDescendant(withText(R.string.paypal_account_font_icon)))));
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(1, hasDescendant(withText(R.string.paypal_account)))));
onView(withId(R.id.select_transfer_method_types_list)).check(
matches(atPosition(1, hasDescendant(withText("Transaction Fee: CAD 0.35")))));
}

@Test
Expand Down Expand Up @@ -362,7 +376,7 @@ public void testSelectTransferMethod_clickBankCardOpensAddTransferMethodUi() {
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("successful_tmc_keys_response.json")).mock();
mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager
.getResourceContent("successful_tmc_bank_card_fields_response.json")).mock();
.getResourceContent("bank_card_fields_response.json")).mock();

mActivityTestRule.launchActivity(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,12 @@ public void showTransferMethodFields(@NonNull final List<HyperwalletFieldGroup>
sectionHeaderText = requireContext().getResources()
.getString(R.string.account_information_section_header, locale.getDisplayName(), mCurrency);
} else {
sectionHeaderText = requireContext().getString(requireContext().getResources()
.getIdentifier(group.getGroupName().toLowerCase(Locale.ROOT), "string",
requireContext().getPackageName()));
final int stringIdentifier = requireContext().getResources().getIdentifier(
group.getGroupName().toLowerCase(Locale.ROOT), "string", requireContext().getPackageName());
sectionHeaderText = stringIdentifier == 0 ? group.getGroupName() : requireContext().getString(
requireContext().getResources()
.getIdentifier(group.getGroupName().toLowerCase(Locale.ROOT), "string",
requireContext().getPackageName()));
}

View sectionHeader = LayoutInflater.from(mDynamicContainer.getContext())
Expand All @@ -319,22 +322,25 @@ public void showTransferMethodFields(@NonNull final List<HyperwalletFieldGroup>
mDynamicContainer.addView(sectionHeader);

// group fields
for (final HyperwalletField field : group.getFields()) {
AbstractWidget widget = WidgetFactory
.newWidget(field, this, getContext(),
mWidgetInputStateHashMap.containsKey(field.getName()) ?
mWidgetInputStateHashMap.get(field.getName()).getValue() : "",
mCreateTransferMethodButton);
if (mWidgetInputStateHashMap.isEmpty() || !mWidgetInputStateHashMap.containsKey(widget.getName())) {
mWidgetInputStateHashMap.put(widget.getName(), widget.getWidgetInputState());
}
if (group.getFields() != null) {
for (final HyperwalletField field : group.getFields()) {
AbstractWidget widget = WidgetFactory
.newWidget(field, this, getContext(),
mWidgetInputStateHashMap.containsKey(field.getName()) ?
mWidgetInputStateHashMap.get(field.getName()).getValue() : "",
mCreateTransferMethodButton);
if (mWidgetInputStateHashMap.isEmpty() || !mWidgetInputStateHashMap.containsKey(
widget.getName())) {
mWidgetInputStateHashMap.put(widget.getName(), widget.getWidgetInputState());
}

View widgetView = widget.getView();
widgetView.setTag(widget);
previousView = placeBelow(widgetView, previousView, true);
final String error = mWidgetInputStateHashMap.get(widget.getName()).getErrorMessage();
widget.showValidationError(error);
mDynamicContainer.addView(widgetView);
View widgetView = widget.getView();
widgetView.setTag(widget);
previousView = placeBelow(widgetView, previousView, true);
final String error = mWidgetInputStateHashMap.get(widget.getName()).getErrorMessage();
widget.showValidationError(error);
mDynamicContainer.addView(widgetView);
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string name="activity_select_transfer_method_title">Add Account</string>
<string name="title_activity_add_transfer_method">Add Transfer Method</string>
<string name="title_add_bank_account">Bank Account</string>
<string name="title_add_bank_card">Bank Card</string>
<string name="title_add_bank_card">Debit Card</string>

<string name="error_exact_length_field">The length of this field is exactly %d.</string>
<string name="error_invalid_expiry_date">%s is invalid.</string>
Expand Down Expand Up @@ -68,11 +68,11 @@

<!-- title and font icon -->
<string name="bank_account">Bank Account</string>
<string name="bank_card">Bank Card</string>
<string name="bank_card">Debit Card</string>
<string name="wire_account">Wire Account</string>
<string name="paper_check">Paper Check</string>
<string name="prepaid_card">Prepaid Card</string>
<string name="paypal_account">PayPal</string>
<string name="paypal_account">PayPal Account</string>

<string name="bank_account_font_icon">\uE000</string>
<string name="bank_card_font_icon">\uE005</string>
Expand Down
90 changes: 90 additions & 0 deletions ui/src/test/resources/bank_account_fields_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"data": {
"transferMethodUIConfigurations": {
"nodes": [
{
"country": "US",
"currency": "USD",
"transferMethodType": "BANK_ACCOUNT",
"profile": "INDIVIDUAL",
"fieldGroups": {
"nodes": [
{
"group": "PERSONAL_INFORMATION",
"fields": [
{
"category": "ACCOUNT",
"dataType": "NUMBER",
"isEditable": true,
"label": "Routing Number",
"maxLength": 9,
"minLength": 9,
"name": "branchId",
"placeholder": "",
"regularExpression": "^[0-9]{9}$",
"isRequired": true,
"validationMessage": {
"length": "The exact length of this field is 9.",
"pattern": "is invalid length or format.",
"empty": "You must provide a value for this field"
}
},
{
"category": "ACCOUNT",
"dataType": "NUMBER",
"isEditable": true,
"label": "Account Number",
"maxLength": 17,
"minLength": 4,
"name": "bankAccountId",
"placeholder": "",
"regularExpression": "^(?![0-]+$)[0-9-]{4,17}$",
"isRequired": true,
"validationMessage": {
"length": "The minimum length of this field is 4 and maximum length is 17.",
"pattern": "is invalid length or format.",
"empty": "You must provide a value for this field"
}
},
{
"category": "ACCOUNT",
"dataType": "SELECTION",
"isEditable": true,
"fieldSelectionOptions": [
{
"label": "CHECKING",
"value": "CHECKING"
},
{
"label": "SAVINGS",
"value": "SAVINGS"
}
],
"label": "Account Type",
"name": "bankAccountPurpose",
"placeholder": "",
"isRequired": true,
"validationMessage": {
"length": "",
"pattern": "is invalid length or format.",
"empty": "You must provide a value for this field"
}
}
]
}
]
}
}
]
},
"fees": {
"nodes": [
{
"value": "2.00",
"feeRateType": "FLAT",
"currency": "USD"
}
]
}
}
}
Loading