From 30ad58b99dd32afca3776fa4a8f43b03fdafcb4b Mon Sep 17 00:00:00 2001 From: Jessy Date: Tue, 17 Dec 2024 21:07:33 +0530 Subject: [PATCH 1/7] Refactor: Simplify CSV export to always use endpoint download --- client/deposits/list/index.tsx | 43 ++----------------- client/disputes/index.tsx | 68 ++---------------------------- client/transactions/list/index.tsx | 31 ++------------ 3 files changed, 10 insertions(+), 132 deletions(-) diff --git a/client/deposits/list/index.tsx b/client/deposits/list/index.tsx index 1ac643d31dc..dd3d737a8fb 100644 --- a/client/deposits/list/index.tsx +++ b/client/deposits/list/index.tsx @@ -312,48 +312,11 @@ export const DepositsList = (): JSX.Element => { const onDownload = async () => { setIsDownloading( true ); - const downloadType = totalRows > rows.length ? 'endpoint' : 'browser'; - if ( 'endpoint' === downloadType ) { - if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { - setCSVExportModalOpen( true ); - } else { - endpointExport( '' ); - } + if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { + setCSVExportModalOpen( true ); } else { - const params = getQuery(); - - const csvColumns = [ - { - ...columns[ 0 ], - label: __( 'Payout Id', 'woocommerce-payments' ), - }, - ...columns.slice( 1 ), - ]; - - const csvRows = rows.map( ( row ) => [ - row[ 0 ], - { - ...row[ 1 ], - value: dateI18n( - 'Y-m-d', - moment.utc( row[ 1 ].value ).toISOString(), - true - ), - }, - ...row.slice( 2 ), - ] ); - - downloadCSVFile( - generateCSVFileName( title, params ), - generateCSVDataFromTable( csvColumns, csvRows ) - ); - - recordEvent( 'wcpay_deposits_download', { - exported_deposits: rows.length, - total_deposits: depositsSummary.count, - download_type: 'browser', - } ); + endpointExport( '' ); } setIsDownloading( false ); diff --git a/client/disputes/index.tsx b/client/disputes/index.tsx index 060afccce35..7471c130d0b 100644 --- a/client/disputes/index.tsx +++ b/client/disputes/index.tsx @@ -444,71 +444,11 @@ export const DisputesList = (): JSX.Element => { const onDownload = async () => { setIsDownloading( true ); - const title = __( 'Disputes', 'woocommerce-payments' ); - const downloadType = totalRows > rows.length ? 'endpoint' : 'browser'; - - if ( 'endpoint' === downloadType ) { - if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { - setCSVExportModalOpen( true ); - } else { - endpointExport( '' ); - } + + if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { + setCSVExportModalOpen( true ); } else { - const csvColumns = [ - { - ...headers[ 0 ], - label: __( 'Dispute Id', 'woocommerce-payments' ), - }, - ...headers.slice( 1, -1 ), // Remove details (position 0) and action (last position) column headers. - ]; - - const csvRows = rows.map( ( row ) => { - return [ - ...row.slice( 0, 3 ), // Amount, Currency, Status. - { - // Reason. - ...row[ 3 ], - value: - disputeStatusMapping[ row[ 3 ].value ?? '' ] - .message, - }, - { - // Source. - ...row[ 4 ], - value: formatStringValue( - ( row[ 4 ].value ?? '' ).toString() - ), - }, - ...row.slice( 5, 10 ), // Order #, Customer, Email, Country. - { - // Disputed On. - ...row[ 10 ], - value: dateI18n( - 'Y-m-d', - moment( row[ 10 ].value ).toISOString() - ), - }, - { - // Respond by. - ...row[ 11 ], - value: dateI18n( - 'Y-m-d / g:iA', - moment( row[ 11 ].value ).toISOString() - ), - }, - ]; - } ); - - downloadCSVFile( - generateCSVFileName( title, getQuery() ), - generateCSVDataFromTable( csvColumns, csvRows ) - ); - - recordEvent( 'wcpay_disputes_download', { - exported_disputes: csvRows.length, - total_disputes: disputesSummary.count, - download_type: 'browser', - } ); + endpointExport( '' ); } setIsDownloading( false ); diff --git a/client/transactions/list/index.tsx b/client/transactions/list/index.tsx index a5206ae0e5e..0ac0c84a9d0 100644 --- a/client/transactions/list/index.tsx +++ b/client/transactions/list/index.tsx @@ -711,35 +711,10 @@ export const TransactionsList = ( const onDownload = async () => { setIsDownloading( true ); - // We destructure page and path to get the right params. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { page, path, ...params } = getQuery(); - const downloadType = totalRows > rows.length ? 'endpoint' : 'browser'; - - recordEvent( 'wcpay_transactions_download_csv_click', { - location: props.depositId ? 'deposit_details' : 'transactions', - download_type: downloadType, - exported_transactions: rows.length, - total_transactions: transactionsSummary.count, - } ); - - if ( 'endpoint' === downloadType ) { - if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { - setCSVExportModalOpen( true ); - } else { - endpointExport( '' ); - } + if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { + setCSVExportModalOpen( true ); } else { - const columnsToDisplayInCsv = columnsToDisplay.map( ( column ) => { - if ( column.labelInCsv ) { - return { ...column, label: column.labelInCsv }; - } - return column; - } ); - downloadCSVFile( - generateCSVFileName( title, params ), - generateCSVDataFromTable( columnsToDisplayInCsv, rows ) - ); + endpointExport( '' ); } setIsDownloading( false ); From 9f7787b4834295254b75f1d254d938287d5824af Mon Sep 17 00:00:00 2001 From: Jessy Date: Wed, 18 Dec 2024 11:50:15 +0530 Subject: [PATCH 2/7] added changelog --- changelog/update-9764-remove-browser-export | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/update-9764-remove-browser-export diff --git a/changelog/update-9764-remove-browser-export b/changelog/update-9764-remove-browser-export new file mode 100644 index 00000000000..9689662ce16 --- /dev/null +++ b/changelog/update-9764-remove-browser-export @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Remove browser based CSV export, use async CSV export for Disputes, DPayouts and Transactions. From 6f75ab6b779c6ffa6bf0b211f4b59731b7538926 Mon Sep 17 00:00:00 2001 From: Jessy Date: Wed, 18 Dec 2024 12:40:32 +0530 Subject: [PATCH 3/7] Fixed the tests, removed tests for sync browser based CSV exports. --- client/deposits/list/test/index.tsx | 66 ++------------- client/transactions/list/test/index.tsx | 104 +++--------------------- 2 files changed, 19 insertions(+), 151 deletions(-) diff --git a/client/deposits/list/test/index.tsx b/client/deposits/list/test/index.tsx index 8eb1c3b9f78..c88bd6d058c 100644 --- a/client/deposits/list/test/index.tsx +++ b/client/deposits/list/test/index.tsx @@ -279,66 +279,18 @@ describe( 'Deposits list', () => { } ); } ); - test( 'should render expected columns in CSV when the download button is clicked', () => { + test( 'should fetch the server side export', async () => { const { getByRole } = render( ); - getByRole( 'button', { name: 'Download' } ).click(); - - const expected = [ - '"Payout Id"', - 'Date', - 'Type', - 'Amount', - 'Status', - '"Bank account"', - '"Bank reference ID"', - ]; - - const csvContent = mockDownloadCSVFile.mock.calls[ 0 ][ 1 ]; - const csvHeaderRow = csvContent.split( os.EOL )[ 0 ].split( ',' ); - expect( csvHeaderRow ).toEqual( expected ); - } ); - test( 'should match the visible rows', () => { - const { getByRole, getAllByRole } = render( ); getByRole( 'button', { name: 'Download' } ).click(); - - const csvContent = mockDownloadCSVFile.mock.calls[ 0 ][ 1 ]; - const csvRows = csvContent.split( os.EOL ); - const displayRows = getAllByRole( 'row' ); - - expect( csvRows.length ).toEqual( displayRows.length ); - - const csvFirstDeposit = csvRows[ 1 ].split( ',' ); - const displayFirstDeposit = Array.from( - displayRows[ 1 ].querySelectorAll( 'td' ) - ).map( ( td ) => td.textContent ); - - // Note: - // - // 1. CSV and display indexes are off by 1 because the first field in CSV is deposit id, - // which is missing in display. - // - // 2. The indexOf check in amount's expect is because the amount in CSV may not contain - // trailing zeros as in the display amount. - // - expect( formatDate( csvFirstDeposit[ 1 ], 'M j, Y' ) ).toBe( - displayFirstDeposit[ 0 ] - ); // date - expect( csvFirstDeposit[ 2 ] ).toBe( displayFirstDeposit[ 1 ] ); // type - expect( - getUnformattedAmount( displayFirstDeposit[ 2 ] ).indexOf( - csvFirstDeposit[ 3 ] - ) - ).not.toBe( -1 ); // amount - expect( csvFirstDeposit[ 4 ] ).toBe( - `"${ displayFirstDeposit[ 3 ] }"` - ); // status - expect( csvFirstDeposit[ 5 ] ).toBe( - `"${ displayFirstDeposit[ 4 ] }"` - ); // bank account - expect( csvFirstDeposit[ 6 ] ).toBe( - `${ displayFirstDeposit[ 5 ] }` - ); // bank reference key + await waitFor( () => { + expect( mockApiFetch ).toHaveBeenCalledTimes( 1 ); + expect( mockApiFetch ).toHaveBeenCalledWith( { + method: 'POST', + path: + '/wc/v3/payments/deposits/download?user_email=mock%40example.com&locale=en', + } ); + } ); } ); test( 'should fetch export after confirmation when download button is selected for unfiltered exports larger than 1000.', async () => { diff --git a/client/transactions/list/test/index.tsx b/client/transactions/list/test/index.tsx index b233b4d5477..c39a9ab4969 100644 --- a/client/transactions/list/test/index.tsx +++ b/client/transactions/list/test/index.tsx @@ -615,104 +615,20 @@ describe( 'Transactions list', () => { } ); } ); - test( 'should render expected columns in CSV when the download button is clicked', () => { + test( 'should fetch export when the download button is clicked', async () => { const { getByRole } = render( ); getByRole( 'button', { name: 'Download' } ).click(); - const expected = [ - '"Transaction ID"', - '"Date / Time (UTC)"', - 'Type', - 'Channel', - '"Paid Currency"', - '"Amount Paid"', - '"Payout Currency"', - 'Amount', - 'Fees', - 'Net', - '"Order #"', - '"Payment Method"', - 'Customer', - 'Email', - 'Country', - '"Risk level"', - '"Payout ID"', - '"Payout date"', - '"Payout status"', - ]; - - // checking if columns in CSV are rendered correctly - expect( - mockDownloadCSVFile.mock.calls[ 0 ][ 1 ] - .split( '\n' )[ 0 ] - .split( ',' ) - ).toEqual( expected ); - } ); - - test( 'should match the visible rows', () => { - const { getByRole, getAllByRole } = render( ); - - getByRole( 'button', { name: 'Download' } ).click(); - - const csvContent = mockDownloadCSVFile.mock.calls[ 0 ][ 1 ]; - const csvRows = csvContent.split( os.EOL ); - const displayRows: HTMLElement[] = getAllByRole( 'row' ); - - expect( csvRows.length ).toEqual( displayRows.length ); - - const csvFirstTransaction = csvRows[ 1 ].split( ',' ); - const displayFirstTransaction: string[] = Array.from( - displayRows[ 1 ].querySelectorAll( 'td' ) - ).map( ( td: HTMLElement ) => td.textContent || '' ); - - // Date/Time column is a th - // Extract is separately and prepend to csvFirstTransaction - const displayFirstRowHead: string[] = Array.from( - displayRows[ 1 ].querySelectorAll( 'th' ) - ).map( ( th: HTMLElement ) => th.textContent || '' ); - displayFirstTransaction.unshift( displayFirstRowHead[ 0 ] ); - - // Note: - // - // 1. CSV and display indexes are off by 1 because the first field in CSV is transaction id, - // which is missing in display. - // - // 2. The indexOf check in amount's expect is because the amount in CSV may not contain - // trailing zeros as in the display amount. - // - expect( displayFirstTransaction[ 0 ] ).toBe( - formatDate( csvFirstTransaction[ 1 ].replace( /['"]+/g, '' ) ) // strip extra quotes - ); // date - expect( displayFirstTransaction[ 1 ] ).toBe( - csvFirstTransaction[ 2 ] - ); // type - expect( displayFirstTransaction[ 2 ] ).toBe( - csvFirstTransaction[ 3 ] - ); // channel - expect( - getUnformattedAmount( displayFirstTransaction[ 3 ] ).indexOf( - csvFirstTransaction[ 7 ] - ) - ).not.toBe( -1 ); // amount - expect( - -Number( getUnformattedAmount( displayFirstTransaction[ 4 ] ) ) - ).toEqual( - Number( - csvFirstTransaction[ 8 ].replace( /['"]+/g, '' ) // strip extra quotes - ) - ); // fees - expect( - getUnformattedAmount( displayFirstTransaction[ 5 ] ).indexOf( - csvFirstTransaction[ 9 ] - ) - ).not.toBe( -1 ); // net - expect( displayFirstTransaction[ 6 ] ).toBe( - csvFirstTransaction[ 10 ] - ); // order number - expect( displayFirstTransaction[ 8 ] ).toBe( - csvFirstTransaction[ 12 ].replace( /['"]+/g, '' ) // strip extra quotes - ); // customer + await waitFor( () => { + expect( mockApiFetch ).toHaveBeenCalledTimes( 1 ); + expect( mockApiFetch ).toHaveBeenCalledWith( { + method: 'POST', + path: `/wc/v3/payments/transactions/download?user_email=mock%40example.com&user_timezone=${ encodeURIComponent( + getUserTimeZone() + ) }&locale=en`, + } ); + } ); } ); } ); } ); From 5e9916fd23491a6904a2095d689d6d8faf210100 Mon Sep 17 00:00:00 2001 From: Jessy Date: Wed, 18 Dec 2024 13:14:35 +0530 Subject: [PATCH 4/7] Fixed the tests to test server side download - Also fixed some issues with the test file. --- client/deposits/list/test/index.tsx | 2 +- client/disputes/test/index.tsx | 81 +++++------------------------ 2 files changed, 13 insertions(+), 70 deletions(-) diff --git a/client/deposits/list/test/index.tsx b/client/deposits/list/test/index.tsx index c88bd6d058c..8d515038cf6 100644 --- a/client/deposits/list/test/index.tsx +++ b/client/deposits/list/test/index.tsx @@ -279,7 +279,7 @@ describe( 'Deposits list', () => { } ); } ); - test( 'should fetch the server side export', async () => { + test( 'should fetch export when the download button is clicked', async () => { const { getByRole } = render( ); getByRole( 'button', { name: 'Download' } ).click(); diff --git a/client/disputes/test/index.tsx b/client/disputes/test/index.tsx index 1409bfc852d..2a88a2099bc 100644 --- a/client/disputes/test/index.tsx +++ b/client/disputes/test/index.tsx @@ -43,6 +43,7 @@ jest.mock( '@wordpress/data', () => ( { dispatch: jest.fn( () => ( { setIsMatching: jest.fn(), onLoad: jest.fn(), + onHistoryChange: jest.fn(), } ) ), registerStore: jest.fn(), select: jest.fn(), @@ -165,6 +166,8 @@ const mockDisputes = [ describe( 'Disputes list', () => { beforeEach( () => { + jest.clearAllMocks(); + // mock Date.now that moment library uses to get current date for testing purposes Date.now = jest.fn( () => new Date( '2019-11-07T12:33:37.000Z' ).getTime() @@ -293,79 +296,19 @@ describe( 'Disputes list', () => { } ); } ); - test( 'should render expected columns in CSV when the download button is clicked ', () => { + test( 'should fetch export when the download button is clicked', async () => { const { getByRole } = render( ); - getByRole( 'button', { name: 'Download' } ).click(); - - const expected = [ - '"Dispute Id"', - 'Amount', - 'Currency', - 'Status', - 'Reason', - 'Source', - '"Order #"', - 'Customer', - 'Email', - 'Country', - '"Disputed on"', - '"Respond by"', - ]; - - const csvContent = mockDownloadCSVFile.mock.calls[ 0 ][ 1 ]; - const csvHeaderRow = csvContent.split( os.EOL )[ 0 ].split( ',' ); - expect( csvHeaderRow ).toEqual( expected ); - } ); - test( 'should match the visible rows', () => { - const { getByRole, getAllByRole } = render( ); getByRole( 'button', { name: 'Download' } ).click(); - const csvContent = mockDownloadCSVFile.mock.calls[ 0 ][ 1 ]; - const csvRows = csvContent.split( os.EOL ); - const displayRows = getAllByRole( 'row' ); - - expect( csvRows.length ).toEqual( displayRows.length ); - - const csvFirstDispute = csvRows[ 1 ].split( ',' ); - const displayFirstDispute = Array.from( - displayRows[ 1 ].querySelectorAll( 'td' ) - ).map( ( td ) => td.textContent ); - - // Note: - // - // 1. CSV and display indexes are off by 2 because: - // - the first field in CSV is dispute id, which is missing in display. - // - the third field in CSV is currency, which is missing in display (it's displayed in "amount" column). - // - // 2. The indexOf check in amount's expect is because the amount in CSV may not contain - // trailing zeros as in the display amount. - // - expect( - getUnformattedAmount( displayFirstDispute[ 0 ] ).indexOf( - csvFirstDispute[ 1 ] - ) - ).not.toBe( -1 ); // amount - - expect( csvFirstDispute[ 2 ] ).toBe( 'usd' ); - - expect( csvFirstDispute[ 3 ] ).toBe( - `"${ displayFirstDispute[ 1 ] }"` - ); //status - - expect( csvFirstDispute[ 4 ] ).toBe( - `"${ displayFirstDispute[ 2 ] }"` - ); // reason - - expect( csvFirstDispute[ 6 ] ).toBe( displayFirstDispute[ 4 ] ); // order - - expect( csvFirstDispute[ 7 ] ).toBe( - `"${ displayFirstDispute[ 5 ] }"` - ); // customer - - expect( formatDate( csvFirstDispute[ 11 ], 'Y-m-d / g:iA' ) ).toBe( - formatDate( displayFirstDispute[ 6 ], 'Y-m-d / g:iA' ) - ); // date respond by + await waitFor( () => { + expect( mockApiFetch ).toHaveBeenCalledTimes( 1 ); + expect( mockApiFetch ).toHaveBeenCalledWith( { + method: 'POST', + path: + '/wc/v3/payments/disputes/download?user_email=mock%40example.com&locale=en', + } ); + } ); } ); } ); } ); From 3b0a8677f16aa7db3d57bbcd896cfb68a2cac8ac Mon Sep 17 00:00:00 2001 From: Nagesh Pai Date: Wed, 18 Dec 2024 19:00:04 +0530 Subject: [PATCH 5/7] Remove unused vars --- client/deposits/list/index.tsx | 7 ------- client/disputes/index.tsx | 6 ------ client/transactions/list/test/index.tsx | 20 -------------------- 3 files changed, 33 deletions(-) diff --git a/client/deposits/list/index.tsx b/client/deposits/list/index.tsx index dd3d737a8fb..a2a20aaa13e 100644 --- a/client/deposits/list/index.tsx +++ b/client/deposits/list/index.tsx @@ -11,11 +11,6 @@ import { __, _n, sprintf } from '@wordpress/i18n'; import moment from 'moment'; import { TableCard, Link } from '@woocommerce/components'; import { onQueryChange, getQuery } from '@woocommerce/navigation'; -import { - downloadCSVFile, - generateCSVDataFromTable, - generateCSVFileName, -} from '@woocommerce/csv-export'; import apiFetch from '@wordpress/api-fetch'; import { useDispatch } from '@wordpress/data'; import { parseInt } from 'lodash'; @@ -221,8 +216,6 @@ export const DepositsList = (): JSX.Element => { depositsSummary.store_currencies || ( isCurrencyFiltered ? [ getQuery().store_currency_is ] : [] ); - const title = __( 'Payouts', 'woocommerce-payments' ); - const downloadable = !! rows.length; const endpointExport = async ( language: string ) => { diff --git a/client/disputes/index.tsx b/client/disputes/index.tsx index 7471c130d0b..727d4f04e39 100644 --- a/client/disputes/index.tsx +++ b/client/disputes/index.tsx @@ -11,11 +11,6 @@ import moment from 'moment'; import { Button } from '@wordpress/components'; import { TableCard, Link } from '@woocommerce/components'; import { onQueryChange, getQuery, getHistory } from '@woocommerce/navigation'; -import { - downloadCSVFile, - generateCSVDataFromTable, - generateCSVFileName, -} from '@woocommerce/csv-export'; import classNames from 'classnames'; import apiFetch from '@wordpress/api-fetch'; import { useDispatch } from '@wordpress/data'; @@ -43,7 +38,6 @@ import { } from 'multi-currency/interface/functions'; import DisputesFilters from './filters'; import DownloadButton from 'components/download-button'; -import disputeStatusMapping from 'components/dispute-status-chip/mappings'; import { CachedDispute, DisputesTableHeader } from 'wcpay/types/disputes'; import { getDisputesCSV } from 'wcpay/data/disputes/resolvers'; import { diff --git a/client/transactions/list/test/index.tsx b/client/transactions/list/test/index.tsx index c39a9ab4969..54daa89b686 100644 --- a/client/transactions/list/test/index.tsx +++ b/client/transactions/list/test/index.tsx @@ -7,12 +7,8 @@ import * as React from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import user from '@testing-library/user-event'; import apiFetch from '@wordpress/api-fetch'; -import { dateI18n } from '@wordpress/date'; -import { downloadCSVFile } from '@woocommerce/csv-export'; import { getQuery, updateQueryString } from '@woocommerce/navigation'; import { getUserTimeZone } from 'wcpay/utils/test-utils'; -import moment from 'moment'; -import os from 'os'; /** * Internal dependencies @@ -58,10 +54,6 @@ jest.mock( 'data/index', () => ( { useReportingExportLanguage: jest.fn( () => [ 'en', jest.fn() ] ), } ) ); -const mockDownloadCSVFile = downloadCSVFile as jest.MockedFunction< - typeof downloadCSVFile ->; - const mockApiFetch = apiFetch as jest.MockedFunction< typeof apiFetch >; const mockUseTransactions = useTransactions as jest.MockedFunction< @@ -199,18 +191,6 @@ const getMockTransactions: () => Transaction[] = () => [ }, ]; -function getUnformattedAmount( formattedAmount: string ) { - const amount = formattedAmount.replace( /[^0-9,.' ]/g, '' ).trim(); - return amount.replace( ',', '.' ); // Euro fix -} - -function formatDate( date: string ) { - return dateI18n( - 'M j, Y / g:iA', - moment.utc( date ).local().toISOString() - ); -} - describe( 'Transactions list', () => { beforeEach( () => { jest.clearAllMocks(); From 1f054fd6b97394d6898489e5f8b2be79b2eebd65 Mon Sep 17 00:00:00 2001 From: Nagesh Pai Date: Wed, 18 Dec 2024 19:21:52 +0530 Subject: [PATCH 6/7] Remove more unused var and imports --- client/deposits/list/test/index.tsx | 8 -------- client/disputes/test/index.tsx | 7 ------- 2 files changed, 15 deletions(-) diff --git a/client/deposits/list/test/index.tsx b/client/deposits/list/test/index.tsx index 8d515038cf6..8f8d36a1262 100644 --- a/client/deposits/list/test/index.tsx +++ b/client/deposits/list/test/index.tsx @@ -5,11 +5,8 @@ */ import { render, waitFor } from '@testing-library/react'; import { updateQueryString } from '@woocommerce/navigation'; -import { downloadCSVFile } from '@woocommerce/csv-export'; import apiFetch from '@wordpress/api-fetch'; -import os from 'os'; - /** * Internal dependencies */ @@ -19,7 +16,6 @@ import { useDepositsSummary, useReportingExportLanguage, } from 'wcpay/data'; -import { formatDate, getUnformattedAmount } from 'wcpay/utils/test-utils'; import { CachedDeposit, CachedDeposits, @@ -117,10 +113,6 @@ const mockUseDepositsSummary = useDepositsSummary as jest.MockedFunction< typeof useDepositsSummary >; -const mockDownloadCSVFile = downloadCSVFile as jest.MockedFunction< - typeof downloadCSVFile ->; - const mockUseReportingExportLanguage = useReportingExportLanguage as jest.MockedFunction< typeof useReportingExportLanguage >; diff --git a/client/disputes/test/index.tsx b/client/disputes/test/index.tsx index 2a88a2099bc..48ffa4df6d5 100644 --- a/client/disputes/test/index.tsx +++ b/client/disputes/test/index.tsx @@ -3,9 +3,7 @@ * External dependencies */ import { render, waitFor } from '@testing-library/react'; -import { downloadCSVFile } from '@woocommerce/csv-export'; import apiFetch from '@wordpress/api-fetch'; -import os from 'os'; /** * Internal dependencies @@ -17,7 +15,6 @@ import { useReportingExportLanguage, useSettings, } from 'data/index'; -import { formatDate, getUnformattedAmount } from 'wcpay/utils/test-utils'; import React from 'react'; import { CachedDispute, @@ -59,10 +56,6 @@ jest.mock( 'data/index', () => ( { useSettings: jest.fn(), } ) ); -const mockDownloadCSVFile = downloadCSVFile as jest.MockedFunction< - typeof downloadCSVFile ->; - const mockApiFetch = apiFetch as jest.MockedFunction< typeof apiFetch >; const mockUseDisputes = useDisputes as jest.MockedFunction< From 248f47e520dc628d16f77053c376dfd99193e1f3 Mon Sep 17 00:00:00 2001 From: Nagesh Pai Date: Wed, 18 Dec 2024 19:38:37 +0530 Subject: [PATCH 7/7] Remove unused vars --- client/transactions/list/index.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/client/transactions/list/index.tsx b/client/transactions/list/index.tsx index 0ac0c84a9d0..dae1276e843 100644 --- a/client/transactions/list/index.tsx +++ b/client/transactions/list/index.tsx @@ -21,11 +21,6 @@ import { getQuery, updateQueryString, } from '@woocommerce/navigation'; -import { - downloadCSVFile, - generateCSVDataFromTable, - generateCSVFileName, -} from '@woocommerce/csv-export'; import apiFetch from '@wordpress/api-fetch'; /** @@ -62,7 +57,6 @@ import autocompleter from 'transactions/autocompleter'; import './style.scss'; import TransactionsFilters from '../filters'; import Page from '../../components/page'; -import { recordEvent } from 'tracks'; import DownloadButton from 'components/download-button'; import CSVExportModal from 'components/csv-export-modal'; import { getTransactionsCSV } from '../../data/transactions/resolvers';