Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activate physical card #28313

Merged
merged 29 commits into from
Oct 10, 2023
Merged

Conversation

MrMuzyk
Copy link
Contributor

@MrMuzyk MrMuzyk commented Sep 27, 2023

Details

Fixed Issues

$ #22878
PROPOSAL:

Tests

  • Add useEffect with test data to the InitialSettingsPage
    useEffect(() => {
        window.Onyx.merge(`cardList`, {
            1234: {
                cardID: 1234,
                state: 4,
                bank: '1000',
                availableSpend: 10000,
                domainName: 'Expensify',
                lastFourPAN: '',
                isVirtual: false,
            },
        });

        Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute('expensify'));
    }, []);
  • Open app
  • Press on your avatar to open Settings
  • Press activate physical card button
  • Enter random 4 digit code
  • Error message about incorrect code should appear

In order to test happy path

  • Change failureData inside Card.js to
            failureData: [
                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: ONYXKEYS.CARD_LIST,
                    value: {
                        [cardID]: {
                            isLoading: false,
                            cardID: 1234,
                            state: 3,
                            bank: '1000',
                            availableSpend: 10000,
                            domainName: 'Expensify',
                            lastFourPAN: '',
                            isVirtual: false,
                        },
                    },
                },
            ],
  • Relog
  • Press on your avatar to open Settings
  • Press activate physical card button
  • Enter random 4 digit code
  • User should get redirected back to Expensify card page and Activate physical card button shouldn't be visible
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

Happy path
https://github.com/Expensify/App/assets/23487612/99fff72f-218c-4f96-8f36-808fa0a9385d

Error path
https://github.com/Expensify/App/assets/23487612/f043c39c-18dc-41c3-983c-dcc6533f4002

Mobile Web - Chrome

Happy path
https://github.com/Expensify/App/assets/23487612/2c00585e-3e24-4f96-b3e6-ab7f0cfa2f7e

Error path
https://github.com/Expensify/App/assets/23487612/033e7634-0bb2-4b4f-aa4f-00474ea2e640

Mobile Web - Safari

Happy path
https://github.com/Expensify/App/assets/23487612/3218c1fc-fce1-48c1-b36b-c69b12aabad3

Error path
https://github.com/Expensify/App/assets/23487612/4037e721-0440-462f-aa1f-d049467b0eaa

Desktop

Happy path
https://github.com/Expensify/App/assets/23487612/0fc7d45a-814f-44a3-b234-1a30e3dbc278

Error path
https://github.com/Expensify/App/assets/23487612/aa59912b-ac69-4537-9706-d7075c3cf362

iOS

Happy path
https://github.com/Expensify/App/assets/23487612/ce997f17-f882-4b0e-880d-1f2bb1a55bea

Error path
https://github.com/Expensify/App/assets/23487612/dc581a4c-086f-4ba7-bc64-2fcdc069caed

Android

Happy path
https://github.com/Expensify/App/assets/23487612/6761aca1-79a0-4f68-bb54-4ca4b099e239

Error path
https://github.com/Expensify/App/assets/23487612/437debbd-7b47-4691-902c-ad0431b6f8e9

@MrMuzyk MrMuzyk requested a review from a team as a code owner September 27, 2023 11:51
@melvin-bot melvin-bot bot requested review from fedirjh and removed request for a team September 27, 2023 11:51
@melvin-bot
Copy link

melvin-bot bot commented Sep 27, 2023

@fedirjh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@github-actions
Copy link
Contributor

github-actions bot commented Sep 27, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@MrMuzyk
Copy link
Contributor Author

MrMuzyk commented Sep 27, 2023

I have read the CLA Document and I hereby sign the CLA

@grgia grgia self-requested a review September 28, 2023 01:39
Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

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

Left some comments. I am also seeing this console error :

Screenshot 2023-09-28 at 12 00 07 PM

src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivateCardPage.js Outdated Show resolved Hide resolved
@MrMuzyk
Copy link
Contributor Author

MrMuzyk commented Sep 28, 2023

Left some comments. I am also seeing this console error :

Screenshot 2023-09-28 at 12 00 07 PM

this was caused by something in main. Ive rebased locally with the lastest one and now the error is gone. I'll make sure to check again once I fix everything pointed out during code review

Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

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

We have a bug with numberpad on the mobile web (safari and Chrome) , the number button doesn’t work after the input loses focus

CleanShot.2023-09-29.at.12.37.05.mp4

On IOS, the submit button is not docked at the bottom :

List page validate page
Screenshot 2023-09-29 at 12 51 59 PM Screenshot 2023-09-29 at 12 52 04 PM

On IOS Safari, the validate button is initially hidden, this may not be a bug , seems like a limitation with the design,

CleanShot.2023-09-29.at.12.36.27.mp4

On mobile, when an error occurs the design expands, is that expected? cc @shawnborton

CleanShot.2023-09-29.at.12.59.05.mp4

src/pages/settings/Wallet/ActivatePhysicalCardPage.js Outdated Show resolved Hide resolved
* @param {String} text
*/
const onCodeInput = (text) => {
setFormError('');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
setFormError('');
setFormError('');
if(cardError){
CardSettings.clearCardListErrors(cardID);
}

We should reset onyx error when input change.

value={lastFourDigits}
lastPressedDigit={lastPressedDigit}
onChangeText={onCodeInput}
errorText={formError}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
errorText={formError}
errorText={formError || cardError}

We pass onyx error with local validation error.

pleaseEnterLastFour: 'Please enter the last four digits of your card.',
activatePhysicalCard: 'Activate physical card',
error: {
notEnoughDigits: 'Not enough digits.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we ask for a copy of this error in the linked issue ? it should be approved by marketing.

and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will do.

The specs for this issue state:

The errors returned here are basically just “not enough digits” (must be 4) and “incorrect last four digits”.

Thought that it's fine for me to put it in there without asking any1 for confirmation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MrMuzyk
Copy link
Contributor Author

MrMuzyk commented Oct 5, 2023

Oh interesting, in that case, I think we should make sure the green button just sits below the number pad and is not docked to the bottom of the view. Thoughts? cc @Expensify/design

@shawnborton And that should be approach for all platforms?

@MrMuzyk
Copy link
Contributor Author

MrMuzyk commented Oct 6, 2023

Screen.Recording.2023-10-06.at.11.10.51.mov
Screen.Recording.2023-10-06.at.11.11.43.mov
Screen.Recording.2023-10-06.at.11.12.07.mov
Screen.Recording.2023-10-06.at.11.12.29.mov
Screen.Recording.2023-10-06.at.11.15.29.mov
Screen.Recording.2023-10-06.at.11.18.58.mov

@fedirjh I've updated the layout according to the latest guidelines. Submit button should be only docked at the bottom if there is an empty space above it. I've uploaded the videos to showcase how it looks like now. PR is ready for the final review

@fedirjh
Copy link
Contributor

fedirjh commented Oct 6, 2023

If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.

@MrMuzyk the app crashes when we deep link to the activate page without having any card in Onyx :

Screenshot 2023-10-06 at 12 06 36 PM

@MrMuzyk
Copy link
Contributor Author

MrMuzyk commented Oct 6, 2023

@fedirjh
Is there anything else I can do apart from this check which is already in codebase?

if (_.isEmpty(physicalCard)) {
        return <NotFoundPage />;
}

This page will not work properly without a physicalCard object provided from onyx

@shawnborton
Copy link
Contributor

Looking good! Minor feedback, but can we reduce the gaps between the activation number inputs to be just 12px like our mockup? Right now the gaps are a bit wide:
CleanShot 2023-10-06 at 07 50 48@2x

Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

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

Is there anything else I can do apart from this check which is already in codebase?

Apparently, using cardList[cardID] is causing this crash, I see using physicalCard should fix the crash.

src/pages/settings/Wallet/ActivatePhysicalCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivatePhysicalCardPage.js Outdated Show resolved Hide resolved
src/pages/settings/Wallet/ActivatePhysicalCardPage.js Outdated Show resolved Hide resolved
Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

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

Looking good.

src/components/MagicCodeInput.js Outdated Show resolved Hide resolved
@MrMuzyk
Copy link
Contributor Author

MrMuzyk commented Oct 6, 2023

@shawnborton

Updated the inputs

Screenshot 2023-10-06 at 15 39 15 1 Screenshot 2023-10-06 at 15 39 42

@fedirjh
Applied requested changes. Thanks for all the tips and making me realise of all the different scenarios that had to be checked here. Haven't thought about deep linking to that page .

@shawnborton
Copy link
Contributor

Awesome, thanks!

Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

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

The code looks good to me and tests well.

src/CONST.ts Outdated Show resolved Hide resolved
@MrMuzyk
Copy link
Contributor Author

MrMuzyk commented Oct 10, 2023

@grgia removed new const I've added and swapped to the one you've proposed. On top of that I've spotted that the type in ONYXKEYS was unnecessarily changed by me so I've reverted that. Rebased with latest main as well :)

@MrMuzyk MrMuzyk requested a review from grgia October 10, 2023 09:53
Copy link
Contributor

@grgia grgia left a comment

Choose a reason for hiding this comment

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

Great work on this!

@grgia grgia merged commit 477c630 into Expensify:main Oct 10, 2023
13 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/grgia in version: 1.3.81-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/grgia in version: 1.3.83-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

return;
}

CardSettings.activatePhysicalExpensifyCard(Number(lastFourDigits), cardID);
Copy link
Member

Choose a reason for hiding this comment

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

We should not convert the digits to numbers. It will remove starting 000s. This caused #31540

return (
<IllustratedHeaderPageLayout
title={translate('activateCardPage.activateCard')}
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(domain))}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have used Navigation.goBack to navigate, it caused #35530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants