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

[TS migration] Migrate 'SettingsWalletPhysicalCard' page to TypeScript #33641

Merged

Conversation

pasyukevich
Copy link
Contributor

@pasyukevich pasyukevich commented Dec 27, 2023

Details

Fixed Issues

$ #31997
PROPOSAL:

Tests

  1. Go to Settings/Wallet.
  2. add this useEffect on WalletPage.js:
useEffect(() => {
        if (cardList[234523452345]) {
            return;
        }
        // eslint-disable-next-line rulesdir/prefer-actions-set-data
        window.Onyx.merge(`cardList`, {
            234523452345: {
                key: '234523452345',
                cardID: 234523452345,
                state: 2,
                bank: 'Expensify Card',
                availableSpend: 10000,
                domainName: 'expensify.com',
                lastFourPAN: '2345',
                isVirtual: false,
                fraud: null,
            },
        });
    }, [cardList]);
  1. Click on the Expensify Card in the Assigned Cards section list.
  2. On the Expensify Card page you're currently on, press the Get Physical Card button at the bottom of the page.
  3. If you have filled in your details before, you should be shown the confirmation page with the correct data already filled. Otherwise, you'll be shown either the legal name, phone number, or address steps until you have filled in every single piece of data required.
  4. When all data is filled, you can press the Ship Card button on the confirmation step to go back to the Expensify Card page.
  5. At this point, it's not possible to send the request to the API so the Expensify Card page won't show the updated state when you already requested the physical card.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Use an account with Expensify card in 'Not issued' state.
  2. Click on the Expensify Card in the Assigned Cards section list.
  3. On the Expensify Card page you're currently on, press the Get Physical Card button at the bottom of the page.
  4. If you have filled in your details before, you should be shown the confirmation page with the correct data already filled. Otherwise, you'll be shown either the legal name, phone number, or address steps until you have filled in every single piece of data required.
  5. When all data is filled, you can press the Ship Card button on the confirmation step to go back to the Expensify Card page.
  6. At this point, it's not possible to send the request to the API so the Expensify Card page won't show the updated state when you already requested the physical card.
  • 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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 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(theme.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 the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • 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.

Screenshots/Videos

Android: Native
Android_native-converted.webm
Android: mWeb Chrome
android_web-converted.webm
iOS: Native
Ios_Native-converted.mp4
iOS: mWeb Safari
Ios_web-converted.mp4
MacOS: Chrome / Safari
mac_web-converted.mov
MacOS: Desktop
mac_desktop-converted.mov

@pasyukevich pasyukevich force-pushed the feature/migrate-SettingsWalletPhysicalCard branch 5 times, most recently from 411e55d to c85b80e Compare December 27, 2023 13:48
src/libs/GetPhysicalCardUtils.ts Outdated Show resolved Hide resolved
src/libs/GetPhysicalCardUtils.ts Outdated Show resolved Hide resolved
@@ -116,13 +86,13 @@ function getUpdatedDraftValues(draftValues: DraftValues, privatePersonalDetails:
* @param draftValues
* @returns
*/
function getUpdatedPrivatePersonalDetails(draftValues: DraftValues) {
const {addressLine1, addressLine2, city, country, legalFirstName, legalLastName, phoneNumber, state, zipPostCode} = draftValues;
function getUpdatedPrivatePersonalDetails(draftValues: OnyxEntry<GetPhysicalCardForm | undefined>): PrivatePersonalDetails {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need undefined inside OnyxEntry value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@blazejkustra blazejkustra Jan 12, 2024

Choose a reason for hiding this comment

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

How about removing undefined from the onyx type instead?

Suggested change
function getUpdatedPrivatePersonalDetails(draftValues: OnyxEntry<GetPhysicalCardForm | undefined>): PrivatePersonalDetails {
function getUpdatedPrivatePersonalDetails(draftValues: OnyxEntry<GetPhysicalCardForm>): PrivatePersonalDetails {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Working on that. It is needed to patch a logic also

state: PropTypes.string,
zipPostCode: PropTypes.string,
}),
draftValues: OnyxEntry<GetPhysicalCardForm | undefined>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need undefined in this typing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@pasyukevich You should rather remove undefined from the onyx value, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@blazejkustra I'm not sure about it

Could you clarify your question?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I'm a bit sick today 😅

Let's remove undefined from ONYXKEYS.ts:

[ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM_DRAFT]: OnyxTypes.GetPhysicalCardForm;

src/pages/settings/Wallet/Card/GetPhysicalCardAddress.tsx Outdated Show resolved Hide resolved
src/pages/settings/Wallet/Card/GetPhysicalCardName.tsx Outdated Show resolved Hide resolved
src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx Outdated Show resolved Hide resolved
src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx Outdated Show resolved Hide resolved
src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx Outdated Show resolved Hide resolved
src/libs/GetPhysicalCardUtils.ts Outdated Show resolved Hide resolved
@pasyukevich pasyukevich force-pushed the feature/migrate-SettingsWalletPhysicalCard branch 6 times, most recently from 6720e7b to 68bad7c Compare December 29, 2023 14:18
src/libs/GetPhysicalCardUtils.ts Outdated Show resolved Hide resolved
src/libs/GetPhysicalCardUtils.ts Outdated Show resolved Hide resolved
src/libs/GetPhysicalCardUtils.ts Outdated Show resolved Hide resolved
src/pages/settings/Wallet/Card/BaseGetPhysicalCard.tsx Outdated Show resolved Hide resolved
src/pages/settings/Wallet/Card/GetPhysicalCardAddress.tsx Outdated Show resolved Hide resolved
src/pages/settings/Wallet/Card/GetPhysicalCardName.tsx Outdated Show resolved Hide resolved
src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx Outdated Show resolved Hide resolved
src/types/onyx/Form.ts Outdated Show resolved Hide resolved
src/libs/CardUtils.ts Outdated Show resolved Hide resolved
src/libs/CardUtils.ts Outdated Show resolved Hide resolved
@pasyukevich pasyukevich force-pushed the feature/migrate-SettingsWalletPhysicalCard branch 3 times, most recently from 052401c to a44bab3 Compare January 2, 2024 17:30
Copy link

melvin-bot bot commented Jan 2, 2024

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@pasyukevich pasyukevich force-pushed the feature/migrate-SettingsWalletPhysicalCard branch from a44bab3 to 3d57b84 Compare January 2, 2024 18:13
Copy link
Contributor

@VickyStash VickyStash left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 78 to 79
const activeCards = Object.values(cardList ?? {}).filter(
(card) => !!card?.domainName && (CONST.EXPENSIFY_CARD.ACTIVE_STATES as ReadonlyArray<OnyxTypes.Card['state']>).includes(card.state),
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use .some instead of .includes to get rid of assertion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@@ -72,11 +73,13 @@ function getYearFromExpirationDateString(expirationDateString: string) {
* @param cardList - collection of assigned cards
* @returns collection of assigned cards grouped by domain
*/
function getDomainCards(cardList: Record<string, OnyxTypes.Card>) {
function getDomainCards(cardList: OnyxCollection<OnyxTypes.Card>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this really a OnyxCollection? if not I think we should stick to just Record<string, OnyxTypes.Card>

Copy link
Contributor

Choose a reason for hiding this comment

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

should it be just OnyxEntry<OnyxTypes.CardList?

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, we receive this data from the Onyx

@@ -77,7 +69,7 @@ function GetPhysicalCardName({
name="legalFirstName"
label={translate('getPhysicalCard.legalFirstName')}
aria-label={translate('getPhysicalCard.legalFirstName')}
role={CONST.ACCESSIBILITY_ROLE.TEXT}
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: why those roles changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They were replaced as they were deprecated

@pasyukevich pasyukevich force-pushed the feature/migrate-SettingsWalletPhysicalCard branch 4 times, most recently from 3a916a3 to 59c7719 Compare January 4, 2024 13:13
@@ -209,16 +171,14 @@ function BaseGetPhysicalCard({
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain))}
/>
<Text style={[styles.textHeadline, styles.mh5, styles.mb5]}>{headline}</Text>
{renderContent(onSubmit, submitButtonText, styles, children, onValidate)}
{renderContent({onSubmit, submitButtonText, children, onValidate})}
Copy link
Contributor

Choose a reason for hiding this comment

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

Before renderContent function had 5 arguments, now it has one. We need to be careful for any regressions

state: PropTypes.string,
zipPostCode: PropTypes.string,
}),
draftValues: OnyxEntry<GetPhysicalCardForm | undefined>;
Copy link
Contributor

Choose a reason for hiding this comment

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

@pasyukevich You should rather remove undefined from the onyx value, right?

@@ -83,7 +56,7 @@ function GetPhysicalCardConfirm({
submitButtonText={translate('getPhysicalCard.shipCard')}
title={translate('getPhysicalCard.header')}
>
<Text style={[styles.baseFontStyle, styles.mb5, styles.mh5]}>{translate('getPhysicalCard.estimatedDeliveryMessage')}</Text>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why these styles were removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only the baseFontStyle was removed, since it is nonexistent in styles

src/pages/settings/Wallet/Card/GetPhysicalCardName.tsx Outdated Show resolved Hide resolved
@pasyukevich pasyukevich force-pushed the feature/migrate-SettingsWalletPhysicalCard branch from 59c7719 to 502d7f5 Compare January 10, 2024 13:25
@pasyukevich pasyukevich force-pushed the feature/migrate-SettingsWalletPhysicalCard branch from 502d7f5 to c97ce23 Compare January 10, 2024 16:46
src/ONYXKEYS.ts Outdated
[ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM]: OnyxTypes.Form;
[ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM_DRAFT]: OnyxTypes.Form | undefined;
[ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM]: OnyxTypes.GetPhysicalCardForm;
[ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM_DRAFT]: OnyxTypes.GetPhysicalCardForm | undefined;
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
[ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM_DRAFT]: OnyxTypes.GetPhysicalCardForm | undefined;
[ONYXKEYS.FORMS.GET_PHYSICAL_CARD_FORM_DRAFT]: OnyxTypes.GetPhysicalCardForm;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@@ -116,13 +86,13 @@ function getUpdatedDraftValues(draftValues: DraftValues, privatePersonalDetails:
* @param draftValues
* @returns
*/
function getUpdatedPrivatePersonalDetails(draftValues: DraftValues) {
const {addressLine1, addressLine2, city, country, legalFirstName, legalLastName, phoneNumber, state, zipPostCode} = draftValues;
function getUpdatedPrivatePersonalDetails(draftValues: OnyxEntry<GetPhysicalCardForm | undefined>): PrivatePersonalDetails {
Copy link
Contributor

@blazejkustra blazejkustra Jan 12, 2024

Choose a reason for hiding this comment

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

How about removing undefined from the onyx type instead?

Suggested change
function getUpdatedPrivatePersonalDetails(draftValues: OnyxEntry<GetPhysicalCardForm | undefined>): PrivatePersonalDetails {
function getUpdatedPrivatePersonalDetails(draftValues: OnyxEntry<GetPhysicalCardForm>): PrivatePersonalDetails {

@@ -209,16 +171,14 @@ function BaseGetPhysicalCard({
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain))}
/>
<Text style={[styles.textHeadline, styles.mh5, styles.mb5]}>{headline}</Text>
{renderContent(onSubmit, submitButtonText, styles, children, onValidate)}
{renderContent({onSubmit, submitButtonText, children, onValidate})}
Copy link
Contributor

Choose a reason for hiding this comment

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

@amyevans amyevans requested review from amyevans and removed request for 0xmiros January 29, 2024 15:06
@amyevans
Copy link
Contributor

In addition to the questions above, could you update the QA steps please @pasyukevich? Step 2 won't be able to happen

@pasyukevich
Copy link
Contributor Author

@amyevans As far as I know, currently there are no other possibilities to test it without the hardcode

@amyevans
Copy link
Contributor

I think Applause has some accounts with the Expensify card (see the test steps in #35483 for instance).

@situchan
Copy link
Contributor

situchan commented Feb 5, 2024

And please resolve conflict @pasyukevich

@pasyukevich
Copy link
Contributor Author

@situchan PR updated

@pasyukevich
Copy link
Contributor Author

@amyevans To test this flow we need an account with a physical card in Not issued state
Applause has a virtual card only.

Where I can check the other options for test accounts?

@amyevans
Copy link
Contributor

amyevans commented Feb 6, 2024

I'm not sure, I asked in Slack and tagged you in the thread!

@pasyukevich
Copy link
Contributor Author

@amyevans I've updated QA steps for internal testing (according to the discussion in slack)

@amyevans
Copy link
Contributor

amyevans commented Feb 8, 2024

Alright thanks! Looks like there's still some unresolved questions from @situchan

@pasyukevich
Copy link
Contributor Author

@situchan All comments were addressed

@situchan
Copy link
Contributor

situchan commented Feb 8, 2024

Thanks

@amyevans all yours

@situchan
Copy link
Contributor

situchan commented Feb 8, 2024

@pasyukevich conflicts

@pasyukevich
Copy link
Contributor Author

@situchan conflicts solved

Copy link
Contributor

@amyevans amyevans left a comment

Choose a reason for hiding this comment

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

There's a lint error to fix, otherwise looks good though 👍

@pasyukevich
Copy link
Contributor Author

pasyukevich commented Feb 9, 2024

@amyevans Lint fixed

@amyevans amyevans merged commit 1c71f13 into Expensify:main Feb 9, 2024
15 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Feb 9, 2024

✋ 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/amyevans in version: 1.4.40-0 🚀

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

@kbecciv
Copy link

kbecciv commented Feb 12, 2024

@situchan QA team is unable to see the Expensify card in the 'Not issued' state. in tester@applausecard.expensifail.com account. Can you please verify above PR Internally?
image

@amyevans
Copy link
Contributor

✅ QA'ed it:

qa-33641.mov

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 1.4.40-5 🚀

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

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.

8 participants