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

Farzin/76562/Remove legacy connect method from cashier #7238

Conversation

farzin-deriv
Copy link
Contributor

Changes:

Please include a summary of the change and which issue is fixed below:

  • ...

When you need to add unit test

  • If this change disrupt current flow
  • If this change is adding new flow

When you need to add integration test

  • If components from external libraries are being used to define the flow, e.g. @deriv/components
  • If it relies on a very specific set of props with no default behavior for the current component.

Test coverage checklist (for reviewer)

  • Ensure utility / function has a test case
  • Ensure all the tests are passing

Type of change

  • Bug fix
  • New feature
  • Update feature
  • Refactor code
  • Translation to code
  • Translation to crowdin
  • Script configuration
  • Improve performance
  • Style only
  • Dependency update
  • Documentation update
  • Release

@vercel
Copy link

vercel bot commented Dec 27, 2022

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

Name Status Preview Updated
deriv-app ✅ Ready (Inspect) Visit Preview Dec 30, 2022 at 3:43PM (UTC)

@github-actions
Copy link
Contributor

github-actions bot commented Dec 27, 2022

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/7238](https://github.com/binary-com/deriv-app/pull/7238)
- **URLs**:
    - **w/ App ID + Server**: https://deriv-app-git-fork-farzin-deriv-farzin-76562removelegacy-ebe5a6.binary.sx?qa_server=frontend.binaryws.com&app_id=31483
    - **Original**: https://deriv-app-git-fork-farzin-deriv-farzin-76562removelegacy-ebe5a6.binary.sx
- **App ID**: `31483`

@codecov-commenter
Copy link

codecov-commenter commented Dec 27, 2022

Codecov Report

Merging #7238 (4449d6a) into develop (c743761) will increase coverage by 0.09%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #7238      +/-   ##
===========================================
+ Coverage    19.40%   19.50%   +0.09%     
===========================================
  Files         1478     1477       -1     
  Lines        34569    34587      +18     
  Branches      6366     6366              
===========================================
+ Hits          6709     6745      +36     
+ Misses       27349    27329      -20     
- Partials       511      513       +2     
Impacted Files Coverage Δ
packages/cashier/src/app.jsx 0.00% <ø> (ø)
...tainers/routes/error-component/error-component.tsx 80.00% <ø> (ø)
...er/src/containers/routes/route-with-sub-routes.tsx 14.28% <ø> (ø)
...ransfer-confirm/payment-agent-transfer-confirm.jsx 100.00% <ø> (ø)
...gent-transfer-form/payment-agent-transfer-form.jsx 77.77% <ø> (ø)
...ransfer-receipt/payment-agent-transfer-receipt.jsx 100.00% <ø> (ø)
.../payment-agent-transfer/payment-agent-transfer.jsx 100.00% <ø> (ø)
...ayment-agent-container/payment-agent-container.jsx 86.11% <ø> (ø)
...thdraw-form/payment-agent-listed-withdraw-form.jsx 88.09% <ø> (ø)
...nt/payment-agent-receipt/payment-agent-receipt.jsx 96.00% <ø> (ø)
... and 14 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -48,7 +48,6 @@
"loadjs": "^4.2.0",
"lodash.debounce": "^4.0.8",
"mobx": "^6.6.1",
"mobx-react": "^7.5.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should’ve been mobx-react-lite, But seems like we have missed it in merge conflicts and didn’t notice it.

<Routes />
</StoreProvider>
</MobxContentProvider>
<StoreProvider store={root_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.

Suggested change
<StoreProvider store={root_store}>
<StoreProvider>

Later when we could move all stores to the @deriv/stores we won’t need to pass anything to the provider anymore as the stores already live in the @deriv/stores package.

Comment on lines -23 to -24
// need to wrap withRouter around connect
// to prevent updates on <BinaryRoutes /> from being blocked
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this comment is still valid or not, If it is then I guess we need to wrap BinaryRoutes with observer but I don’t see any use of stores data in BinaryRoutes 🤔

@@ -1,6 +1,3 @@
import { useStore } from '@deriv/stores';

export type TRootStore = ReturnType<typeof useStore>;
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 still need to keep TRootStore in the @deriv/cashier package as we are overriding the return type of useStore hook with cashier stores, Later once we managed to replace cashier stores with hooks or move them to @deriv/stores we should be able to remove this as well.

@@ -21,4 +22,8 @@ export default class CounterStore {
decrement() {
this.count = --this.count;
}

unmount() {
stopPersisting(this);
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 should call stopPersisting here to solve the warning we get while running tests.

};

it('should show proper messages and button', () => {
render(<OnRampProviderCard {...props} />);
const mockRootStore: DeepPartial<TRootStore> = {
Copy link
Contributor

Choose a reason for hiding this comment

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

@farzin-deriv could we refactor mockRootStore to avoid duplication? For example create mockRootStore in beforeEach function and in test cases just change the required field. (e.g is_dark_mode_on in 'should show proper icons in dark_mode' test case)?

@@ -22,32 +17,148 @@ describe('<P2PCashier />', () => {
const history = createBrowserHistory();

it('should render <Loading /> component', () => {
const mockRootStore = {
Copy link
Contributor

Choose a reason for hiding this comment

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

@farzin-deriv could we refactor mockRootStore to avoid duplication? For example create mockRootStore in beforeEach function and in test cases just change the required field. (because e.g in 'should render P2P component' test case we only change is_logging_in field and in 'should redirect to "/cashier/p2p" page with "?order=1" query parameter' test case as i can see there is no any difference with original mockRootStore variable 🤔)?

Copy link
Contributor Author

@farzin-deriv farzin-deriv Dec 27, 2022

Choose a reason for hiding this comment

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

@george-usynin-binary Yes you are right, We should have a mocked version of the RootStore so we won’t need to create it each time for each test case, I've already created a card for it and added my proposed API for it, We can discuss it and come up with better ideas 🙇🏻

@sonarcloud
Copy link

sonarcloud bot commented Dec 30, 2022

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 24 Code Smells

No Coverage information No Coverage information
66.0% 66.0% Duplication

@carolsachdeva carolsachdeva merged commit ad1dc0b into binary-com:develop Jan 3, 2023
@farzin-deriv farzin-deriv deleted the farzin/76562/remove_legacy_connect_method_from_cashier branch January 3, 2023 05:23
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.

6 participants