-
Notifications
You must be signed in to change notification settings - Fork 303
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
FarhanNurzi/P2PS-1329/Advertisers ads are duplicating in other advertiser profile after manual refresh #9569
Merged
hirad-deriv
merged 11 commits into
deriv-com:master
from
farhan-nurzi-deriv:P2PS-1329/issues-when-refreshing-the-page
Oct 17, 2023
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4f08b29
fix: fix issues when refreshing advertiser and my-profile page
Farhan-slurrp d967bf5
fix: sendbird error in test files
Farhan-slurrp 116a07d
refactor: prevent destructuring error when response is undefined
Farhan-slurrp 7e36879
Merge branch 'master' of https://github.com/binary-com/deriv-app into…
Farhan-slurrp bc5e329
fix: failed tests
Farhan-slurrp 345cede
fix: block overlay doesnt show the advertiser name
Farhan-slurrp c6bd7f1
Merge branch 'master' of https://github.com/binary-com/deriv-app into…
Farhan-slurrp 8094bf5
chore: empty commit
Farhan-slurrp 3568950
Merge branch 'master' of https://github.com/binary-com/deriv-app into…
Farhan-slurrp 1720962
chore: epmty commit
Farhan-slurrp 036d752
Merge branch 'master' of https://github.com/binary-com/deriv-app into…
Farhan-slurrp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
packages/p2p/src/components/advertiser-page/__tests__/advertiser-page.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { useModalManagerContext } from 'Components/modal-manager/modal-manager-context'; | ||
import { useStores } from 'Stores/index'; | ||
import AdvertiserPage from '../advertiser-page'; | ||
|
||
const mock_modal_manager = { | ||
showModal: jest.fn(), | ||
hideModal: jest.fn(), | ||
useRegisterModalProps: jest.fn(), | ||
is_modal_open: true, | ||
}; | ||
|
||
jest.mock('Components/modal-manager/modal-manager-context'); | ||
const mocked_useModalManagerContext = useModalManagerContext as jest.MockedFunction< | ||
() => Partial<ReturnType<typeof useModalManagerContext>> | ||
>; | ||
|
||
mocked_useModalManagerContext.mockImplementation(() => mock_modal_manager); | ||
|
||
const mock_store: DeepPartial<ReturnType<typeof useStores>> = { | ||
advertiser_page_store: { | ||
advertiser_details_id: 'id1', | ||
advertiser_details_name: 'test name', | ||
counterparty_advertiser_info: { | ||
name: 'name', | ||
is_online: 1, | ||
}, | ||
is_counterparty_advertiser_blocked: false, | ||
onAdvertiserIdUpdate: jest.fn(), | ||
onMount: jest.fn(), | ||
onTabChange: jest.fn(), | ||
setIsDropdownMenuVisible: jest.fn(), | ||
onUnmount: jest.fn(), | ||
onCancel: jest.fn(), | ||
is_loading: false, | ||
info: { | ||
name: 'name', | ||
}, | ||
}, | ||
general_store: { | ||
advertiser_id: 'id2', | ||
advertiser_info: { | ||
name: 'my name', | ||
is_online: 1, | ||
}, | ||
block_unblock_user_error: '', | ||
error_code: '', | ||
active_index: 0, | ||
setBlockUnblockUserError: jest.fn(), | ||
setActiveIndex: jest.fn(), | ||
path: { | ||
my_profile: 3, | ||
}, | ||
is_block_unblock_user_loading: false, | ||
setCounterpartyAdvertiserId: jest.fn(), | ||
}, | ||
buy_sell_store: { | ||
show_advertiser_page: true, | ||
hideAdvertiserPage: jest.fn(), | ||
}, | ||
my_profile_store: { | ||
setActiveTab: jest.fn(), | ||
}, | ||
}; | ||
|
||
jest.mock('Components/advertiser-page/advertiser-page-adverts', () => jest.fn(() => <div>adverts</div>)); | ||
jest.mock('Components/advertiser-page/advertiser-page-stats', () => jest.fn(() => <div>stats</div>)); | ||
jest.mock('@deriv/components', () => ({ | ||
...jest.requireActual('@deriv/components'), | ||
Loading: jest.fn(() => <div> loading...</div>), | ||
})); | ||
|
||
jest.mock('Stores', () => ({ | ||
...jest.requireActual('Stores'), | ||
useStores: jest.fn(() => mock_store), | ||
})); | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
useLocation: jest.fn(() => ({ | ||
hash: '', | ||
key: '0', | ||
pathname: '/cashier/p2p/advertiser', | ||
search: '?id=39', | ||
})), | ||
})); | ||
|
||
describe('<Advertiserpage />', () => { | ||
it('should call setCounterpartyAdvertiserId when component mounted', () => { | ||
render(<AdvertiserPage />); | ||
expect(mock_store.general_store.setCounterpartyAdvertiserId).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/p2p/src/components/my-profile/payment-methods/__tests__/payment-methods.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { useStores } from 'Stores/index'; | ||
import PaymentMethods from '../payment-methods'; | ||
|
||
let mock_store: DeepPartial<ReturnType<typeof useStores>>; | ||
|
||
jest.mock('Stores', () => ({ | ||
...jest.requireActual('Stores'), | ||
useStores: jest.fn(() => mock_store), | ||
})); | ||
|
||
jest.mock('Components/my-profile/payment-methods/add-payment-method', () => jest.fn(() => <div>AddPaymentMethod</div>)); | ||
jest.mock('Components/my-profile/payment-methods/payment-methods-list/edit-payment-method-form', () => | ||
jest.fn(() => <div>EditPaymentMethodForm</div>) | ||
); | ||
jest.mock('Components/my-profile/payment-methods/payment-methods-empty', () => | ||
jest.fn(() => <div>PaymentMethodsEmpty</div>) | ||
); | ||
jest.mock('Components/my-profile/payment-methods/payment-methods-list', () => | ||
jest.fn(() => <div>PaymentMethodsList</div>) | ||
); | ||
|
||
describe('<PaymentMethods />', () => { | ||
beforeEach(() => { | ||
mock_store = { | ||
general_store: { | ||
active_index: 3, | ||
setFormikRef: jest.fn(), | ||
}, | ||
my_profile_store: { | ||
advertiser_has_payment_methods: true, | ||
hideAddPaymentMethodForm: jest.fn(), | ||
is_loading: false, | ||
getAdvertiserPaymentMethods: jest.fn(), | ||
getPaymentMethodsList: jest.fn(), | ||
setAddPaymentMethodErrorMessage: jest.fn(), | ||
setIsLoading: jest.fn(), | ||
setShouldShowAddPaymentMethodForm: jest.fn(), | ||
setShouldShowEditPaymentMethodForm: jest.fn(), | ||
should_show_add_payment_method_form: false, | ||
}, | ||
}; | ||
}); | ||
|
||
it('should call getPaymentMethodsList when component mounted', () => { | ||
render(<PaymentMethods />); | ||
expect(mock_store.my_profile_store.getPaymentMethodsList).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fix
@sendbird/chat
error when running jest