Skip to content

Commit

Permalink
Test coverage dbot (#9825)
Browse files Browse the repository at this point in the history
* Sync with master to get latest update (#9750)

* translations: 📚 sync translations with crowdin (#9672)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* chore: translation workflow trigger (#9684)

* Revert "chore: translation workflow trigger (#9684)" (#9686)

This reverts commit cfacd85.

* Kate / WEBREL-51 / Test coverage: ProgressSliderStream in Trader package (#9464)

* feat: add unit tests

* refactor: incapsulated trade providers

* Kate / Test coverage:  ChartLoader + Loading in Trader package (#8398)

* refactor: add integr and unit tests for loader

* refactor: removed hardcoded test id

* likhith/fix: 🐛 display onfido error message (#9401)

* fix: 🐛 display onfido error message

* fix: reverted change

* test: ✅ added testcases

* fix: test case names

* fix: added testcases

* Henry/fix: test coverage and ts migration for asset/trading/categories (#8483)

* fix: test coverage and ts migration for asset/trading/categories

* fix: codecov issues

* fix: codecov issues

* test: dynamic test component import

* fix: code smell add error handling

* fix: change from FC to componenttype

* fix: circleCi

* fix: circleCI

* fix: circleCi

* fix: failing test

* fix: circleCI

* Matin/WALL-1308/Adding Korean language (#9426)

* chore: adding Korean language

* chore: changed Korean short form to KO from KR

* chore: fix translation issue in login history table

* chore: update all flags to follow the latest design system

* chore: Korean language on P2P

* chore: update deriv-charts to v1.3.2

* chore: empty

* translations: 📚 sync translations with crowdin (#9607)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* chore: empty

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* Amina/fix: disable account when proof failed (#9555)

* fix: disable account when proof failed

* fix: disable account when proof failed

* fix: flag

* fix: import

* fix: update with master

* fix: duplicate_types (#9691)

* likhith/fix: 🐛 translation of IDV documents dropdown option (#9336)

* fix: 🐛 translation of IDV documents dropdown option

* fix: 🐛 translation of default config

* fix: 🐛 translation of default config

* fix: 🐛 removed unused-import

* fix: 🐛 refactored code

* fix: ♻️ incorporated review comments

* fix: 🐛 added missing function

* maryia/DTRA-350/feat: handle displayed positions locally in TogglePositionsMobile (#9610)

* feat: handle displayed positions locally in mobile TogglePositions

* test: added a test

* chore: refactoring

* test: fix tests after conflict resolution

* FarhanNurzi/P2PS-1417/2FA order confirm modal is not showing up on mobile browsers (#9620)

* fix: completed order modal is not showing in mobile

* fix: add test case, fix error in chat component upon creating order

* refactor: destructure order in handleResponse

* Adrienne / Implemented new navigation flow for filtering payment methods in buy/sell page (#8544)

* Create codeql.yml

* Create codeql-test.yml

* chore: removed codeql workflows

* chore: removed dccache

* chore: added escapeHtml function to login

* feat: added new flow for filter modal

* chore: removed old commits

* fix: fixed ui issues regarding requirements

* feat: changed reset flow

* feat: changed flow for reset, added status for filter modal icon

* chore: incorporated reviews

* chore: applied code review changes

* Amina/wall 575/maintenance notifications for site and cashier (#9064)

* fix: notifications_in_cashier_and_accounts

* fix: notification for maintenance

* fix: notification_filter

* fix: notification_filter

* fix: filter notifications in mobile

* fix: code_review_suggestions

* chore: merge master

* chore: resolve conflict

* fix: showing notification in mobile

* Shaheer/wall 1229 (#9240)

* feat: ✨ adds financial assessment notification

* refactor: 🎨 sorts the object block

* feat: ✨ displays financial assessment notification on trigger from backend

* chore: 🚑 resolves merge conflict with master

* test: 🧪 adds test case for app-notification

* test: 🧪 adds test cases for notification

* Kate / OPT-306 / Update Accumulator to Accumulators  (#9577)

* chore: change text

* chore: apply suggestion

* Kate / Add video for Vanillas description (#9622)

* feat: add video for vanilla

* refactor: add tests and change file structure

* refactor: video component and test

* refactor: change folders name and add more videos

* refactor: apply suggestions

* chore: rename data test id

* chore: correct spelling

* chore: remove optional data test id

* refactor: add backup

* fix: tests

* likhith/chore: incorporated the API response to save the opt-out user data (#9618)

* chore: incorporated the API response to save the opt-out user data

* chore: incorporated the API response to save the opt-out user data

* chore: incorporated the API response to save the opt-out user data

* chore: incorporated the API response to save the opt-out user data

* chore: incorporated review comments

* chore: incorporated review comments

* chore: incorporated review comments

* fix: error displayed for MF account creation

* Merge branch 'master' into likhith/KYC-362/track-idv-opt-out-during-account-creation

* translations: 📚 sync translations with crowdin (#9702)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* Matin / Remove ESLint Ignore (#9707)

* chore: fix Oneall social unlinking from Apple accounts

* Revert "chore: fix Oneall social unlinking from Apple accounts"

This reverts commit 84009b0.

* chore: remove eslint ignore

* translations: 📚 sync translations with crowdin (#9709)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* fix: set dbot as external in platform config for authorize logout isssue (#9711)

* feat: transaction details modal (#9032)

* feat: transaction details modal

* feat: complete test cases for TransactionDetails modal

* chore: fix code smells

* chore: fix code smells

* chore: remove code smells

* chore: redeploy

* chore: move transaction details types to types folder

* chore: show enrty and exit tick if available

* fix: transaction scroll css issue fix

* fix: update key with data for divider inside transaction details modal

* fix: update buy price to have decimal value

* fix: css issue on modal height and fixed decimal profit/loss

* fix: fix style for modal getting cut

* fix: modal css issue after build

* fix: decrease the modal height for edge cutting issue

* fix: hide download button on mobile

* fix: gtm issue (#9551)

* fix: registration flow in buy/sell tab (#9573)

* fix: registration flow in buy/sell tab

* fix: added unit test

* Farzin/WALL-460/DepositCrypto module (#8867)

* Merge branch 'master' into farzin/wall-252/replace_the_use_of_cashier_store_in_other_packages_with_shared_hooks

* Merge branch 'farzin/wall-252/replace_the_use_of_cashier_store_in_other_packages_with_shared_hooks' into farzin/wall-434/separate_cashier_onboarding_to_a_new_route

* fix(cashier): 📝 resolve conflict

* feat(cashier): 🔥 remove `AccountPromptDialogStore`

* fix(cashier): ✅ fix failing tests

* feat(cashier): 🔥 remove `onMountCashierOnboarding`

* fix(cashier): ✅ fix `CashierOnboardingP2PCard`

* Merge branch 'master' into farzin/wall-434/separate_cashier_onboarding_to_a_new_route

* Merge branch 'master' into farzin/wall-434/separate_cashier_onboarding_to_a_new_route

* fix(cashier): 🐛 fix dialog issue

* fix(cashier): 📝 resolve PR comments

* refactor(cashier): ♻️ `CashierOnboardingModule` clean-up

* feat(cashier): ✨ add `useDepositCryptoAddress` hook

* feat(cashier): ✨ add `DepositCryptoWalletAddress`

* feat(cashier): ✨ add `DepositCryptoTryFiatOnRamp`

* feat(cashier): ✨ add `DepositCryptoModule`

* feat(cashier): ✨ add `PageContainer`

* refactor(cashier): 🚚 change folder structure

* feat(cashier): ✨ add `PageContainer`

* style(cashier): 💄 update the styles to match with the desing

* fix(cashier): 📝 resolve PR comments

* fix(cashier): 📝 resolve PR comments

* fix(cashier): ✅ fix failing tests

* feat(cashier): ♻️ move `CashierBreadcrumb` to `PageContainer`

* feat(cashier): ✨ add `DepositCryptoCurrencyDetails`

* feat(cashier): ✨ add `DepositCryptoWalletAddress`

* refactor(cashier): 🚚 change folder structure

* style(cashier): 💄 update the styles to match with the design

* feat(cashier): ✨ add `DepositCryptoDisclaimers`

* feat(components): ✨ add `InlineMessage`

* feat(cashier): ♻️ render `RecentTransaction` in `DepositCrypto`

* ci: 💚 trigger build

* refactor(cashier): ♻️ `CashierOnboardingModule` clean-up

* refactor(cashier): ♻️ `CashierOnboardingModule` clean-up

* fix(cashier): 🐛 fix double loader issue while switching accounts

* fix(cashier): ✅ fix failing test

* fix: 🔧 fix `jest.config.js` issue

* ci: 👷 set jest `maxWorkers` to `8`

* ci: 👷 set jest `maxWorkers` to `2`

* refactor(components): 💄 refactor `InlineMessage` component with the new design

* refactor(components): 💄 refactor `InlineMessage` component with the new design

* refactor(components): 🚚 move `SideNote` to components package

* feat(components): ✨ add `InlineMessage` component

* feat(components): ✨ add `SideNote` component

* feat(hooks): ✨ add `useInputDecimalFormatter` hook

* feat(hooks): ✨ add `useInputATMFormatter` hook

* feat(hooks): ✨ add `useCurrencyConfig` hook

* feat(hooks): ✨ add `useDepositCryptoAddress` hook

* fix: 🔧 fix `jest.config.js`

* feat: 🏷️ add `Prettify<T>` utility type

* fix(hooks): ✅ fix failing test

* fix(hooks): ✅ fix failing test

* feat(cashier): ✨ show transaction confirmations number

* feat(cashier): ✨ add `useUnsafeCashierRouteHandler` hook

* feat(cashier): ✨ use `useUnsafeCashierRouteHandler` hook in `AppContent`

* fix(appstore): 🚚 update deposit link in trader hub page

* refactor(cashier): ♻️ refactor cashier onboarding side notes

* feat(cashier): ✨ add `DepositCryptoResentTransactionSideNote`

* fix(cashier): ♻️ replace `is_crypto` with `useCurrencyConfig` hook

* style(cashier): 💄 update the styles

* style(cashier): 💄 update the styles

* style(cashier): 💄 update the styles

* refactor(cashier): 🚚 move components

* Merge branch 'master' into farzin/deposit_crypto_module

* feat(cashier): ✨ add `Confirmations` column to crypto transactions history

* refactor(cashier): ♻️ improve `CashierBreadcrumb`

* refactor(cashier): ♻️ improve `PageContainer`

* refactor(cashier): 🚚 move `SwitchToFiatAccountDialog` to components

* refactor(cashier): ♻️ clean-up cashier onboarding components

* feat(cashier): ✨ add `Confirmations` to recent transaction side note

* fix(cashier): ✅ fix failing test

* fix(cashier): ✅ fix failing test

* Merge remote-tracking branch 'aum-deriv/aum/WALL-297/deposit-fiat-module' into farzin/deposit_crypto_module

* refactor(cashier): 🔥 remove `containers` constant

* refactor(cashier): 🔥 remove `ErrorDialogStore`

* refactor(cashier): 🔥 remove `DepositStore`

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 🐛 fix reaise issues

* refactor(cashier): 🎨 improvements on `CashierOnboardingModule`

* refactor(cashier): 🚚 move cashier `EmptyState` to components package

* fix(cashier): 🐛 fix raised issues

* chore: ⬆️ update `@deriv/api-types` to `1.0.111`

* feat(api): 🏷️ add types for `cashier_payments` private call

* style(cashier): 💄 update deposit crypto page style to match the design

* feat(hooks): ✨ add `useCurrentCurrencyConfig` hook

* fix(cashier): ✅ fix failing tests

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* feat(hooks): ✨ add `useCryptoTransactions` hook

* fix(cashier): 🐛 fix raised issues

* style(cashier): 💄 update `CryptoTransactionsSideNoteResentTransaction` style

* style(cashier): 💄 update `DepositCryptoSideNoteUSDT` style

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 🐛 fix raised issues

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve conflicts

* fix(cashier): 📝 resolve comments

* fix(cashier): 📝 resolve comments

* Merge branch 'master' into farzin/wall-852/show_pending_crypto_deposit_transaction_even_if_0_confirmation

* fix(cashier): 📝 resolve PR comments

* fix(cashier): 📝 resolve PR comments

* fix(cashier): 📝 resolve PR comments

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* Merge branch 'master' into farzin/deposit_crypto_module

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

* fix(cashier): 📝 fix raised issues

---------

Co-authored-by: Farzin Mirzaie <farzin@deriv.com>

* fix: fix quick add modal's height bug (#8574)

* Farabi/bot 296/update responsive of tour in light mode (#9315)

* fix: tour responsive on light mode

* chore: updated PR

* fix: highlighted target issue on tour

* fix: added back data-testid

* Maryia/Bot-303/feat: add crash/boom to markets list (#9098)

* feat: add cryptocurrencies to markets list

* feat: crash/boom, step indices

* feat: take profit, stop loss disable when equal 0 to skip definition, add progress slider for crypta

* refactor: currency definition, fix type of variable

* fix: is_mobile

* chore: remove cryptocurrency and step index

* chore: remove cryptocurrency and step index(2)

* fix: Hide Crash & Boom from quick strategy form

* fix: DBot doesn't allow to run mutlipliers with take profit <=0 and stop loss > 0

* Kate / DTRA-166 / Implement Contract pages for Ends/ Stays contracts (#8998)

* refactor: move trade type from un to supported

* feat: ad contract type check func and add to contract details

* feat: add chart markers settings for contract type

* chore: add style for mobile

* chore: remove gradient

* chore: empty commit

* chore: add gradient for contract details card for desktop

* feat: add chart markers setings and update style

* refactor: apply suggestions

* chore: empty commit

* feat: enable smart trader contract

* refactor: remove rounding for barrier value

* refactor: add swipble component for contract audit mobile and fix style

* refactor: applied suggestions from review

* fix: change trade type icons

* chore: empty commit

* fix: conflicts

* Henry/dtra 282/rewrite contract type info component (#9352)

* fix: initialize

* fix: ts migrate and add test coverage to ContractType folder

* fix: remove unused import

* fix: TS Error due to name and value not being intrinsic attribute to span element

* fix: add test cases

* fix: code smells

* fix: consistency issue

* fix: code smell

* fix: minor change

* fix: rewrite contract-type-info to get rid of visual bug when switching between tabs

* fix: remove unused import

* fix: remove unused css

* fix: refactor component

* fix: small word change

* fix: resolve comments

* fix: resolve comments

* fix: empty commit

* fix: code smells

* fix: circleCI

* fix: resolve comments

* fix: missing import

* fix: remove scroll for contract-type-info

* fix: resolve conflicts and merge master

* fix: remove useeffect as per comment

* fix: remove css styling

* fix: circleCI

* farabi/bot-228/fix-step-5-modal-alignment (#9377)

* fix: removed for loop of loader in dashboard scss

* fix: step 5 content

* Niloofar Sadeghi / useP2PAdvertList custom hook (#9704)

* feat: create a custom hook for handling p2p-advert-list endpoint

* fix: review comments

* fix: review comments

* test: add test case for usepaginatedfetch custom hook

* fix: circle/ci error

---------

Co-authored-by: niloofar sadeghi <niloofar.sadeghi@re-work.dev>

* chore: test case for dbot-providers (#9583)

* henry/test: add test coverage and ts migration for successdialog (#8432)

* test: add test coverage and ts migration for successdialog

* fix: code smell

* fix: switch to userEvent from fireEvent

* fix: make something reusuable variable

* fix: remove unused file

* test: ✅ add test case for Audio component (#9572)

* test: ✅ add test case for Audio component

* test: add test case in audio component to check src attribute

* fix: fixed type in audio test file bot-web-ui

* translations: 📚 sync translations with crowdin (#9730)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* chore: fixed orders failing test case (#9735)

* translations: 📚 sync translations with crowdin (#9741)

Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>

* chore: update code owners (#9678)

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>
Co-authored-by: prince-deriv <82309725+prince-deriv@users.noreply.github.com>
Co-authored-by: kate-deriv <121025168+kate-deriv@users.noreply.github.com>
Co-authored-by: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com>
Co-authored-by: henry-deriv <118344354+henry-deriv@users.noreply.github.com>
Co-authored-by: Matin shafiei <matin@deriv.com>
Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com>
Co-authored-by: Maryia <103177211+maryia-deriv@users.noreply.github.com>
Co-authored-by: Farhan Ahmad Nurzi <125247833+farhan-nurzi-deriv@users.noreply.github.com>
Co-authored-by: adrienne-deriv <103016120+adrienne-deriv@users.noreply.github.com>
Co-authored-by: Shaheer <122449658+shaheer-deriv@users.noreply.github.com>
Co-authored-by: Shafin Al Karim <129021108+shafin-deriv@users.noreply.github.com>
Co-authored-by: nada-deriv <122768621+nada-deriv@users.noreply.github.com>
Co-authored-by: Farzin Mirzaie <72082844+farzin-deriv@users.noreply.github.com>
Co-authored-by: Farzin Mirzaie <farzin@deriv.com>
Co-authored-by: Farabi <102643568+farabi-deriv@users.noreply.github.com>
Co-authored-by: maryia-matskevich-deriv <103181650+maryia-matskevich-deriv@users.noreply.github.com>
Co-authored-by: Niloofar Sadeghi <93518187+niloofar-deriv@users.noreply.github.com>
Co-authored-by: niloofar sadeghi <niloofar.sadeghi@re-work.dev>
Co-authored-by: vinu-deriv <100689171+vinu-deriv@users.noreply.github.com>
Co-authored-by: ameerul-deriv <103412909+ameerul-deriv@users.noreply.github.com>

* Revert "Sync with master to get latest update (#9750)"

This reverts commit 0dcb820.

* Shafin/bot 531/chore  toolbar widget test (#9883)

* chore: test case for ToolbarWidgets

* chore: remove act

* chore: empty commit

* chore: contract card loading tests (#9884)

* Farabi/bot 533/contract result overlay test case (#9886)

* fix: added test case for contract result overlay

* fix: using mock_ws from utils/mock

* Maryia/Bot-535/test: react-joyride-wrapper component (#9893)

* test: react-joyride-wrapper

* refactor: react-joyride-wrapper

* Update packages/bot-web-ui/src/components/dashboard/__tests__/react-joyride-wrapper.spec.tsx

* chore: empty commit

* refactor: test for react-joyride-wrapper

* test: search-icon (#9891)

* Maryia/BOT-537/test: RunStrategy (#9892)

* test: RunStrategy

* refactor: test for run strategy

* Farabi/bot 536/test case for icon button (#9888)

* fix: added test case for icon-button.tsx

* fix: removed test for popovercd

* fix: removed icon-button and test case as its no longer used

* Vinu/bot 519/bot notification messages test case (#9881)

* test: add test case for bot-notification-messages component

* fix: fixed any type in bot-notification-messages.spec

* fix: added actions in bot-notification-messages spec file insted of changing store value directly

* fix: empty commit to trigger build

* fix: removed unused component (#9873)

* chore: test case for BotPreview (#9951)

* chore: test case for BotPreview

* chore: change type for reference

---------

Co-authored-by: Sandeep Rajput <90243468+sandeep-deriv@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DerivFE <80095553+DerivFE@users.noreply.github.com>
Co-authored-by: prince-deriv <82309725+prince-deriv@users.noreply.github.com>
Co-authored-by: kate-deriv <121025168+kate-deriv@users.noreply.github.com>
Co-authored-by: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com>
Co-authored-by: henry-deriv <118344354+henry-deriv@users.noreply.github.com>
Co-authored-by: Matin shafiei <matin@deriv.com>
Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com>
Co-authored-by: Maryia <103177211+maryia-deriv@users.noreply.github.com>
Co-authored-by: Farhan Ahmad Nurzi <125247833+farhan-nurzi-deriv@users.noreply.github.com>
Co-authored-by: adrienne-deriv <103016120+adrienne-deriv@users.noreply.github.com>
Co-authored-by: Shaheer <122449658+shaheer-deriv@users.noreply.github.com>
Co-authored-by: Shafin Al Karim <129021108+shafin-deriv@users.noreply.github.com>
Co-authored-by: nada-deriv <122768621+nada-deriv@users.noreply.github.com>
Co-authored-by: Farzin Mirzaie <72082844+farzin-deriv@users.noreply.github.com>
Co-authored-by: Farzin Mirzaie <farzin@deriv.com>
Co-authored-by: Farabi <102643568+farabi-deriv@users.noreply.github.com>
Co-authored-by: maryia-matskevich-deriv <103181650+maryia-matskevich-deriv@users.noreply.github.com>
Co-authored-by: Niloofar Sadeghi <93518187+niloofar-deriv@users.noreply.github.com>
Co-authored-by: niloofar sadeghi <niloofar.sadeghi@re-work.dev>
Co-authored-by: ameerul-deriv <103412909+ameerul-deriv@users.noreply.github.com>
Co-authored-by: rupato-deriv <97010868+rupato-deriv@users.noreply.github.com>
Co-authored-by: Sandeep <sandeep@regentmarkets.com>
  • Loading branch information
1 parent 4dd0984 commit 2dee35a
Show file tree
Hide file tree
Showing 17 changed files with 422 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import exp from 'constants';
import { render, screen } from '@testing-library/react';
import Audio from '../audio';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React from 'react';
import { mockStore, StoreProvider } from '@deriv/stores';
import { render, screen } from '@testing-library/react';
import { mock_ws } from 'Utils/mock';
import RootStore from 'Stores/root-store';
import { DBotStoreProvider, mockDBotStore } from 'Stores/useDBotStore';
import BotNotificationMessages from '../bot-notification-messages';

jest.mock('@deriv/bot-skeleton/src/scratch/blockly', () => jest.fn());
jest.mock('@deriv/bot-skeleton/src/scratch/dbot', () => ({
saveRecentWorkspace: jest.fn(),
unHighlightAllBlocks: jest.fn(),
}));
jest.mock('@deriv/bot-skeleton/src/scratch/hooks/block_svg', () => jest.fn());
jest.mock('@deriv/bot-skeleton', () => ({
...jest.requireActual('@deriv/bot-skeleton'),
blocksCoordinate: jest.fn(),
}));

describe('BotNotificationMessages', () => {
let wrapper: ({ children }: { children: JSX.Element }) => JSX.Element, mock_DBot_store: RootStore | undefined;
beforeAll(() => {
const mock_store = mockStore({
ui: {
notification_messages_ui: jest
.fn()
.mockReturnValue(<p>Mocked Notification Message</p>) as React.ElementType,
},
});
mock_DBot_store = mockDBotStore(mock_store, mock_ws);

wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock_store}>
<DBotStoreProvider ws={mock_ws} mock={mock_DBot_store}>
{children}
</DBotStoreProvider>
</StoreProvider>
);
});

it('should render BotNotificationMessages', () => {
const { container } = render(<BotNotificationMessages />, {
wrapper,
});
expect(container).toBeInTheDocument();
expect(screen.getByTestId('dt_notifications_container')).toHaveClass('notifications-container');
});

it('should apply notifications-container__dashboard class when active tab is 0 and is_info_panel_visible is true', () => {
mock_DBot_store!.dashboard.setInfoPanelVisibility(true);

render(<BotNotificationMessages />, {
wrapper,
});

expect(screen.getByTestId('dt_notifications_container')).toHaveClass(
'notifications-container notifications-container__dashboard'
);
});

it('should apply notifications-container--panel-open class when is_drawer_open is true and active tab has a value of 1 or 2', () => {
mock_DBot_store!.dashboard.setActiveTab(1);
mock_DBot_store!.run_panel.toggleDrawer(true);

render(<BotNotificationMessages />, {
wrapper,
});

expect(screen.getByTestId('dt_notifications_container')).toHaveClass(
'notifications-container notifications-container--panel-open'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const BotNotificationMessages = observer(() => {
'notifications-container__dashboard': active_tab === 0 && is_info_panel_visible,
'notifications-container--panel-open': [BOT_BUILDER, CHART].includes(active_tab) && is_drawer_open,
})}
data-testid='dt_notifications_container'
>
<Notifications />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from 'react';
import { isDesktop, isMobile } from '@deriv/shared';
import { mockStore, StoreProvider } from '@deriv/stores';
// eslint-disable-next-line import/no-extraneous-dependencies
import { render, screen } from '@testing-library/react';
import { mock_ws } from 'Utils/mock';
import { DBotStoreProvider, mockDBotStore } from 'Stores/useDBotStore';
import ToolbarWidgets from '../toolbar-widgets';

jest.mock('@deriv/shared', () => ({
...jest.requireActual('@deriv/shared'),
isMobile: jest.fn(),
isDesktop: jest.fn(),
}));

jest.mock('@deriv/bot-skeleton/src/scratch/blockly', () => jest.fn());
jest.mock('@deriv/bot-skeleton/src/scratch/dbot', () => ({
saveRecentWorkspace: jest.fn(),
unHighlightAllBlocks: jest.fn(),
}));
jest.mock('@deriv/bot-skeleton/src/scratch/hooks/block_svg', () => jest.fn());

// // Mocking the imports from @deriv/deriv-charts
jest.mock('@deriv/deriv-charts', () => ({
...jest.requireActual('@deriv/deriv-charts'),
__esModule: true,
ChartMode: jest.fn(() => <div>Mocked ChartMode</div>),
DrawTools: jest.fn(() => <div>Mocked DrawTools</div>),
Share: jest.fn(() => <div>Mocked Share</div>),
StudyLegend: jest.fn(() => <div>Mocked StudyLegend</div>),
ToolbarWidget: jest.fn(({ children }) => <div>{children}</div>),
Views: jest.fn(() => <div>Mocked Views</div>),
}));

describe('ToolbarWidgets', () => {
let wrapper: ({ children }: { children: JSX.Element }) => JSX.Element;

const mockUpdateChartType = jest.fn();
const mockUpdateGranularity = jest.fn();

beforeAll(() => {
const mock_store = mockStore({});
const mock_DBot_store = mockDBotStore(mock_store, mock_ws);

wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock_store}>
<DBotStoreProvider ws={mock_ws} mock={mock_DBot_store}>
{children}
</DBotStoreProvider>
</StoreProvider>
);
});

it('should render ToolbarWidgets in desktop', () => {
(isMobile as jest.Mock).mockReturnValueOnce(false);
(isDesktop as jest.Mock).mockReturnValueOnce(true);
render(<ToolbarWidgets updateChartType={mockUpdateChartType} updateGranularity={mockUpdateGranularity} />, {
wrapper,
});
expect(screen.getByText('Mocked StudyLegend')).toBeInTheDocument();
});

it('should render ToolbarWidgets in mobile', () => {
(isMobile as jest.Mock).mockReturnValueOnce(true);
(isDesktop as jest.Mock).mockReturnValueOnce(false);
render(<ToolbarWidgets updateChartType={mockUpdateChartType} updateGranularity={mockUpdateGranularity} />, {
wrapper,
});
expect(screen.queryByText('Mocked StudyLegend')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
import { mockStore, StoreProvider } from '@deriv/stores';
// eslint-disable-next-line import/no-extraneous-dependencies
import { render, screen } from '@testing-library/react';
import { mock_ws } from 'Utils/mock';
import { DBotStoreProvider, mockDBotStore } from 'Stores/useDBotStore';
import ContractCardLoader from '../contract-card-loading';

jest.mock('@deriv/bot-skeleton/src/scratch/blockly', () => jest.fn());
jest.mock('@deriv/bot-skeleton/src/scratch/dbot', () => ({
saveRecentWorkspace: jest.fn(),
unHighlightAllBlocks: jest.fn(),
}));
jest.mock('@deriv/bot-skeleton/src/scratch/hooks/block_svg', () => jest.fn());

describe('ContractCardLoader', () => {
let wrapper: ({ children }: { children: JSX.Element }) => JSX.Element;
beforeAll(() => {
const mock_store = mockStore({});
const mock_DBot_store = mockDBotStore(mock_store, mock_ws);

wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock_store}>
<DBotStoreProvider ws={mock_ws} mock={mock_DBot_store}>
{children}
</DBotStoreProvider>
</StoreProvider>
);
});

it('should render ContractCardLoader', () => {
render(<ContractCardLoader />, {
wrapper,
});
expect(screen.getByTestId('contract-card-loader')).toBeInTheDocument();
});

it('should render ContractCardLoader with default speed value', () => {
render(<ContractCardLoader />, {
wrapper,
});
const svgElement = screen.getByTestId('contract-card-loader');
// eslint-disable-next-line testing-library/no-node-access
const stopElement = svgElement.querySelector('animate'); // accessing the node directly to test the animation duration
expect(stopElement).toHaveAttribute('dur', '3s');
});

it('should render ContractCardLoader with speed value passed as prop', () => {
render(<ContractCardLoader speed={5} />, {
wrapper,
});
const svgElement = screen.getByTestId('contract-card-loader');
// eslint-disable-next-line testing-library/no-node-access
const stopElement = svgElement.querySelector('animate'); // accessing the node directly to test the animation duration
expect(stopElement).toHaveAttribute('dur', '5s');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const ContractCardLoader = ({ speed = 3 }: TContractCardLoader) => (
speed={speed}
backgroundColor={'var(--general-section-2)'}
foregroundColor={'var(--general-hover)'}
data-testid='contract-card-loader'
>
<rect x='12' y='15' rx='0' ry='0' width='41' height='25' />
<rect x='61' y='24' rx='0' ry='0' width='91' height='8' />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import { mockStore, StoreProvider } from '@deriv/stores';
// eslint-disable-next-line import/no-extraneous-dependencies
import { render, screen } from '@testing-library/react';
import { mock_ws } from 'Utils/mock';
import RootStore from 'Stores/index';
import { DBotStoreProvider, mockDBotStore } from 'Stores/useDBotStore';
import ContractResultOverlay from './contract-result-overlay';

jest.mock('@deriv/bot-skeleton/src/scratch/blockly', () => jest.fn());
jest.mock('@deriv/bot-skeleton/src/scratch/dbot', () => ({
saveRecentWorkspace: jest.fn(),
unHighlightAllBlocks: jest.fn(),
}));
jest.mock('@deriv/bot-skeleton/src/scratch/hooks/block_svg', () => jest.fn());

describe('ContractResultOverlay', () => {
let wrapper: ({ children }: { children: JSX.Element }) => JSX.Element, mock_DBot_store: RootStore | undefined;

beforeEach(() => {
jest.resetModules();
const mock_store = mockStore({});
mock_DBot_store = mockDBotStore(mock_store, mock_ws);

wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock_store}>
<DBotStoreProvider ws={mock_ws} mock={mock_DBot_store}>
{children}
</DBotStoreProvider>
</StoreProvider>
);
});

it('should render the ContractResultOverlay component', () => {
const { container } = render(<ContractResultOverlay profit={0} className={''} />, {
wrapper,
});
expect(container).toBeInTheDocument();
});

it('should show contract won', () => {
render(<ContractResultOverlay profit={0} className={''} />, {
wrapper,
});
expect(screen.getByText('Won')).toBeInTheDocument();
});

it('should show contract lost', () => {
render(<ContractResultOverlay profit={-1} className={''} />, {
wrapper,
});
expect(screen.getByText('Lost')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import { mockStore, StoreProvider } from '@deriv/stores';
// eslint-disable-next-line import/no-extraneous-dependencies
import { render, screen } from '@testing-library/react';
import { mock_ws } from 'Utils/mock';
import { DBotStoreProvider, mockDBotStore } from '../../../stores/useDBotStore';
import ReactJoyrideWrapper from '../react-joyride-wrapper';

jest.mock('@deriv/bot-skeleton/src/scratch/blockly', () => jest.fn());
jest.mock('@deriv/bot-skeleton/src/scratch/dbot', () => ({
saveRecentWorkspace: jest.fn(),
unHighlightAllBlocks: jest.fn(),
}));
jest.mock('@deriv/bot-skeleton/src/scratch/hooks/block_svg', () => jest.fn());
jest.mock('react-joyride', () => jest.fn(() => <div>ReactJoyride</div>));

describe('ReactJoyrideWrapper', () => {
const mock_store = mockStore({});
const mock_DBot_store = mockDBotStore(mock_store, mock_ws);

const mocked_props = {
steps: [
{
target: '.animation__wrapper',
content: <div>Content step 1</div>,
},
{
target: '.animation__wrapper',
content: <div>Content step 2</div>,
},
],
styles: {},
run: true,
};

it('should render ReactJoyrideWrapper', () => {
render(
<StoreProvider store={mock_store}>
<DBotStoreProvider ws={mock_ws} mock={mock_DBot_store}>
<ReactJoyrideWrapper {...mocked_props} />
</DBotStoreProvider>
</StoreProvider>
);

expect(screen.getByText('ReactJoyride')).toBeInTheDocument();
});
});

This file was deleted.

Loading

0 comments on commit 2dee35a

Please sign in to comment.