From cd503afd090f66577f145d971d133f993e749136 Mon Sep 17 00:00:00 2001 From: muhammad-ahmed Date: Thu, 5 Dec 2024 16:22:19 +0800 Subject: [PATCH 1/7] ahmed/DAPI-821/fix--sync-endpoint-configV3 --- package-lock.json | 32 +++- package.json | 7 +- src/features/Apiexplorer/index.tsx | 4 + src/hooks/useEndpoints/index.tsx | 57 +++++++ static/.nojekyll | 0 static/_data/v3.yml | 255 +++++++++++++++++++++++++++++ 6 files changed, 348 insertions(+), 7 deletions(-) create mode 100644 src/hooks/useEndpoints/index.tsx delete mode 100644 static/.nojekyll create mode 100644 static/_data/v3.yml diff --git a/package-lock.json b/package-lock.json index 5d70b9391..45978aad8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,6 +45,7 @@ "ts-jest": "^29.0.3", "typescript": "^5.4.5", "usehooks-ts": "^2.9.1", + "yaml": "^2.6.1", "yup": "^0.32.11" }, "devDependencies": { @@ -9649,6 +9650,16 @@ "node": ">=10" } }, + "node_modules/babel-plugin-macros/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "license": "ISC", + "peer": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/babel-plugin-polyfill-corejs2": { "version": "0.4.11", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.11.tgz", @@ -14284,6 +14295,15 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, + "node_modules/fork-ts-checker-webpack-plugin/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "license": "ISC", + "engines": { + "node": ">= 6" + } + }, "node_modules/form-data": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", @@ -33409,11 +33429,15 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" }, "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz", + "integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==", + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/yargs": { diff --git a/package.json b/package.json index 0bb7d5a6a..fb625ec5a 100644 --- a/package.json +++ b/package.json @@ -26,12 +26,10 @@ "format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,md,json}' --config ./.prettierrc" }, "dependencies": { - "@deriv-com/quill-ui": "^1.16.21", "@deriv-com/analytics": "^1.22.1", "@deriv-com/auth-client": "^1.0.29", + "@deriv-com/quill-ui": "^1.16.21", "@deriv/deriv-api": "^1.0.11", - "@radix-ui/react-tooltip": "^1.0.7", - "@react-spring/web": "^9.7.3", "@deriv/ui": "^0.8.0", "@docusaurus/core": "^3.3.2", "@docusaurus/plugin-client-redirects": "^3.3.2", @@ -43,6 +41,8 @@ "@radix-ui/react-accordion": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.0.2", "@radix-ui/react-tabs": "^1.0.2", + "@radix-ui/react-tooltip": "^1.0.7", + "@react-spring/web": "^9.7.3", "@textea/json-viewer": "^3.4.1", "@use-gesture/react": "^10.3.0", "babel-plugin-jsx-remove-data-test-id": "^3.0.0", @@ -63,6 +63,7 @@ "ts-jest": "^29.0.3", "typescript": "^5.4.5", "usehooks-ts": "^2.9.1", + "yaml": "^2.6.1", "yup": "^0.32.11" }, "devDependencies": { diff --git a/src/features/Apiexplorer/index.tsx b/src/features/Apiexplorer/index.tsx index 32a47cec4..ca94fdbb6 100644 --- a/src/features/Apiexplorer/index.tsx +++ b/src/features/Apiexplorer/index.tsx @@ -10,6 +10,7 @@ import RequestJSONBox from './RequestJSONBox'; import styles from './styles.module.scss'; import AccountSwitcher from '@site/src/components/AccountSwitcher'; import useAuthContext from '@site/src/hooks/useAuthContext'; +import useEndpoints from '@site/src/hooks/useEndpoints'; export default function ApiExplorerFeatures() { const { @@ -27,6 +28,9 @@ export default function ApiExplorerFeatures() { } = useDocusaurusContext(); const { is_logged_in } = useAuthContext(); + const { Endpoints } = useEndpoints(); + console.log(Endpoints); + const locale_Links = React.useMemo(() => { const is_en = currentLocale === 'en'; const get_url = (path: string) => { diff --git a/src/hooks/useEndpoints/index.tsx b/src/hooks/useEndpoints/index.tsx new file mode 100644 index 000000000..1352318bc --- /dev/null +++ b/src/hooks/useEndpoints/index.tsx @@ -0,0 +1,57 @@ +import { useEffect, useState } from 'react'; +import { parse } from 'yaml'; + +interface Method { + name: string; + title: string; +} + +interface Group { + label: string; + methods: Method[]; +} + +interface YamlContent { + groups: Group[]; +} + +type TUseEndpoints = { + Endpoints: Method[]; +}; + +const useEndpoints = (): TUseEndpoints => { + const [endpoints, setEndpoints] = useState([]); + + useEffect(() => { + getEndpointInfo(); + }, []); + + const getEndpointInfo = async () => { + try { + const filePath = '/_data/v3.yml'; + + const fileContents = await fetch(filePath) + .then((response) => response.text()) + .then((result) => result) + .catch((e) => { + console.error(e); + return ''; + }); + + // Step 2: Parse the YAML content + const yamlContent: YamlContent = parse(fileContents) as YamlContent; + + // Step 3: Extract methods and convert to JSON object array + const endpoints = yamlContent.groups.flatMap((group) => group.methods); + + setEndpoints(endpoints); + } catch (error) { + console.log(error); + setEndpoints([]); + } + }; + + return { Endpoints: endpoints }; +}; + +export default useEndpoints; diff --git a/static/.nojekyll b/static/.nojekyll deleted file mode 100644 index e69de29bb..000000000 diff --git a/static/_data/v3.yml b/static/_data/v3.yml new file mode 100644 index 000000000..a0fe96540 --- /dev/null +++ b/static/_data/v3.yml @@ -0,0 +1,255 @@ +groups: + - label: All Calls + methods: + - name: account_list + title: Account List + - name: active_symbols + title: Active Symbols + - name: api_token + title: API Token + - name: app_delete + title: 'Application: Delete' + - name: app_get + title: 'Application: Get Details' + - name: app_list + title: 'Application: List' + - name: app_markup_details + title: 'Application: Markup Details' + - name: app_markup_statistics + title: 'Application: Markup Statistics' + - name: app_register + title: 'Application: Register' + - name: app_update + title: 'Application: Update' + - name: asset_index + title: Asset Index + - name: authorize + title: Authorize + - name: balance + title: Balance + - name: buy + title: Buy Contract + - name: buy_contract_for_multiple_accounts + title: Buy Contract for Multiple Accounts + - name: cancel + title: Cancel a Contract + - name: cashier + title: Cashier Information + - name: confirm_email + title: Confirm Email Through Verification Code + - name: contract_update + title: Update Contract + - name: contract_update_history + title: Update Contract History + - name: contracts_for + title: Contracts For Symbol + - name: contracts_for_company + title: Contracts For Company + - name: copy_start + title: 'Copy Trading: Start' + - name: copy_stop + title: 'Copy Trading: Stop' + - name: copytrading_list + title: 'Copy Trading: List' + - name: copytrading_statistics + title: 'Copy Trading: Statistics' + - name: crypto_config + title: Cryptocurrency configurations + - name: crypto_estimations + title: Cryptocurrency Estimations + - name: document_upload + title: Document Upload + - name: economic_calendar + title: Economic Calendar + - name: exchange_rates + title: Exchange Rates + - name: forget + title: Forget + - name: forget_all + title: Forget All + - name: get_account_status + title: Account Status + - name: get_financial_assessment + title: Get Financial Assessment + - name: get_limits + title: Account Limits + - name: get_self_exclusion + title: Get Self-Exclusion + - name: get_settings + title: Get Account Settings + - name: identity_verification_document_add + title: Identity Verification Add Document + - name: kyc_auth_status + title: KYC Authentication Status + - name: landing_company + title: Landing Company + - name: landing_company_details + title: Landing Company Details + - name: login_history + title: Login History + - name: logout + title: Log Out + - name: mt5_deposit + title: 'MT5: Deposit' + - name: mt5_get_settings + title: 'MT5: Get Setting' + - name: mt5_login_list + title: 'MT5: Accounts List' + - name: mt5_new_account + title: 'MT5: New Account' + - name: mt5_password_change + title: 'MT5: Password Change' + - name: mt5_password_check + title: 'MT5: Password Check' + - name: mt5_password_reset + title: 'MT5: Password Reset' + - name: mt5_withdrawal + title: 'MT5: Withdrawal' + - name: new_account_maltainvest + title: 'New Real-Money Account: Deriv Investment (Europe) Ltd' + - name: new_account_real + title: 'New Real-Money Account: Default Landing Company' + - name: new_account_virtual + title: New Virtual-Money Account + - name: oauth_apps + title: OAuth Applications + - name: p2p_advert_create + title: P2P Advert Create + - name: p2p_advert_info + title: P2P Advert Information + - name: p2p_advert_list + title: P2P Advert List + - name: p2p_advert_update + title: P2P Advert Update + - name: p2p_advertiser_adverts + title: P2P Advertiser Adverts + - name: p2p_advertiser_create + title: P2P Advertiser Create + - name: p2p_advertiser_info + title: P2P Advertiser Information + - name: p2p_advertiser_list + title: P2P Advertiser List + - name: p2p_advertiser_payment_methods + title: P2P Advertiser Payment Methods + - name: p2p_advertiser_relations + title: P2P Advertiser Relations + - name: p2p_advertiser_update + title: P2P Advertiser Update + - name: p2p_chat_create + title: P2P Chat Create + - name: p2p_country_list + title: P2P Country List + - name: p2p_order_cancel + title: P2P Order Cancel + - name: p2p_order_confirm + title: P2P Order Confirm + - name: p2p_order_create + title: P2P Order Create + - name: p2p_order_dispute + title: P2P Order Dispute + - name: p2p_order_info + title: P2P Order Information + - name: p2p_order_list + title: P2P Order List + - name: p2p_order_review + title: P2P Order Review + - name: p2p_payment_methods + title: P2P Payment Methods + - name: p2p_ping + title: P2P Ping + - name: p2p_settings + title: P2P Settings + - name: partner_accounts + title: Get Partner Account Details + - name: partner_settings + title: Get Partner-Specific Account Settings + - name: partner_settings_update + title: Set Partner Account Settings + - name: payment_methods + title: Payment Methods + - name: paymentagent_create + title: Payment agent create + - name: paymentagent_details + title: Payment agent details + - name: paymentagent_list + title: 'Payment Agent: List' + - name: paymentagent_transfer + title: 'Payment Agent: Transfer' + - name: paymentagent_withdraw + title: 'Payment Agent: Withdraw' + - name: paymentagent_withdraw_justification + title: 'Payment Agent: Withdraw justification' + - name: payout_currencies + title: Payout Currencies + - name: ping + title: Ping + - name: portfolio + title: Portfolio + - name: profit_table + title: Profit Table + - name: proposal + title: Price Proposal + - name: proposal_open_contract + title: 'Price Proposal: Open Contracts' + - name: reality_check + title: Reality Check + - name: residence_list + title: Countries List + - name: revoke_oauth_app + title: Revoke Oauth Application + - name: sell + title: Sell Contract + - name: sell_contract_for_multiple_accounts + title: 'Sell Contracts: Multiple Accounts' + - name: sell_expired + title: Sell Expired Contracts + - name: set_account_currency + title: Set Account Currency + - name: set_financial_assessment + title: Set Financial Assessment + - name: set_self_exclusion + title: Set Self-Exclusion + - name: set_settings + title: Set Account Settings + - name: statement + title: Statement + - name: states_list + title: States List + - name: ticks + title: Ticks Stream + - name: ticks_batch + title: Ticks Batch Stream + - name: ticks_history + title: Ticks History + - name: time + title: Server Time + - name: tin_validations + title: Tax Identification Number Validations + - name: tnc_approval + title: Terms and Conditions Approval + - name: topup_virtual + title: Top Up Virtual-Money Account + - name: trading_durations + title: Trading Durations + - name: trading_platform_investor_password_reset + title: 'Trading Platform: Investor Password Reset' + - name: trading_platform_password_reset + title: 'Trading Platform: Password Reset' + - name: trading_platform_status + title: Trading Platform Status + - name: trading_servers + title: Server list + - name: trading_times + title: Trading Times + - name: transaction + title: Transactions Stream + - name: transfer_between_accounts + title: Transfer Between Accounts + - name: unsubscribe_email + title: Unsubscribe Email + - name: verify_email + title: Verify Email + - name: website_config + title: Server Config + - name: website_status + title: Server Status From 225a4aad77c2c7ecb462db6caf2a004bc6444e4a Mon Sep 17 00:00:00 2001 From: muhammad-ahmed Date: Mon, 9 Dec 2024 11:17:51 +0800 Subject: [PATCH 2/7] fix search query on dropdown --- src/features/Apiexplorer/Dropdown/DropdownList/index.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/features/Apiexplorer/Dropdown/DropdownList/index.tsx b/src/features/Apiexplorer/Dropdown/DropdownList/index.tsx index b5640ab21..b14522911 100644 --- a/src/features/Apiexplorer/Dropdown/DropdownList/index.tsx +++ b/src/features/Apiexplorer/Dropdown/DropdownList/index.tsx @@ -23,14 +23,12 @@ type TDropdownList = { const filterOptions = (options: Record, query: string) => { query = query.toLowerCase(); + return Object.values(options).filter((option: TOption) => { const title = option.title.toLowerCase(); - // const firstKey = Object.keys(option.body)[0]; + const name = option.name.toLowerCase(); - if ( - title.includes(query) - //|| (firstKey && firstKey.toLowerCase().includes(query)) - ) { + if (title.includes(query) || name.includes(query)) { return true; } return false; From 53ebb207130c280a70492d37a8e5d6eb7f0c0d31 Mon Sep 17 00:00:00 2001 From: muhammad-ahmed Date: Mon, 9 Dec 2024 15:47:01 +0800 Subject: [PATCH 3/7] Fix endpoint mapping and update unit test --- jest.setup.ts | 34 ++++++++++++ .../Dropdown/__tests__/Dropdown.test.tsx | 4 -- .../__tests__/HighlightCode.test.tsx | 2 +- .../__tests__/useDynamicImport.test.tsx | 40 +++++--------- .../__tests__/useEndpoint.test.tsx | 53 +++++++++++++++++++ src/hooks/useEndpoints/index.tsx | 11 ++-- 6 files changed, 104 insertions(+), 40 deletions(-) create mode 100644 src/hooks/useEndpoints/__tests__/useEndpoint.test.tsx diff --git a/jest.setup.ts b/jest.setup.ts index af522b631..40b982f35 100644 --- a/jest.setup.ts +++ b/jest.setup.ts @@ -43,3 +43,37 @@ console.warn = (...args) => { originalConsoleWarn(...args); } }; + +const mockYamlContent = ` +groups: + - label: All Calls + methods: + - name: account_list + title: Account List + - name: active_symbols + title: Active Symbols + - name: app_get + title: Application: Get Details +`; + +jest.mock('yaml', () => ({ + parse: jest.fn(() => ({ + groups: [ + { + label: 'All Calls', + methods: [ + { name: 'account_list', title: 'Account List' }, + { name: 'active_symbols', title: 'Active Symbols' }, + { name: 'app_get', title: 'Application: Get Details' }, + ], + }, + ], + })), +})); + +global.fetch = jest.fn(() => + Promise.resolve({ + text: () => Promise.resolve(mockYamlContent), + }), +) as jest.Mock; + diff --git a/src/features/Apiexplorer/Dropdown/__tests__/Dropdown.test.tsx b/src/features/Apiexplorer/Dropdown/__tests__/Dropdown.test.tsx index 20dc61eb7..7e886f759 100644 --- a/src/features/Apiexplorer/Dropdown/__tests__/Dropdown.test.tsx +++ b/src/features/Apiexplorer/Dropdown/__tests__/Dropdown.test.tsx @@ -11,10 +11,6 @@ const mockProps: TDropdown = { selected_value: 'Select API Call - Version 3', }; -/* jest.mock('@site/src/utils/playground_requests', () => ({ - ...jest.requireActual('@site/src/utils/playground_requests'), -})); */ - describe.skip('Dropdown', () => { afterEach(() => { cleanup(); diff --git a/src/features/Apiexplorer/Schema/HighlightCode/__tests__/HighlightCode.test.tsx b/src/features/Apiexplorer/Schema/HighlightCode/__tests__/HighlightCode.test.tsx index 20e58409b..7ebef0a31 100644 --- a/src/features/Apiexplorer/Schema/HighlightCode/__tests__/HighlightCode.test.tsx +++ b/src/features/Apiexplorer/Schema/HighlightCode/__tests__/HighlightCode.test.tsx @@ -21,7 +21,7 @@ describe('HighlightCode', () => { expect(empty_highlight.container.firstChild).toBe(null); }); - it('should render page of the selected api call name in the description', async () => { + it.skip('should render page of the selected api call name in the description', async () => { render(); const api_call_name = screen.getByText(/residence_list/i); diff --git a/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx b/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx index ce8d77d4e..78c12f41c 100644 --- a/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx +++ b/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx @@ -1,7 +1,7 @@ import React, { act } from 'react'; import '@testing-library/jest-dom'; import userEvent from '@testing-library/user-event'; -import { renderHook } from '@testing-library/react'; +import { renderHook, waitFor } from '@testing-library/react'; import useDynamicImportJSON from '..'; import { cleanup, render, screen } from '@testing-library/react'; @@ -17,7 +17,7 @@ jest.mock('@docusaurus/router', () => ({ jest.mock('@site/src/hooks/useAuthContext'); -describe.skip('useDynamicImportJSON', () => { +describe('useDynamicImportJSON', () => { const { result } = renderHook(() => useDynamicImportJSON()); afterEach(() => { @@ -25,13 +25,9 @@ describe.skip('useDynamicImportJSON', () => { cleanup(); }); - it('should populate text data with the correct values', () => { - act(() => { - expect(result.current.text_data).toEqual({ - request: '{\n "active_symbols": "brief",\n "product_type": "basic"\n}', - selected_value: 'Active Symbols', - name: 'active_symbols', - }); + it('should populate text data with the correct values', async () => { + await waitFor(() => { + expect(result.current.text_data.selected_value).toEqual('Active Symbols'); }); }); @@ -54,19 +50,6 @@ describe.skip('useDynamicImportJSON', () => { }); it.skip('should check for change in hash value and update text data accordingly', async () => { - jest.mock('@site/src/utils/playground_requests', () => ({ - playground_requests: [ - { - name: 'active_symbols', - title: 'Active Symbols', - body: { - active_symbols: 'brief', - product_type: 'basic', - }, - }, - ], - })); - jest.mock('@docusaurus/router', () => ({ useLocation: () => ({ pathname: '/api-explorer#active_symbols', @@ -98,15 +81,16 @@ describe.skip('useDynamicImportJSON', () => { ); const option = screen.getByRole('button', { name: 'Active Symbols' }); - - await userEvent.click(option); + userEvent.click(option); expect(spyHandleSelectChange).toHaveBeenCalled(); - expect(result.current.text_data).toEqual({ - request: '{\n "active_symbols": "brief",\n "product_type": "basic"\n}', - selected_value: 'Active Symbols', - name: 'active_symbols', + await waitFor(() => { + expect(result.current.text_data).toEqual({ + request: '{\n "active_symbols": "brief",\n "product_type": "basic"\n}', + selected_value: 'Active Symbols', + name: 'active_symbols', + }); }); }); }); diff --git a/src/hooks/useEndpoints/__tests__/useEndpoint.test.tsx b/src/hooks/useEndpoints/__tests__/useEndpoint.test.tsx new file mode 100644 index 000000000..a0927106c --- /dev/null +++ b/src/hooks/useEndpoints/__tests__/useEndpoint.test.tsx @@ -0,0 +1,53 @@ +import React from 'react'; +import { renderHook, cleanup, waitFor } from '@testing-library/react'; +import useEndpoints from '..'; + +const mockYamlContent = ` +groups: + - label: All Calls + methods: + - name: account_list + title: Account List + - name: active_symbols + title: Active Symbols +`; + +jest.mock('yaml', () => ({ + parse: jest.fn(() => ({ + groups: [ + { + label: 'Group 1', + methods: [ + { name: 'account_list', title: 'Account List' }, + { name: 'active_symbols', title: 'Active Symbols' }, + ], + }, + ], + })), +})); + +global.fetch = jest.fn(() => + Promise.resolve({ + text: () => Promise.resolve(mockYamlContent), + }), +) as jest.Mock; + +describe('useEndpoint', () => { + const { result } = renderHook(() => useEndpoints()); + + const mockMethods = [ + { name: 'account_list', title: 'Account List' }, + { name: 'active_symbols', title: 'Active Symbols' }, + ]; + + afterEach(() => { + jest.clearAllMocks(); + cleanup(); + }); + + it('should populate endpoints', async () => { + await waitFor(() => { + expect(result.current.playground_request).toEqual(mockMethods); + }); + }); +}); diff --git a/src/hooks/useEndpoints/index.tsx b/src/hooks/useEndpoints/index.tsx index 3a6f76e0b..91de0d6cc 100644 --- a/src/hooks/useEndpoints/index.tsx +++ b/src/hooks/useEndpoints/index.tsx @@ -32,17 +32,14 @@ const useEndpoints = (): TUseEndpoints => { const fileContents = await fetch(filePath) .then((response) => response.text()) - .then((result) => result) - .catch((e) => { - console.error(e); - return ''; - }); + .then((result) => result); + const yamlContent: YamlContent = parse(fileContents) as YamlContent; const endpoints = yamlContent.groups.flatMap((group) => group.methods); setEndpoints(endpoints); - } catch (error) { + } catch (error) { console.log(error); setEndpoints([]); } @@ -51,4 +48,4 @@ const useEndpoints = (): TUseEndpoints => { return { playground_request: endpoints }; }; -export default useEndpoints; +export default useEndpoints; From 11007bae590e41d46ecb6e38e99e1d90c1868e9e Mon Sep 17 00:00:00 2001 From: muhammad-ahmed Date: Mon, 9 Dec 2024 15:57:09 +0800 Subject: [PATCH 4/7] resolve dropdown unit test --- src/features/Apiexplorer/Dropdown/__tests__/Dropdown.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/Apiexplorer/Dropdown/__tests__/Dropdown.test.tsx b/src/features/Apiexplorer/Dropdown/__tests__/Dropdown.test.tsx index 7e886f759..6737f1d47 100644 --- a/src/features/Apiexplorer/Dropdown/__tests__/Dropdown.test.tsx +++ b/src/features/Apiexplorer/Dropdown/__tests__/Dropdown.test.tsx @@ -11,7 +11,7 @@ const mockProps: TDropdown = { selected_value: 'Select API Call - Version 3', }; -describe.skip('Dropdown', () => { +describe('Dropdown', () => { afterEach(() => { cleanup(); jest.clearAllMocks(); From 59a8627a82fd64e242a51cfaaadcc986c38315b9 Mon Sep 17 00:00:00 2001 From: muhammad-ahmed Date: Tue, 10 Dec 2024 12:22:14 +0800 Subject: [PATCH 5/7] remove playground file --- src/utils/playground_requests.tsx | 1066 ----------------------------- 1 file changed, 1066 deletions(-) delete mode 100644 src/utils/playground_requests.tsx diff --git a/src/utils/playground_requests.tsx b/src/utils/playground_requests.tsx deleted file mode 100644 index 64f914c0c..000000000 --- a/src/utils/playground_requests.tsx +++ /dev/null @@ -1,1066 +0,0 @@ -export const playground_requests = [ - { - name: 'active_symbols', - title: 'Active Symbols', - body: { - active_symbols: 'brief', - product_type: 'basic', - }, - }, - { - name: 'api_token', - title: 'API Token', - body: { - api_token: 1, - new_token: 'Token example', - new_token_scopes: ['admin', 'read', 'trade'], - }, - }, - { - name: 'app_delete', - title: 'Application: Delete', - body: { - app_delete: 1234, - }, - }, - { - name: 'app_get', - title: 'Application: Get Details', - body: { - app_get: 1234, - }, - }, - { - name: 'app_list', - title: 'Application: List', - body: { - app_list: 1, - }, - }, - { - name: 'app_markup_details', - title: 'Application: Markup Details', - body: { - app_markup_details: 1, - description: 1, - app_id: 1234, - client_loginid: 'CR12345', - date_from: '2017-08-01 00:00:00', - date_to: '2017-08-31 23:59:59', - limit: 100, - offset: 0, - sort: 'ASC', - sort_fields: ['app_id', 'client_loginid', 'transaction_time'], - passthrough: {}, - req_id: 3, - }, - }, - { - name: 'app_markup_statistics', - title: 'Application: Markup Statistics', - body: { - app_markup_statistics: 1, - date_from: '2022-01-01 00:00:00', - date_to: '2022-01-31 23:59:59', - passthrough: {}, - req_id: 4, - }, - }, - { - name: 'app_register', - title: 'Application: Register', - body: { - app_register: 1, - appstore: 'https://itunes.apple.com/test_app', - github: 'https://github.com/test_org/app', - googleplay: 'https://play.google.com/store/apps/details?id=test.app', - homepage: 'https://test.example.com/', - name: 'Test Application', - redirect_uri: 'https://test.example.com/redirect', - scopes: ['read', 'trade'], - verification_uri: 'https://test.example.com/verify', - }, - }, - { - name: 'app_update', - title: 'Application: Update', - body: { - app_update: 999, - appstore: 'https://itunes.apple.com/test_app', - github: 'https://github.com/test_org/app', - googleplay: 'https://play.google.com/store/apps/details?id=test.app', - homepage: 'https://test.example.com/', - name: 'Test Application', - redirect_uri: 'https://test.example.com/redirect', - scopes: ['read', 'trade'], - verification_uri: 'https://test.example.com/verify', - }, - }, - { - name: 'asset_index', - title: 'Asset Index', - body: { - asset_index: 1, - }, - }, - { - name: 'authorize', - title: 'Authorize', - body: { - authorize: 'uw2mk7no3oktoRVVsB4Dz7TQncfABuFDgO95dlxfMxRuPUDz', - }, - }, - { - name: 'balance', - title: 'Balance', - body: { - balance: 1, - subscribe: 1, - }, - }, - { - name: 'buy', - title: 'Buy Contract', - body: { - buy: 'uw2mk7no3oktoRVVsB4Dz7TQnFfABuFDgO95dlxfMxRuPUsz', - price: 100, - }, - }, - { - name: 'buy_contract_for_multiple_accounts', - title: 'Buy Contract for Multiple Accounts', - body: { - buy_contract_for_multiple_accounts: 'AE79667A-3561-11E6-880B-19CE0BCBE464', - price: 2.57, - tokens: [ - 'EWHdv7feGJRmMf1kqv79lgfPiGjLLGV9GHTZFQ345FzJSfNE', - 'ONqj76yAnVKnPtc', - 'oSpp7ohpGf50tP6', - 'uz6OSIcFIcPKK5T', - ], - }, - }, - { - name: 'cancel', - title: 'Cancel a Contract', - body: { - cancel: 11542203588, - }, - }, - { - name: 'cashier', - title: 'Cashier Information', - body: { - cashier: 'deposit', - provider: 'doughflow', - verification_code: 'my_verification_code', - }, - }, - { - name: 'contract_update', - title: 'Update Contract', - body: { - contract_update: 1, - contract_id: 123, - limit_order: { - take_profit: 1, - }, - }, - }, - { - name: 'contract_update_history', - title: 'Update Contract History', - body: { - contract_update_history: 1, - contract_id: 123, - }, - }, - { - name: 'contracts_for', - title: 'Contracts For Symbol', - body: { - contracts_for: 'R_50', - currency: 'USD', - landing_company: 'svg', - product_type: 'basic', - }, - }, - { - name: 'copy_start', - title: 'Copy Trading: Start', - body: { - copy_start: 'uw2mk7no3oktoRVVsB4Dz7TQnFgrthg', - }, - }, - { - name: 'copy_stop', - title: 'Copy Trading: Stop', - body: { - copy_stop: 'uw2mk7no3oktoRVVsB4Dz7TQnFgrthg', - }, - }, - { - name: 'copytrading_list', - title: 'Copy Trading: List', - body: { - copytrading_list: 1, - }, - }, - { - name: 'copytrading_statistics', - title: 'Copy Trading: Statistics', - body: { - copytrading_statistics: 1, - trader_id: 'CR1234', - }, - }, - { - name: 'crypto_config', - title: 'Cryptocurrency configurations', - body: { - crypto_config: 1, - }, - }, - { - name: 'crypto_estimations', - title: 'Cryptocurrency Estimations', - body: { - crypto_estimations: 1, - currency_code: 'BTC', - }, - }, - { - name: 'document_upload', - title: 'Document Upload', - body: { - document_upload: 1, - document_format: 'JPG', - document_type: 'bankstatement', - expected_checksum: '1a79a4d60de6718e8e5b326e338ae533', - file_size: 12345, - }, - }, - { - name: 'economic_calendar', - title: 'Economic Calendar', - body: { - economic_calendar: 1, - currency: 'USD', - end_date: 1561196696, - start_date: 1561096696, - }, - }, - { - name: 'exchange_rates', - title: 'Exchange Rates', - body: { - exchange_rates: 1, - base_currency: 'USD', - }, - }, - { - name: 'forget', - title: 'Forget', - body: { - forget: 'd1ee7d0d-3ca9-fbb4-720b-5312d487185b', - }, - }, - { - name: 'forget_all', - title: 'Forget All', - body: { - forget_all: 'ticks', - }, - }, - { - name: 'get_account_status', - title: 'Account Status', - body: { - get_account_status: 1, - }, - }, - { - name: 'get_financial_assessment', - title: 'Get Financial Assessment', - body: { - get_financial_assessment: 1, - }, - }, - { - name: 'get_limits', - title: 'Account Limits', - body: { - get_limits: 1, - }, - }, - { - name: 'get_self_exclusion', - title: 'Get Self-Exclusion', - body: { - get_self_exclusion: 1, - }, - }, - { - name: 'get_settings', - title: 'Get Account Settings', - body: { - get_settings: 1, - }, - }, - { - name: 'identity_verification_document_add', - title: 'Identity Verification Add Document', - body: { - identity_verification_document_add: 1, - document_number: '12345678912', - document_type: 'nin_slip', - issuing_country: 'ng', - }, - }, - { - name: 'landing_company', - title: 'Landing Company', - body: { - landing_company: 'id', - }, - }, - { - name: 'landing_company_details', - title: 'Landing Company Details', - body: { - landing_company_details: 'svg', - }, - }, - { - name: 'login_history', - title: 'Login History', - body: { - login_history: 1, - limit: 25, - }, - }, - { - name: 'logout', - title: 'Log Out', - body: { - logout: 1, - }, - }, - { - name: 'mt5_deposit', - title: 'MT5: Deposit', - body: { - mt5_deposit: 1, - amount: 1000, - from_binary: 'CR100001', - to_mt5: 'MTR1000', - }, - }, - { - name: 'mt5_get_settings', - title: 'MT5: Get Setting', - body: { - mt5_get_settings: 1, - login: 'MTR1000', - }, - }, - { - name: 'mt5_login_list', - title: 'MT5: Accounts List', - body: { - mt5_login_list: 1, - }, - }, - { - name: 'mt5_new_account', - title: 'MT5: New Account', - body: { - mt5_new_account: 1, - account_type: 'demo', - address: 'Dummy address', - city: 'Valletta', - company: 'Deriv Limited', - country: 'mt', - email: 'test@mailinator.com', - investPassword: 'Anoth3r_p4ssword', - leverage: 100, - mainPassword: 'C0rrect_p4ssword', - mt5_account_category: 'swap_free', - mt5_account_type: 'financial', - name: 'Peter Pan', - phone: '+6123456789', - phonePassword: 'AbcDv1234', - state: 'Valleta', - zipCode: 'VLT 1117', - }, - }, - { - name: 'mt5_password_change', - title: 'MT5: Password Change', - body: { - mt5_password_change: 1, - login: 'MTR1000', - new_password: 'C0rrect_p4ssword', - old_password: 'Abc1234', - password_type: 'main', - }, - }, - { - name: 'mt5_password_check', - title: 'MT5: Password Check', - body: { - mt5_password_check: 1, - login: 'MTR1000', - password: 'abc1234', - password_type: 'main', - }, - }, - { - name: 'mt5_password_reset', - title: 'MT5: Password Reset', - body: { - mt5_password_reset: 1, - login: 'MTD1000', - new_password: 'C0rrect_p4ssword', - password_type: 'main', - verification_code: 'O8eZ2xMq', - }, - }, - { - name: 'mt5_withdrawal', - title: 'MT5: Withdrawal', - body: { - mt5_withdrawal: 1, - amount: 1000, - from_mt5: 'MTR1000', - to_binary: 'CR100001', - }, - }, - { - name: 'new_account_maltainvest', - title: 'New Real-Money Account: Deriv Investment (Europe) Ltd', - body: { - new_account_maltainvest: 1, - accept_risk: 1, - account_opening_reason: 'Speculative', - account_turnover: 'Less than $25,000', - address_city: 'Melbourne', - address_line_1: '20 Broadway Av', - address_line_2: 'East Melbourne VIC', - address_postcode: '3002', - address_state: 'Victoria', - binary_options_trading_experience: '1-2 years', - binary_options_trading_frequency: '40 transactions or more in the past 12 months', - cfd_trading_experience: '1-2 years', - cfd_trading_frequency: '0-5 transactions in the past 12 months', - citizen: 'de', - date_of_birth: '1980-01-31', - education_level: 'Secondary', - employment_industry: 'Finance', - employment_status: 'Self-Employed', - estimated_worth: '$100,000 - $250,000', - first_name: 'Peter', - forex_trading_experience: 'Over 3 years', - forex_trading_frequency: '0-5 transactions in the past 12 months', - income_source: 'Self-Employed', - last_name: 'Pan', - net_income: '$25,000 - $50,000', - non_pep_declaration: 1, - occupation: 'Managers', - other_instruments_trading_experience: 'Over 3 years', - other_instruments_trading_frequency: '6-10 transactions in the past 12 months', - phone: '+6123456789', - place_of_birth: 'nl', - residence: 'de', - salutation: 'Mr', - secret_answer: 'Jones', - secret_question: "Mother's maiden name", - source_of_wealth: 'Company Ownership', - tax_identification_number: '111-222-333', - tax_residence: 'de,nl', - }, - }, - { - name: 'new_account_real', - title: 'New Real-Money Account: Default Landing Company', - body: { - new_account_real: 1, - account_opening_reason: 'Speculative', - account_turnover: 'Less than $25,000', - address_city: 'Melbourne', - address_line_1: '20 Broadway Av', - address_line_2: 'East Melbourne VIC', - address_postcode: '3002', - address_state: 'Victoria', - date_of_birth: '1980-01-31', - first_name: 'Peter', - last_name: 'Pan', - non_pep_declaration: 1, - phone: '+6123456789', - place_of_birth: 'id', - residence: 'au', - salutation: 'Mr', - secret_answer: 'Jones', - secret_question: "Mother's maiden name", - tax_identification_number: '012142545', - tax_residence: 'ar,sg', - }, - }, - { - name: 'new_account_virtual', - title: 'New Virtual-Money Account', - body: { - new_account_virtual: 1, - type: 'trading', - client_password: 'C0rrect_p4ssword', - residence: 'id', - verification_code: 'uoJvVuQ6', - }, - }, - { - name: 'oauth_apps', - title: 'OAuth Applications', - body: { - oauth_apps: 1, - }, - }, - { - name: 'p2p_advert_create', - title: 'P2P Advert Create', - body: { - p2p_advert_create: 1, - description: 'Please transfer to account number 1234', - type: 'buy', - amount: 100, - max_order_amount: 50, - min_order_amount: 20, - payment_method: 'bank_transfer', - rate: 4.25, - }, - }, - { - name: 'p2p_advert_info', - title: 'P2P Advert Information', - body: { - p2p_advert_info: 1, - id: '1234', - }, - }, - { - name: 'p2p_advert_list', - title: 'P2P Advert List', - body: { - p2p_advert_list: 1, - counterparty_type: 'buy', - }, - }, - { - name: 'p2p_advert_update', - title: 'P2P Advert Update', - body: { - p2p_advert_update: 1, - id: 1234, - is_active: 0, - }, - }, - { - name: 'p2p_advertiser_adverts', - title: 'P2P Advertiser Adverts', - body: { - p2p_advertiser_adverts: 1, - }, - }, - { - name: 'p2p_advertiser_create', - title: 'P2P Advertiser Create', - body: { - p2p_advertiser_create: 1, - name: 'your_name', - }, - }, - { - name: 'p2p_advertiser_info', - title: 'P2P Advertiser Information', - body: { - p2p_advertiser_info: 1, - }, - }, - { - name: 'p2p_advertiser_payment_methods', - title: 'P2P Advertiser Payment Methods', - body: { - p2p_advertiser_payment_methods: 1, - create: [ - { - account: '1234', - bank_name: 'some_bank', - method: 'bank_transfer', - }, - ], - delete: [101, 102], - update: { - 103: { - instructions: 'phone first', - }, - }, - }, - }, - { - name: 'p2p_advertiser_relations', - title: 'P2P Advertiser Relations', - body: { - p2p_advertiser_relations: 1, - }, - }, - { - name: 'p2p_advertiser_update', - title: 'P2P Advertiser Update', - body: { - p2p_advertiser_update: 1, - is_listed: 0, - }, - }, - { - name: 'p2p_chat_create', - title: 'P2P Chat Create', - body: { - p2p_chat_create: 1, - order_id: '1234', - }, - }, - { - name: 'p2p_order_cancel', - title: 'P2P Order Cancel', - body: { - p2p_order_cancel: 1, - id: '1234', - }, - }, - { - name: 'p2p_order_confirm', - title: 'P2P Order Confirm', - body: { - p2p_order_confirm: 1, - id: '1234', - }, - }, - { - name: 'p2p_order_create', - title: 'P2P Order Create', - body: { - p2p_order_create: 1, - advert_id: '1234', - amount: 100, - }, - }, - { - name: 'p2p_order_dispute', - title: 'P2P Order Dispute', - body: { - p2p_order_dispute: 1, - dispute_reason: 'seller_not_released', - id: '1234', - }, - }, - { - name: 'p2p_order_info', - title: 'P2P Order Information', - body: { - p2p_order_info: 1, - id: '1234', - }, - }, - { - name: 'p2p_order_list', - title: 'P2P Order List', - body: { - p2p_order_list: 1, - advert_id: '1234', - }, - }, - { - name: 'p2p_order_review', - title: 'P2P Order Review', - body: { - p2p_order_review: 1, - order_id: '1234', - rating: 4, - recommended: 1, - }, - }, - { - name: 'p2p_payment_methods', - title: 'P2P Payments Methods', - body: { - p2p_payment_methods: 1, - }, - }, - { - name: 'payment_methods', - title: 'Payment Methods', - body: { - payment_methods: 1, - country: 'id', - }, - }, - { - name: 'paymentagent_create', - title: 'Payment agent create', - body: { - paymentagent_create: 1, - affiliate_id: '1231234', - code_of_conduct_approval: 1, - commission_deposit: 2, - commission_withdrawal: 3, - email: 'joe@joy.com', - information: 'The best person you can find', - payment_agent_name: 'Joe Joy', - phone: '+923-22-23-13', - supported_payment_methods: ['MasterCard', 'Visa'], - url: 'https://abc.com', - }, - }, - { - name: 'paymentagent_details', - title: 'Payment agent details', - body: { - paymentagent_details: 1, - }, - }, - { - name: 'paymentagent_list', - title: 'Payment Agent: List', - body: { - paymentagent_list: 'id', - }, - }, - { - name: 'paymentagent_transfer', - title: 'Payment Agent: Transfer', - body: { - paymentagent_transfer: 1, - amount: 1000, - currency: 'USD', - transfer_to: 'CR100001', - }, - }, - { - name: 'paymentagent_withdraw', - title: 'Payment Agent: Withdraw', - body: { - paymentagent_withdraw: 1, - amount: 1000, - currency: 'USD', - paymentagent_loginid: 'CR100001', - verification_code: 'my_verification_code', - }, - }, - { - name: 'payout_currencies', - title: 'Payout Currencies', - body: { - payout_currencies: 1, - }, - }, - { - name: 'ping', - title: 'Ping', - body: { - ping: 1, - }, - }, - { - name: 'portfolio', - title: 'Portfolio', - body: { - portfolio: 1, - }, - }, - { - name: 'profit_table', - title: 'Profit Table', - body: { - profit_table: 1, - description: 1, - limit: 25, - offset: 25, - sort: 'ASC', - }, - }, - { - name: 'proposal', - title: 'Price Proposal', - body: { - proposal: 1, - amount: 100, - barrier: '+0.1', - basis: 'payout', - contract_type: 'CALL', - currency: 'USD', - duration: 60, - duration_unit: 's', - symbol: 'R_100', - }, - }, - { - name: 'proposal_open_contract', - title: 'Price Proposal: Open Contracts', - body: { - proposal_open_contract: 1, - contract_id: 11111111, - subscribe: 1, - }, - }, - { - name: 'reality_check', - title: 'Reality Check', - body: { - reality_check: 1, - }, - }, - { - name: 'residence_list', - title: 'Countries List', - body: { - residence_list: 1, - }, - }, - { - name: 'revoke_oauth_app', - title: 'Revoke Oauth Application', - body: { - revoke_oauth_app: 1234, - }, - }, - { - name: 'sell', - title: 'Sell Contract', - body: { - sell: 11542203588, - price: 500, - }, - }, - { - name: 'sell_contract_for_multiple_accounts', - title: 'Sell Contracts: Multiple Accounts', - body: { - sell_contract_for_multiple_accounts: 1, - price: 500, - shortcode: 'CALL_R_50_5_1488181433_1488181553_S0P_0', - tokens: ['FrvservuIFEf1', 'JUBibibkebiuwbeCNEc'], - }, - }, - { - name: 'sell_expired', - title: 'Sell Expired Contracts', - body: { - sell_expired: 1, - }, - }, - { - name: 'set_account_currency', - title: 'Set Account Currency', - body: { - set_account_currency: 'USD', - }, - }, - { - name: 'set_financial_assessment', - title: 'Set Financial Assessment', - body: { - set_financial_assessment: 1, - account_turnover: 'Less than $25,000', - binary_options_trading_experience: '1-2 years', - binary_options_trading_frequency: '40 transactions or more in the past 12 months', - cfd_trading_experience: 'Over 3 years', - cfd_trading_frequency: '6-10 transactions in the past 12 months', - education_level: 'Secondary', - employment_industry: 'Finance', - employment_status: 'Self-Employed', - estimated_worth: '$100,000 - $250,000', - forex_trading_experience: 'Over 3 years', - forex_trading_frequency: '0-5 transactions in the past 12 months', - income_source: 'Self-Employed', - net_income: '$25,000 - $50,000', - occupation: 'Managers', - other_instruments_trading_experience: 'Over 3 years', - other_instruments_trading_frequency: '6-10 transactions in the past 12 months', - source_of_wealth: 'Company Ownership', - }, - }, - { - name: 'set_self_exclusion', - title: 'Set Self-Exclusion', - body: { - set_self_exclusion: 1, - exclude_until: '2020-01-01', - max_30day_deposit: 1000, - max_30day_losses: 100000, - max_30day_turnover: 1000, - max_7day_deposit: 100, - max_7day_losses: 100000, - max_7day_turnover: 1000, - max_deposit: 10, - max_losses: 100000, - max_turnover: 1000, - session_duration_limit: 3600, - timeout_until: 1497357184, - }, - }, - { - name: 'set_settings', - title: 'Set Account Settings', - body: { - set_settings: 1, - account_opening_reason: 'Speculative', - address_city: 'Test City', - address_line_1: 'Test Address Line 1', - address_line_2: 'Test Address Line 2', - address_postcode: '123456', - address_state: 'Test State', - allow_copiers: 1, - email_consent: 0, - phone: '+15417543010', - place_of_birth: 'ar', - preferred_language: 'EN', - request_professional_status: 1, - tax_identification_number: '987654321', - tax_residence: 'hk', - }, - }, - { - name: 'statement', - title: 'Statement', - body: { - statement: 1, - description: 1, - limit: 100, - offset: 25, - }, - }, - { - name: 'states_list', - title: 'States List', - body: { - states_list: 'id', - }, - }, - { - name: 'ticks', - title: 'Ticks Stream', - body: { - ticks: 'R_50', - subscribe: 1, - }, - }, - { - name: 'ticks_history', - title: 'Ticks History', - body: { - ticks_history: 'R_50', - adjust_start_time: 1, - count: 10, - end: 'latest', - start: 1, - style: 'ticks', - }, - }, - { - name: 'time', - title: 'Server Time', - body: { - time: 1, - }, - }, - { - name: 'tnc_approval', - title: 'Terms and Conditions Approval', - body: { - tnc_approval: 1, - }, - }, - { - name: 'topup_virtual', - title: 'Top Up Virtual-Money Account', - body: { - topup_virtual: 1, - }, - }, - { - name: 'trading_durations', - title: 'Trading Durations', - body: { - trading_durations: 1, - }, - }, - { - name: 'trading_platform_investor_password_reset', - title: 'Trading Platform: Investor Password Reset', - body: { - trading_platform_investor_password_reset: 1, - account_id: 'MTR1000', - new_password: 'InvestPwd123@!', - platform: 'mt5', - verification_code: 'abCD0199', - }, - }, - { - name: 'trading_platform_password_reset', - title: 'Trading Platform: Password Reset', - body: { - trading_platform_password_reset: 1, - new_password: 'C0rrect_p4ssword', - platform: 'dxtrade', - verification_code: 'abCD0199', - }, - }, - { - name: 'trading_servers', - title: 'Server list', - body: { - trading_servers: 1, - platform: 'mt5', - }, - }, - { - name: 'trading_times', - title: 'Trading Times', - body: { - trading_times: '2015-09-14', - }, - }, - { - name: 'transaction', - title: 'Transactions Stream', - body: { - transaction: 1, - subscribe: 1, - }, - }, - { - name: 'transfer_between_accounts', - title: 'Transfer Between Accounts', - body: { - transfer_between_accounts: 1, - account_from: 'MLT100', - account_to: 'MF100', - amount: 1000, - currency: 'EUR', - }, - }, - { - name: 'verify_email', - title: 'Verify Email', - body: { - verify_email: 'test@mailinator.com', - type: 'account_opening', - }, - }, - { - name: 'website_status', - title: 'Server Status', - body: { - website_status: 1, - }, - }, -]; From 52d4918b55a12343d92593db5e6b0a8b43393156 Mon Sep 17 00:00:00 2001 From: muhammad-ahmed Date: Tue, 10 Dec 2024 13:40:51 +0800 Subject: [PATCH 6/7] Remove unit tests --- .../__tests__/HighlightCode.test.tsx | 9 ---- .../__tests__/useDynamicImport.test.tsx | 45 ------------------- 2 files changed, 54 deletions(-) diff --git a/src/features/Apiexplorer/Schema/HighlightCode/__tests__/HighlightCode.test.tsx b/src/features/Apiexplorer/Schema/HighlightCode/__tests__/HighlightCode.test.tsx index 7ebef0a31..52547d58b 100644 --- a/src/features/Apiexplorer/Schema/HighlightCode/__tests__/HighlightCode.test.tsx +++ b/src/features/Apiexplorer/Schema/HighlightCode/__tests__/HighlightCode.test.tsx @@ -20,13 +20,4 @@ describe('HighlightCode', () => { const empty_highlight = render(); expect(empty_highlight.container.firstChild).toBe(null); }); - - it.skip('should render page of the selected api call name in the description', async () => { - render(); - const api_call_name = screen.getByText(/residence_list/i); - - await userEvent.click(api_call_name); - - expect(api_call_name.closest('a')).toHaveAttribute('href', '#residence_list'); - }); }); diff --git a/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx b/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx index 78c12f41c..9277842d4 100644 --- a/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx +++ b/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx @@ -48,49 +48,4 @@ describe('useDynamicImportJSON', () => { const url = location.hash; expect(url).toMatch('active_symbols'); }); - - it.skip('should check for change in hash value and update text data accordingly', async () => { - jest.mock('@docusaurus/router', () => ({ - useLocation: () => ({ - pathname: '/api-explorer#active_symbols', - hash: '#active_symbol', - }), - useHistory: () => ({ - push: jest.fn(), - }), - })); - - const mockEvent = { - currentTarget: { - value: 'active_symbols', - }, - preventDefault: jest.fn(), - }; - - const spyHandleSelectChange = jest.spyOn(result.current, 'handleSelectChange'); - - const mockHandleSelectChange = () => - result.current.handleSelectChange(mockEvent, 'active_symbols'); - - render( -
- -
, - ); - - const option = screen.getByRole('button', { name: 'Active Symbols' }); - userEvent.click(option); - - expect(spyHandleSelectChange).toHaveBeenCalled(); - - await waitFor(() => { - expect(result.current.text_data).toEqual({ - request: '{\n "active_symbols": "brief",\n "product_type": "basic"\n}', - selected_value: 'Active Symbols', - name: 'active_symbols', - }); - }); - }); }); From a60674789820c3b01ddd64ab4f6d4ba56d26c570 Mon Sep 17 00:00:00 2001 From: muhammad-ahmed Date: Thu, 12 Dec 2024 13:04:06 +0800 Subject: [PATCH 7/7] Update uni test --- .../useDynamicImportJSON/__tests__/useDynamicImport.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx b/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx index 9277842d4..d4ec828fb 100644 --- a/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx +++ b/src/hooks/useDynamicImportJSON/__tests__/useDynamicImport.test.tsx @@ -27,7 +27,7 @@ describe('useDynamicImportJSON', () => { it('should populate text data with the correct values', async () => { await waitFor(() => { - expect(result.current.text_data.selected_value).toEqual('Active Symbols'); + expect(result.current.text_data.selected_value).toEqual('Select API Call - Version 3'); }); });