Add card number character count validation tests #427
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR include?
Automates regression test cases to verify that we check the length of the card number even if it's a valid luhn number and belongs to a scheme.
To test this, some mock luhn numbers of different lengths are created. For example, to test if Visa card number length is being checked by our SDK, I added two different luhn numbers:
440000000002 -> Starts with 4 and consists of 12 digits -> Shows error
Please enter a valid card number
4400000000008 -> Starts with 4 and consists of 13 digits -> Does not show error even if it's not a valid Visa card number
Visa cards start with 4 and be between 13, 16 or 19 digits. We can't test the upper character limit because the textfields don't allow us to input more than the max limit.
To increase the testing speed
Rather than relaunching the app each and every time, we only change the card number field. The error we see becomes visible after we tap the
Done
button on thekeyboard
, so, it's okay to show or hide that error by tapping that button and verifying our test case and switch to the next one.If current card number after dropping the last 2 characters equals to the previous card number dropping the last character, we get that we're still testing the same card scheme and just delete the last digit and add the new two digits. Refer to the Visa card numbers above to understand this more.
When we switch to a new card scheme, we delete all the card number digits and input again.
If you want to understand this flow better, feel free to run the tests locally and watch the behaviour of UI.
When we come across
Amex
, which has 4 digits of security code, we delete the security code field completely (if security code is different than the previous one)