Skip to content

Conversation

@likhith-deriv
Copy link
Contributor

Changes:

Please provide a summary of the change.

Screenshots:

Please provide some screenshots of the change.

@vercel
Copy link

vercel bot commented Jul 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
deriv-app ✅ Ready (Inspect) Visit Preview Aug 11, 2023 1:26pm

@github-actions
Copy link
Contributor

github-actions bot commented Jul 18, 2023

A production App ID was automatically generated for this PR. (log)

Click here to copy & paste above information.
- **PR**: [https://github.com/binary-com/deriv-app/pull/9386](https://github.com/binary-com/deriv-app/pull/9386)
- **URLs**:
    - **w/ App ID + Server**: https://deriv-app-git-fork-likhith-deriv-likhith-webrel-795refac-77e5ba.binary.sx?qa_server=red.binaryws.com&app_id=24224
    - **Original**: https://deriv-app-git-fork-likhith-deriv-likhith-webrel-795refac-77e5ba.binary.sx
- **App ID**: `24224`

@github-actions
Copy link
Contributor

github-actions bot commented Jul 18, 2023

🚨 Lighthouse report for the changes in this PR:

Category Score
🔺 Performance 16
🟧 Accessibility 75
🟢 Best practices 92
🟧 SEO 85
🟢 PWA 90

Lighthouse ran with https://deriv-app-git-fork-likhith-deriv-likhith-webrel-795refac-77e5ba.binary.sx/

@coveralls
Copy link

coveralls commented Jul 18, 2023

Coverage Status

coverage: 9.781% (-0.04%) from 9.825% when pulling 60cc83a on likhith-deriv:likhith/WEBREL-795/Refactor-real-account-signup-flow into 5995349 on binary-com:master.

import AddressDetails from '../address-details';
import { isDesktop, isMobile, PlatformContext, TLocationList } from '@deriv/shared';
import { FormikProps, FormikValues } from 'formik';
import { isDesktop, isMobile, PlatformContext } from '@deriv/shared';
Copy link
Contributor

Choose a reason for hiding this comment

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

you removed isDesktop and isMobile from the component itself,
should we refactor test accordingly?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh I see in the code of test it ok, so just remove here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here it is required because the DesktopWrapper and MobileWrapper are still making use of them


beforeEach(() => {
(isDesktop as jest.Mock).mockReturnValue(true);
(isMobile as jest.Mock).mockReturnValue(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

remove please these lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here it is required because the DesktopWrapper and MobileWrapper are still making use of them

Comment on lines +112 to +118
const new_store_config = {
...store,
ui: {
...store.ui,
is_mobile: true,
},
};
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
const new_store_config = {
...store,
ui: {
...store.ui,
is_mobile: true,
},
};
store.ui.is_mobile = true,

Could you check it? I think we can just change the value without creating new store

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do it. I feel using immutable data is better


it('should render AddressDetails component not svg', async () => {
mock_props.is_svg = false;
const new_props = { ...mock_props, is_svg: false };
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 to create new object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel using immutable data is better as we know where the object has changed

] as TLocationList[];

render(<AddressDetails {...mock_props} />);
const new_store_config = {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here.
maybe we can just do the creation of store in beforeEach?
in this case we can avoid creating new objects and just change properties directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are global settings available - mock_props, store, provider_value. I am modifying the ones that I need to simulate the test scenario


export type TInputFieldValues = Record<string, string>;

export type TAddressDetailFormProps = {
Copy link
Contributor

@yauheni-deriv yauheni-deriv Jul 19, 2023

Choose a reason for hiding this comment

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

is it really common types?
as I see we use it only for the component itself and for tests.
maybe we should keep it in the components file?
for using types in tests we can extract them with React.ComponentProps<typeof TAddressDetailFormProps>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using in spec file to type the FormikValue interface

is_account_switcher_disabled: computed,
is_mobile: computed,
is_tablet: computed,
is_desktop: computed,
Copy link
Contributor

Choose a reason for hiding this comment

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

please add new properties alphabetically :)

sub_section_index: 0,
toggleReadyToDepositModal: jest.fn(),
is_tablet: false,
is_desktop: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, please, alphabetically :)

is_reports_visible: boolean;
is_language_settings_modal_on: boolean;
is_mobile: boolean;
is_desktop: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

and here :)

initialValues={props.value}
validate={handleValidate}
validateOnMount
onSubmit={(values, actions) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be more readable if we move this logic to separate function?

has_real_account,
...props
}: TAddressDetails) => {
const { is_appstore } = React.useContext(PlatformContext);
Copy link
Contributor

Choose a reason for hiding this comment

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

@likhith-deriv do we need this flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flag has been removed

* refactor: ♻️ refactor component to remove unwanted code

* feat: removed commented code

* test: ✅ added testcase

* test: 🧪 added tests

* refactor: ♻️ incorporated review comments

* refactor: ♻️ incorporated review comments

* refactor: ♻️ incorporated review comments
* refactor: ♻️ migrated code to TS

* refactor: ♻️ incorporated review comments

* refactor: ♻️ incorporated review comments

* Update packages/account/src/Types/common-prop.type.ts

Co-authored-by: yauheni-deriv <103182683+yauheni-deriv@users.noreply.github.com>

---------

Co-authored-by: yauheni-deriv <103182683+yauheni-deriv@users.noreply.github.com>
* refactor: ⚡ refactored currency selector component

* fix: 🚨 lint errors

* feat: incorporated store values

* fix: 🎨 split code into small components

* fix: 🎨 removed un-necessary array

* refactor: ♻️ incorporated review comments

* refactor: ♻️ incorporated review comments

* resolved failing test cases

* chore: incorporated review comment

* fix: build issue

* fix: build issue
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
11.3% 11.3% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants